vad.on('speech', () => {
console.log('user started talking');
});vad.on('speech', () => {
player.stop();
player.clearQueue();
generation.abort();
history.trimLastReply(player.playedText());
});On user speech the agent stops audio, cancels generation and keeps only the part of the reply the user heard.
Enable echo cancellation, so the agent's own voice from the speakers is not detected as user speech, and require a minimum speech length before barge-in.
No. Short sounds like 'mm-hm' or coughs often should not stop it. Use a minimum speech duration or check the words before stopping playback.
The full generated reply was saved to history even though playback was cut off. Trim the stored reply to the text that was actually played.