voice: add opt-in audio turn detector hook#5514
Draft
piyush-gambhir wants to merge 1 commit intolivekit:mainfrom
Draft
voice: add opt-in audio turn detector hook#5514piyush-gambhir wants to merge 1 commit intolivekit:mainfrom
piyush-gambhir wants to merge 1 commit intolivekit:mainfrom
Conversation
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
This PR adds an opt-in extension point for audio-native turn detectors in
livekit-agents.Today, custom turn detectors operate on chat or transcript context only. This change adds:
AudioTurnContext, a public container for buffered current-turn audio plus transcript and chat contextAudioTurnDetector, a public protocol for audio-native end-of-turn detectorsAudioRecognitionMotivation
Some turn detectors operate directly on audio rather than text. Those detectors cannot currently plug into the existing custom turn-detection API because only
ChatContextis exposed to custom detectors.This PR adds the minimal generic hook needed to support that class of detector without introducing any provider-specific dependency.
Scope
Validation
make checkuv run pytest tests/test_agent_session.py tests/test_audio_recognition_handoff.py tests/test_audio_turn_detection.py -quv run python -m py_compile examples/voice_agents/audio_turn_detector.pyuv run examples/voice_agents/audio_turn_detector.py --helpNotes
This draft intentionally keeps the change generic and provider-agnostic. A follow-up plugin PR can implement a concrete detector on top of this hook.
This is also intended as a narrower, lower-risk framing of audio-based turn detection than the earlier feature request in #3094.