faint-arm-51818
09/30/2025, 3:17 PMtall-airline-16756
09/30/2025, 3:17 PMtall-airline-16756
09/30/2025, 3:18 PMsession.say, and session.generate_reply! Here’s a friendly guide to get you started with the right event listeners:
• Tracking Function Calls: You can keep an eye on function tools being executed by using the function_tools_executed event. It gives you useful details about the function calls and their results.
• Tracking session.say and `session.generate_reply`: The speech_created event is your go-to here. It provides a SpeechHandle object to help you monitor speech playout, and the source property tells you whether the speech came from say, generate_reply, or tool_response.
• Accessing Current Speech: If you’re working in Python, you can easily access the active speech handle with session.current_speech and sync up with whatever speech is playing at the moment.
If you’d like, I can also share some specific code examples or dive deeper into any part—just let me know! I’m here to help.
Sources: Agent speech and audio | LiveKit Docs | Events and error handling | LiveKit Docs | Events and error handling | LiveKit Docs | Docs::Agentsfaint-arm-51818
10/02/2025, 10:28 AMtall-airline-16756
10/02/2025, 10:29 AMspeech_created event, here’s a simple approach you can try:
Python Example:
@session.on("speech_created")
async def on_speech_created(event):
print(f"Speech created - Source: {event.source}, User initiated: {event.user_initiated}")
# Access the speech handle to monitor playout
handle = event.speech_handle
# Wait for the speech to finish playing
await handle.wait_for_playout()
print("Speech playout completed.")
To get the actual speech transcript, you can link this with the conversation_item_added event, which includes the agent's spoken text:
Python Example:
@session.on("conversation_item_added")
def on_conversation_item_added(event):
item = event.item
if item.role == "assistant":
print(f"Assistant said: {item.content}")
This way, you can keep an eye on the speech playout and capture what’s being said. If you’d like me to walk you through this further or provide more examples, please don’t hesitate to ask—I’m here to help!
Sources: Events and error handling | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | Events and error handling | LiveKit Docs | Agent speech and audio | LiveKit Docs