Skip to content

fix(speech): wait for the new STT to be ready before replaying - #303

Merged
akirilyuk merged 2 commits into
mainfrom
fix/stt-ready-gate
Oct 5, 2026
Merged

akirilyuk merged 2 commits into
mainfrom
fix/stt-ready-gate

Conversation

@akirilyuk

Copy link
Copy Markdown
Owner

Symptom

With a speech backend that rejects new streams for about 30 s after it starts, a host that swaps the STT and calls releaseSttHold({ replay: true }) (or replayLastUtterance()) saw the replay stall in finalize and end with no final. When the stream finally opened, the queued audio was transcribed and the final came out as a plain user_speech_final, so hosts treated it as a new utterance.

Cause

The replay fed the held audio into the new STT before its stream was open. The single finalize wait (2 s) expired, the release completed without a final, and the replay context was gone by the time the late final arrived.

Change

  • SttProvider::wait_ready(timeout) (default: always ready). The cluster STT shares a readiness signal between its stream task and the provider: true on Ready, false on every (re)open and when the task exits.
  • release_stt_hold and replay_last_utterance wait up to SPEECH_STT_READY_WAIT_MS (default 15000) before feeding audio. On timeout they log and replay anyway.
  • If release_stt_hold gets no final, the replay context stays armed so a late final is still flagged replay: true. A context older than 15 s is dropped, so a lost replay cannot mislabel a later utterance.
  • The cluster STT logs a denied stream open once, then every 5 s, and logs the denied-attempt count when the stream opens.
  • Docs and CHANGELOG updated.

Tests

  • held_replay_waits_for_stt_ready, replay_ready_wait_times_out_and_continues, late_final_after_held_replay_is_flagged_replay, stale_replay_context_does_not_flag_later_utterance (speech crate).
  • Readiness-watch test against the in-process mock server, and unit tests for the denied-open log throttle (cluster speech crate).

Verified locally and via CI; no extra manual steps.

🤖 Generated with Claude Code

akirilyuk and others added 2 commits October 5, 2026 07:50
…the replay flag on a late final

SttProvider gains wait_ready; the cluster STT reports readiness from its stream
task. release_stt_hold and replay_last_utterance wait for it (SPEECH_STT_READY_WAIT_MS,
default 15 s) before feeding audio. A replay final that arrives after the release
returned keeps replay=true for up to 15 s. Denied stream opens are logged once, then
every 5 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@akirilyuk
akirilyuk merged commit a17a66f into main Oct 5, 2026
8 checks passed
@akirilyuk
akirilyuk deleted the fix/stt-ready-gate branch October 5, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant