loud-postman-20421
09/18/2025, 2:32 PMtall-airline-16756
09/18/2025, 2:32 PMtall-airline-16756
09/18/2025, 2:33 PMAgentSession.history() method doesn’t directly provide timestamps for transcript entries, but there are a few ways you can get those timestamps:
• Enable TTS-aligned transcription: By setting use_tts_aligned_transcript=True in your AgentSession configuration, you’ll receive TimedString objects that include start_time and end_time for each word or sentence. This works well with certain TTS providers like Cartesia and ElevenLabs.
• Use event-based timestamps: You can listen for events like conversation_item_added or user_input_transcribed. These events come with a created_at timestamp showing exactly when the item was added to the history.
• Manual timestamping: Another option is to add timestamps yourself using datetime.now() when you handle transcription events such as user_input_transcribed.
If you’d like, I can provide more details or examples on how to set up any of these methods—just let me know! I’m here to help you every step of the way.
Sources: Session recording and transcripts | LiveKit Docs | Text and transcriptions | LiveKit Docs | Text and transcriptions | LiveKit Docs | tests/test_agent_session.py | pipeline-stt/transcriber.pyloud-postman-20421
09/18/2025, 2:33 PMtall-airline-16756
09/18/2025, 2:33 PMAgentSession.history() method doesn’t directly give timestamps for transcript entries. But don’t worry—you can still get those timestamps by using other methods, like enabling TTS-aligned transcription, working with event-based timestamps, or even adding timestamps manually during transcription events. If you'd like, I’d be happy to walk you through how to set any of these up. Just let me know!loud-postman-20421
09/18/2025, 2:34 PMtall-airline-16756
09/18/2025, 2:35 PMuse_tts_aligned_transcript=True in your AgentSession configuration, you’ll be able to access timestamps through the transcription_node. This node works with TimedString objects, which conveniently include start_time and end_time attributes for each word or sentence.
Here’s a friendly example to help you get started:
async def transcription_node(
self, text: AsyncIterable[str | TimedString], model_settings: ModelSettings
) -> AsyncGenerator[str | TimedString, None]:
async for chunk in text:
if isinstance(chunk, TimedString):
print(f"Text: {chunk.text}, Start: {chunk.start_time}, End: {chunk.end_time}")
yield chunk
This setup will let you easily extract and use timestamps for each part of your transcript. If you have any questions or want to dive deeper into this, just let me know—I’m here to help!loud-postman-20421
09/18/2025, 2:35 PMtall-airline-16756
09/18/2025, 2:35 PMTimedString objects is designed especially for TTS (Text-to-Speech) situations. When it comes to SST (Speech-to-Text), you’d want to use event-based timestamps, like those from the user_input_transcribed event, or you can add timestamps manually during transcription events.
If you’d like, I’m here to help clarify anything or assist you further with SST-related timestamping. Just let me know!loud-postman-20421
09/18/2025, 2:49 PMtall-airline-16756
09/18/2025, 2:49 PMexclude_timestamp option! This option is available in the to_dict method of the ChatContext class, which you can access through the AgentSession.history property. It lets you exclude the created_at timestamp field when you’re serializing chat items, which can be really handy.
Here’s a simple example in Python to show you how it works:
# Access the chat context from the session and exclude timestamps
chat_dict = agent_session.history.to_dict(exclude_timestamp=True)
And if you’re working with JavaScript or TypeScript, you can use the toJSON method with the excludeTimestamp option like this:
// Access the chat context and exclude timestamps
const chatDict = agentSession.history.toJSON({ excludeTimestamp: true });
If anything is unclear or if you’d like me to walk you through it step-by-step, please don’t hesitate to ask. I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | agents/src/voice/agent_activity.ts