How to wait for a user reply after generate_reply(...
# ask-ai
l
How to wait for a user reply after generate_reply()?
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to wait for a user reply after calling
generate_reply()
. Use the
SpeechHandle
returned by
generate_reply()
— await it to wait for playback to finish and the agent to start listening for user input. Example:
Copy code
handle = session.generate_reply(instructions="How can I help you today?")
await handle         # waits for speech playback to complete and agent readiness

# agent is now listening for user input; proceed to handle incoming user reply
If you only need to wait for playout without blocking other work:
Copy code
handle = session.generate_reply(instructions="How can I help you today?")
# do other tasks...
await handle.wait_for_playout()  # ensures speech finishes
The agent begins listening for user input automatically after speaking. Sources: Agent speech and audio | LiveKit docs