clever-doctor-15083
11/08/2025, 3:05 AMtall-airline-16756
11/08/2025, 3:05 AMtall-airline-16756
11/08/2025, 3:06 AMtranscription_enabled=True in RoomOutputOptions when you start the session.
2. Next, listen for the conversation_item_added event to capture the real-time transcripts. To focus specifically on the agent’s speech, filter for role == "assistant".
3. You can then access the real-time transcription data through the transcription_node or llm_node for immediate processing.
4. Finally, save the complete transcript by using session.history or add a shutdown callback to store the data when the session ends.
If you’d like, I’m here to walk you through any part of this or provide more details. Just let me know!
Sources: Understanding Transcript Timing in Voice Conversations | complex-agents/teleprompter/cartesia-ink.py | livekit-plugins/livekit-plugins-speechmatics/livekit/plugins/speechmatics/s... | Session recording and transcripts | LiveKit Docs | How to capture real-time agent transcriptions during conversationsclever-doctor-15083
11/08/2025, 3:08 AMtall-airline-16756
11/08/2025, 3:08 AMfrom livekit.agents import AgentSession, RoomOutputOptions
async def start_sip_session():
session = AgentSession()
# Store transcripts in memory
conversation_transcripts = []
# Event handler for capturing conversation items
@session.on("conversation_item_added")
def on_conversation_item(event):
if event.item.role == "assistant":
print(f"Agent said: {event.item.text_content}")
conversation_transcripts.append({
"role": event.item.role,
"text": event.item.text_content,
"timestamp": event.created_at.isoformat()
})
# Start the session with transcription enabled
await session.start(
agent=your_sip_agent,
room=your_room_context,
room_output_options=RoomOutputOptions(
transcription_enabled=True,
audio_enabled=True,
sync_transcription=True
)
)
# Save the transcript when the session ends
def save_transcript():
with open("sip_transcript.json", "w") as f:
json.dump(conversation_transcripts, f, indent=2)
session.add_shutdown_callback(save_transcript)
# Call the function to start the session
# asyncio.run(start_sip_session())
This snippet sets up transcription, listens for conversation events, and saves everything neatly into a JSON file once the session wraps up. If anything feels unclear or you'd like me to walk you through more examples, just let me know—I'm here to help!clever-doctor-15083
11/08/2025, 3:30 AMtall-airline-16756
11/08/2025, 3:30 AMsession.history property to get the entire conversation history, which includes all transcribed user inputs and agent responses. It’s a great idea to save this history when the session ends by using a shutdown callback.
2. Real-Time Event Listening: By listening to the conversation_item_added event, you’ll be able to capture new conversation items as they come in — both user and agent messages.
3. Text Streams: Another approach is to register a handler for the lk.transcription text stream topic, which lets you receive real-time transcriptions from participants.
4. Frontend Integration: If you’re working with LiveKit’s React components, the useTranscriptions() and useChat() hooks are super helpful to merge real-time transcriptions with chat messages seamlessly.
Here’s a simple Python code snippet to get you started with capturing the full conversation history:
from livekit.agents import AgentSession
async def capture_transcripts():
session = AgentSession()
# Start the session with transcription enabled
await session.start(
agent=your_agent,
room=your_room_context,
room_output_options=RoomOutputOptions(
transcription_enabled=True
)
)
# Save the full conversation history when the session ends
def save_transcript():
with open("conversation_history.json", "w") as f:
json.dump(session.history, f, indent=2)
session.add_shutdown_callback(save_transcript)
If you have any questions or want me to walk you through additional examples, please don’t hesitate to ask — I’m here to help!
Sources: Text and transcriptions | LiveKit docs | Session recording and transcripts | LiveKit Docs | Session recording and transcripts | LiveKit docs | complex-agents/note-taking-assistant/README.md | examples/other/translation/multi-user-translator.pyclever-doctor-15083
11/08/2025, 3:48 PMtall-airline-16756
11/08/2025, 3:48 PM