Aller au contenu
login
arrow_backRetour aux issues
mbailey/voicemode #211

Feature Request: Barge-in / Interrupt TTS playback when user starts speaking

ecoDébutant enhancement help wanted

descriptionDescription

## Problem Statement Currently, when Claude responds via TTS, users must wait for the entire response to finish before they can speak. This creates friction in natural conversation, especially when: - The user has already understood the point and wants to respond - The user needs to redirect the conversation - The response is longer than necessary for the user's needs ## Proposed Solution Add a "barge-in" or interrupt capability that detects when the user starts speaking and: 1. Immediately stops TTS playback 2. Seamlessly transitions to recording the user's voice input 3. Continues the conversation without requiring manual intervention ## Technical Approach Looking at the existing `NonBlockingAudioPlayer` class in `audio_player.py`, a potential implementation could: 1. **Add a parallel VAD (Voice Activity Detection) thread** that continuously monitors the microphone during TTS playback 2. **When voice activity is detected**, stop the current TTS playback by: - Clearing the audio queue - Calling `stream.stop()` - Setting the `playback_complete` event 3. **Capture the user's speech** and send it to Whisper for transcription 4. **Submit the transcription** to Claude as the next input The existing code already uses threading and has mechanisms for stopping playback (`CallbackStop`, `playback_complete` event), so the infrastructure is partially there. ## Use Case I use VoiceMode for hands-free coding assistance while working at my desk. The current turn-taking model works well for structured interactions, but true conversational flow requires the ability to interrupt when needed—similar to how human conversations naturally work. This is especially valuable when: - Claude is explaining something I already understand - I realize I need to clarify my question mid-response - I want to say "yes, do that" before Claude finishes listing all options ## Configuration Suggestion This could be an opt-in feature via environment variable: ``` VOICEMODE_BARGE_IN=true ``` Some users might prefer the current sequential behavior for its predictability, so making it configurable would accommodate both preferences. ## Additional Context - This feature is common in commercial voice assistants (Alexa, Google Assistant, Siri all support barge-in) - The VAD functionality is already available through libraries like `webrtcvad` or could leverage the existing silence detection logic - Low latency detection would be important to feel responsive (ideally <100ms from voice onset to TTS stop) Thank you for building such a useful tool! VoiceMode has made hands-free coding with Claude practical and enjoyable.
codeOuvre sur GitHub