Skip to content

STT turn detection: a final transcript that arrives after a later END_OF_SPEECH leaves every later turn committed one utterance late #7699

Closed as not planned

Description

@anirudhsama

Bug Description

With turn_detection="stt", a FINAL_TRANSCRIPT that arrives after a turn has already been committed on a later END_OF_SPEECH is never committed on its own. It waits for the next END_OF_SPEECH, and from then on every turn is committed one utterance late. Each reply answers the previous utterance and is interrupted by the late final before it plays, so the agent sounds silent until the caller hangs up.

AudioRecognition sets _user_turn_committed on END_OF_SPEECH, runs EOU on FINAL_TRANSCRIPT only while it is set, and clears it after every EOU run. This works when each utterance's final arrives before the next START_OF_SPEECH. It breaks when the user resumes in the gap between an STT's end of speech and its final:

START(A)  END(A)            # committed=True; no transcript yet, EOU skipped
START(B)                    # user resumes before A's final
FINAL(A)                    # speaking=True, so no EOU; A stays in _audio_transcript
END(B)                      # committed=True; EOU commits "A"; committed=False
FINAL(B)                    # committed=False, so no EOU; B waits for END(C)

After that, every END(n) commits utterance n-1, and on_final_transcript → _interrupt_by_audio_activity() interrupts the reply it started. The chain only breaks on an utterance that produces no final.

Any STT that sends END_OF_SPEECH before FINAL_TRANSCRIPT can trigger this. Sarvam's realtime endpoint does, and the gap is a few hundred ms. With a 300 ms silence window, a short pause mid-sentence is enough. It affected about 7% of our production phone calls.

livekit-plugins-sarvam's realtime stream (stt_streaming.py) triggers it directly: it emits END_OF_SPEECH on vad.speech_end, and vad.speech_start calls _reset_utterance_state(). So a resumed user's held final(A) is emitted after END(B), and final(B) is stranded as above. The legacy stt.py holds END_OF_SPEECH until the final and drops it on a resume, so it isn't affected.

Expected Behavior

A final that arrives once the user has stopped speaking ends the turn, as Pipecat's ExternalUserTurnStopStrategy does: it re-evaluates "not speaking, has final text, no interim results still waiting for a final" on every signal and on a short timer, rather than latching on the stop signal. Fragments that arrive while the user is still speaking join the same turn, which already happens.

Possible fixes: keep _user_turn_committed set until the next START_OF_SPEECH rather than clearing it on commit, or run EOU on a final whenever _speaking is false in STT mode.

Reproduction Steps

Feed this event sequence through an stt_node with turn_detection="stt", vad=None, min_endpointing_delay=0:

  1. START_OF_SPEECH, END_OF_SPEECH, START_OF_SPEECH
  2. 50 ms later, FINAL_TRANSCRIPT("I need the OTP.")
  3. 200 ms later, END_OF_SPEECH
  4. 50 ms later, FINAL_TRANSCRIPT("For the guard.")

Expected: one user turn, "I need the OTP. For the guard.", and a reply. Actual: "I need the OTP." is committed at step 3, and "For the guard." is not committed until another END_OF_SPEECH arrives.

Operating System

Linux

Models Used

Sarvam saaras:v3-realtime (STT), any LLM

Package Versions

@livekit/agents 1.9.0 (Node). The same logic is in livekit/agents main (dbe555b) and livekit/agents-js main (11e204f) as of 2026-10-09.

Session/Room/Call IDs

No response

Proposed Solution

We worked around it in our own Sarvam realtime STT. It holds END_OF_SPEECH until every `vad.speech_end` in the utterance has had its `transcript.final`, with a 2 s fallback. A `vad.speech_start` before then continues the same utterance: no new START_OF_SPEECH, and the pending END_OF_SPEECH is dropped. A final that arrives after the fallback has fired is followed by its own END_OF_SPEECH. That keeps FINAL before END for every turn, so commits happen on the END after the final.

Additional Context

No response

Screenshots and Recordings

No response

Activity

  1. davidzhao commented on Oct 10, 2026

    @davidzhao
    Member

    Thanks for the report! This looks like the same root cause as #6504, so I'm closing it as a duplicate to keep the discussion in one place. Please follow #6504 for updates, and if your case differs (different provider, version, or repro), add the details there and we'll reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions