feat(voice): expose SpeechHandle.hold_interruptions context manager - #7201
Open
devtechedge wants to merge 2 commits into
Open
feat(voice): expose SpeechHandle.hold_interruptions context manager#7201devtechedge wants to merge 2 commits into
devtechedge wants to merge 2 commits into
Conversation
Public counted/restoring hold for per-utterance barge-in protection under server-side turn detection, and demote the realtime input_speech_started uninterruptible path from exception to debug now that holds are supported. Fixes livekit#7191
Assignments while hold_interruptions is active now update the value restored on final release; effective interruptibility stays false until then. force=True still cuts through. Covers True/False during nested holds.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #7191.
SpeechHandle._hold_interruptions()/_release_interruptions()already implement counted, restoring per-utterance barge-in protection, but were private. Realtime callers that need onesay()(or a group of them) to survive server-side turn detection had no supported API:allow_interruptions=Falseis scrubbed under realtime, and a bare setter does not compose across overlapping holders.This exposes a public context manager that wraps the existing hold/release, and demotes the realtime
input_speech_started"not interruptable" path fromlogger.exceptiontologger.debug, since that path is reachable by design once holds are supported (interrupt(force=True)still cuts through).Changes
livekit-agents/livekit/agents/voice/speech_handle.py: addSpeechHandle.hold_interruptions()context managerlivekit-agents/livekit/agents/voice/agent_activity.py: debug-level log when realtime barge-in hits a non-interruptable speechtests/test_speech_handle_hold_interruptions.py: unit coverage for restore, nesting, prior-False preserve, andforce=TrueUsage
Test plan
uv run --directory livekit-agents pytest ../tests/test_speech_handle_hold_interruptions.py -q(4 passed)