proud-lawyer-39815
09/22/2025, 7:24 PMtall-airline-16756
09/22/2025, 7:24 PMtall-airline-16756
09/22/2025, 7:25 PMwait_for_playout() method from the LiveKit Agents SDK. This way, you can be confident that the entire speech has played before moving on.
Here's a friendly example in Python:
speech_handle = session.say("Hello, how can I help?")
await speech_handle.wait_for_playout()
session.input.set_audio_enabled(False)
And if you're working with TypeScript/Node.js, it looks like this:
const speechHandle = session.say("Hello, how can I help?");
await speechHandle.waitForPlayout();
session.input.setAudioEnabled(false);
Another approach you might find helpful is listening for agent state changes, like when the state switches from "speaking" to "listening," to know exactly when the speech has finished. If you'd like, I’m here to walk you through that or help with anything else!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | agents/src/voice/audio_recognition.ts | How does end-of-utterance detection work in conversations?