When should a voice agent stop speaking?
A good voice agent should stop talking the moment you interrupt it. A poor agent, however, will continue reciting its sentence—as if you weren't even there—even while you’re saying, "No, stop!" To make matters worse, it might even repeat the very sentence you just interrupted. Unfortunately, we encountered such scenarios ourselves at one point.
Words are too slow.
Our initial hypothesis was that the agent should stop once the caller has spoken three meaningful words. In theory, this sounded quite sound; in practice, however, it took 1.6 seconds for an agitated caller to get the agent to stop talking—simply because it took time for those three words to be spoken and subsequently transcribed.
We then revised our hypothesis, lowering the threshold to two words. When that still proved insufficient, we updated it to: "500 ms of continuous audio plus at least one transcribed word." This was an improvement, but it still felt sluggish.
Stopping based solely on audio detection is highly risky.
The next logical step we considered was to stop the agent the instant any sound was detected, without waiting for transcription. The problem here, of course, was echo. On a telephone line, an agent often hears a portion of its own output; if the agent were configured to stop whenever sound is detected, it could end up interrupting itself.
At that stage, we had not yet integrated a full-scale Acoustic Echo Cancellation (AEC) system (solutions like speexdsp or WebRTC require a cgo dependency). Instead, we implemented a simpler filter prior to the speech-to-text (STT) stage: the audio from both sides is downsampled to 4 kHz (similar to standard telephone lines), the agent’s audio from the last X milliseconds is buffered, and a normalized cross-correlation is calculated. An audio frame from the caller is muted only if two consecutive frames are found that match the agent’s audio with approximately the same delay. While this is not a true acoustic echo cancellation (AEC) system, it successfully filtered out over 95% of echo frames with delays ranging from 40 to 300 milliseconds during testing. Furthermore, since it does not interfere with instances where both audio streams overlap, it can accurately detect moments when a user genuinely interrupts the conversation.
Our current rule
In addition, we monitor the volume level of each caller during the conversation. The agent stops speaking if it detects audio from the caller that reaches ≥ X% of their learned volume level and persists for Y milliseconds—unless:
- The transcription matches what the agent is currently saying (i.e., it is an "echo"), or
- The input consists of "backchannel" responses—such as "uh-huh," "yes," or "okay." People frequently use such expressions while listening; these signify "continue" rather than "stop."
The initial greeting, which includes a notification that the call is being recorded, is never subject to interruption. As a result of the test calls, we observed that the time elapsed from the caller’s first sound to the agent falling silent decreased from approximately 1500 ms to 200–300 ms. That was when we realized we had found the right solution.