Handling Interruptions, Barge-In, and Real-Time Speech Cut-Through
How to implement real barge-in: detecting caller speech during TTS, cutting through audio safely, and keeping duplex conversation natural.
Handling Interruptions (Barge-In) and Real-Time Speech Cut-Through in VoiceBridge
True full-duplex AI voice is not defined by whether audio flows in both directions. It is defined by whether a caller can interrupt the AI naturally — exactly like a human conversation.
If the AI keeps speaking while the caller talks, the experience becomes an IVR, not a real conversation. VoiceBridge solves this using a production-grade barge-in detection and cut-through control pipeline built directly into the RTP and realtime AI flow.
Architecture reference: MYLINEHUB VoiceBridge Architecture
Why barge-in is the real test of full-duplex voice
Many Asterisk AI integrations claim “real-time voice” but fail at interruptions. Common failures include:
- Turn-based playback where caller must wait for TTS to finish.
- One-way RTP during playback, preventing simultaneous speech.
- No mechanism to cancel AI generation mid-response.
VoiceBridge treats barge-in as a core duplex requirement, not an optional feature.
Where barge-in logic lives in the VoiceBridge codebase
Barge-in is implemented inside the open-source VoiceBridge project: mylinehub-voicebridge
-
src/main/java/com/mylinehub/voicebridge/barge/BargeInController.javaCore detection loop that evaluates caller speech energy and triggers interruption. -
src/main/java/com/mylinehub/voicebridge/barge/AudioEnergy.javaLightweight PCM energy calculation used for real-time speech detection. -
src/main/java/com/mylinehub/voicebridge/barge/OutboundAudioController.javaImmediately stops outbound AI audio and clears RTP send queues. -
src/main/java/com/mylinehub/voicebridge/openai/OpenAiRealtimeTruncateManager.javaCancels or truncates realtime AI generation so the conversation remains coherent.
How real-time interruption actually works
VoiceBridge performs barge-in using a continuous loop:
- Caller speech arrives via RTP from Asterisk.
- PCM frames are analyzed for energy above a defined threshold.
- Multiple consecutive frames confirm real speech (not noise).
- Outbound AI audio is stopped instantly.
- Realtime AI generation is truncated or cancelled.
- Conversation resumes with caller input as the next turn.
This ensures natural conversational timing instead of robotic turn-taking.
Speech detection strategy used by VoiceBridge
Instead of heavy Voice Activity Detection libraries, VoiceBridge uses a fast RMS-based energy model:
- Per-frame PCM energy calculation.
- Short sliding window smoothing.
- Consecutive hit requirement to avoid noise triggers.
- Cooldown window to prevent rapid stop/start flapping.
This approach is intentionally lightweight so it works reliably in real telecom RTP streams.
Instant AI audio cancellation and RTP cut-through
Detecting speech is only half the problem. The system must also stop AI audio immediately.
VoiceBridge achieves this using the outbound controller:
- Clears queued audio packets.
- Cancels active RTP send loops.
- Resets pacing so new speech starts cleanly.
Without this, callers would still hear the tail end of AI speech after interrupting — breaking conversational realism.
Realtime AI truncation to keep conversation state correct
Even after local audio stops, the remote AI may still be generating audio. VoiceBridge therefore coordinates interruption with realtime AI sessions.
The truncation manager ensures:
- AI stops producing unused audio.
- Conversation state remains synchronized.
- Next AI response reflects caller interruption correctly.
Barge-in flow inside a duplex VoiceBridge call
The key requirement is that interruption propagates through every stage of the duplex pipeline.
Why this makes VoiceBridge different from IVR-style AI systems
Traditional IVR AI:
- No real interruption handling.
- Turn-based audio playback.
- Caller waits → AI speaks → repeat.
VoiceBridge full-duplex AI:
- Caller and AI can speak simultaneously.
- Interruptions are detected in milliseconds.
- AI audio stops instantly and conversation continues naturally.
Operational tuning for production deployments
- Keep RTP frame timing consistent (≈20 ms typical).
- Tune energy threshold based on real PSTN noise.
- Use consecutive-frame detection to avoid false triggers.
- Ensure outbound RTP queues fully clear on interruption.
These controls allow VoiceBridge to operate reliably in real call-center telecom environments.
Conclusion
Full-duplex AI voice is impossible without true barge-in. VoiceBridge delivers this by combining:
- Realtime RTP speech detection
- Instant outbound audio cancellation
- Realtime AI truncation control
- Stable duplex media flow inside Asterisk
This is one of the core innovations that enables human-like AI phone conversations on open-source Asterisk infrastructure.
Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.
Comments (0)
Be the first to comment.