busy-spoon-35253
03/06/2026, 7:25 AMtall-airline-16756
03/06/2026, 7:26 AMtall-airline-16756
03/06/2026, 7:26 AMspeech_created on the AgentSession.
◦ speech_created is emitted whenever the agent generates speech (for example via session.say() or session.generate_reply()).
• To proactively trigger a response from the agent in a Realtime session, use generate_reply().
◦ generate_reply() returns a SpeechHandle you can await or attach callbacks to (for example, await handle.wait_for_playout() to know when playout finishes).
If you’d like, tell me:
• Which SDK/language you’re using (JavaScript, Python, etc.), and
• Whether you want an example that awaits playout or attaches a callback,
and I’ll provide a short code snippet you can drop into your app.
Sources: Agent speech and audio | LiveKit Documentation | Streamline troubleshooting with Agent Observabilitybusy-spoon-35253
03/06/2026, 7:26 AMtall-airline-16756
03/06/2026, 7:27 AMspeech_created event on the AgentSession — this is emitted whenever the agent generates speech (for example from session.say() or session.generate_reply()).
• Use generate_reply() to ask the agent to produce a reply; it returns a SpeechHandle you can await or attach callbacks to (e.g., wait_for_playout()).
Example (Python-style pseudocode showing the pattern):
# assume you have an AgentSession instance named `session`
# and an async event loop
# 1. Attach a handler to speech_created
def on_speech_created(speech):
# `speech` is the Speech object created by the agent
print("Agent generated speech:", speech.id)
print("Text:", getattr(speech, "text", "<no text available>"))
# You can access additional metadata on speech here if provided
session.on("speech_created", on_speech_created)
# 2. Trigger the agent to generate a reply
async def ask_agent():
# generate_reply returns a SpeechHandle
handle = await session.generate_reply(instructions="Greet the user and introduce yourself")
# wait for the speech to finish playing out
await handle.wait_for_playout()
print("Agent playout finished")
# run your ask_agent coroutine in your event loop
Notes and tips:
• The speech_created event fires as soon as the speech object is produced. Use SpeechHandle methods (like wait_for_playout()) to know when audio playout completes.
• If you prefer callbacks instead of awaiting, attach them to the SpeechHandle (for example, a completion callback) if the SDK exposes such methods.
• If you’d like, I can provide a concrete runnable snippet that matches the exact Python SDK classes/method names you’re using — tell me which LiveKit Python SDK version you have or paste the small part of your current session setup.