-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(voice): enforce interruption min_duration on STT transcript triggers (#3515) #6417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dorukdumlu
wants to merge
6
commits into
livekit:main
Choose a base branch
from
dorukdumlu:fix/min-interruption-duration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+276
−3
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef5f737
fix(voice): enforce interruption min_duration on STT transcript trigg…
dorukdumlu 331d819
fix(voice): use VAD voiced duration for STT min_duration gate
dorukdumlu 6b38397
fix(voice): keep VAD speech duration after Silero post-EOS zero
dorukdumlu fd18dcd
fix(voice): clear vad speech duration on turn commit
dorukdumlu 3ad3376
fix(voice): update VAD duration before interruption hook
dorukdumlu a97f724
fix(voice): ignore zero VAD duration while STT already speaking
dorukdumlu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Agent can keep talking over a user whose barge-in the voice detector missed
The barge-in check compares the length of a previous, already-finished stretch of user speech (
current_speech_durationatlivekit-agents/livekit/agents/voice/agent_activity.py:2053) against the minimum-speech setting, so a user who speaks a full sentence that the voice detector misses can be judged "too short" and fail to stop the agent.Impact: The agent can continue speaking over a user who clearly barged in, until the end-of-turn logic eventually commits (or, if that turn is dropped, not at all).
Stale `_vad_speech_duration` defeats the documented final-transcript failsafe
_vad_speech_durationis written on VAD START_OF_SPEECH/INFERENCE_DONE/END_OF_SPEECH (livekit-agents/livekit/agents/voice/audio_recognition.py:1428,:1457-1458,:1490) and only cleared on_clear_user_turn(:1066) or on a committed turn (:1821). Post-EOS inference frames withspeech_duration == 0are deliberately skipped, so the last completed segment's duration persists indefinitely.Sequence: (1) a short VAD blip (e.g. 0.2 s of noise) fires SOS/EOS, producing no transcript, so
_run_eou_detectionreturns early and the turn is never committed —_vad_speech_durationstays 0.2; (2) the user then barges in for real but VAD misses it (poor AEC / echo suppression), so no new VAD event arrives; (3)on_final_transcriptfires the failsafe call to_interrupt_by_audio_activity(livekit-agents/livekit/agents/voice/agent_activity.py:2275), whose new gate reads the stale 0.2 and returns early.The new code comment at
livekit-agents/livekit/agents/voice/agent_activity.py:2047-2048states unknown duration is passed through precisely to preserve this failsafe, but a stale value from an unrelated earlier segment is notNone, so the exemption never applies.current_speech_duration's own docstring claims it reports the "current or most recent user speech segment" — during a VAD miss it reports a different, older segment.Consider invalidating
_vad_speech_durationwhen the segment it belongs to is no longer current (e.g. clearing it on VAD END_OF_SPEECH after a grace period, or recording the timestamp of the measurement and ignoring durations older than the current speech start).Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.