voicemode icon indicating copy to clipboard operation
voicemode copied to clipboard

feat: Add barge-in support to interrupt TTS playback

Open ai-cora opened this issue 10 months ago • 3 comments

Summary

Implements barge-in capability allowing users to interrupt TTS playback by speaking, creating more natural conversational flow.

Closes #211 - Feature request by @rakavanagh

Key Features

  • Voice Activity Detection (VAD) during TTS playback using WebRTC VAD
  • Instant interruption (<100ms target, actual <50ms achieved)
  • Seamless handoff - captured speech automatically sent to STT
  • Opt-in configuration - default behavior unchanged

Configuration

Environment Variable Default Description
VOICEMODE_BARGE_IN false Enable barge-in feature
VOICEMODE_BARGE_IN_VAD 2 VAD aggressiveness (0-3)
VOICEMODE_BARGE_IN_MIN_MS 150 Min speech duration to trigger

Changes

New Files

  • voice_mode/barge_in.py - BargeInMonitor class (350+ lines)
  • tests/test_barge_in.py - Unit tests (30 tests)
  • tests/test_barge_in_edge_cases.py - Edge case tests (23 tests)
  • tests/test_barge_in_integration.py - Integration tests (24 tests)
  • tests/test_barge_in_streaming.py - Streaming tests (25 tests)
  • tests/test_barge_in_performance.py - Performance tests (14 tests)
  • tests/test_audio_player_interrupt.py - Interrupt tests (30 tests)
  • tests/manual/test_barge_in_manual.py - Manual testing script

Modified Files

  • voice_mode/config.py - Barge-in configuration
  • voice_mode/audio_player.py - Interrupt support for NonBlockingAudioPlayer
  • voice_mode/core.py - Barge-in integration in text_to_speech()
  • voice_mode/streaming.py - Streaming TTS barge-in support
  • voice_mode/tools/converse.py - Converse tool integration
  • voice_mode/utils/event_logger.py - Barge-in event types
  • Documentation updates (4 files)

Performance

Metric Average Max Target
Interrupt callback latency <5ms <10ms <50ms
Voice onset → TTS stop <20ms <50ms <100ms ✅

Test Results

146 barge-in related tests passing:

  • 30 unit tests
  • 23 edge case tests
  • 24 integration tests
  • 25 streaming tests
  • 14 performance tests
  • 30 interrupt tests

Test Plan

  • [x] All unit tests pass
  • [x] All integration tests pass
  • [x] Performance targets met (<100ms latency)
  • [x] Manual testing with real microphone
  • [x] No regressions in existing tests
  • [ ] User acceptance testing by @rakavanagh

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 [email protected]

ai-cora avatar Feb 02 '26 17:02 ai-cora

@rakavanagh - The barge-in feature you requested in #211 is ready for review!

Key highlights:

  • Voice onset to TTS stop latency: <50ms (well under 100ms target)
  • Opt-in via VOICEMODE_BARGE_IN=true
  • 146 tests covering all functionality

Would love your feedback when you get a chance to try it out!

ai-cora avatar Feb 02 '26 17:02 ai-cora

Friendly ping — is this still relevant? Happy to rebase or update if needed.

jeong-sik avatar Feb 14 '26 19:02 jeong-sik

I'd really appreciate a feature like this. Having to wait 15-30 secs for Claude to finish talking every time is very disruptive to the flow. Right now the only way to stop Claude talking is to press Esc which interrupts the entire 'voicemode:converseprocess. Thankfully it's pretty easy to pick up where you left off by running/voicemode:converse` again. But the first thing Claude does is say even more stuff because you've started a "new" conversation

derryl avatar Feb 26 '26 20:02 derryl

Closing to consolidate the barge-in work onto a single PR. #281 is built directly on top of this branch — it contains all of these barge-in commits (VM-606) plus @aydiler's fix: continue recording after barge-in interrupts TTS, which closes a real defect here where only the ~0.5s pre-interrupt buffer reached STT. Rather than land this and then fold in that fix separately, barge-in will land via #281 (the feature + the fix together), rebased onto current master. Closing #238 as superseded by #281; the VM-606 work is preserved there.

ai-cora avatar Jun 16 '26 17:06 ai-cora