How do I get a start time and a end time in the tr...
# ask-ai
a
How do I get a start time and a end time in the transcription segment when using openai realtime? I see them as properties in TranscriptionSegment but pretty sure they are omitted when using realtime model? Any ideas?
✅ 1
t
Thanks for reaching out, Malte. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about getting start/end timestamps for transcription segments when using the OpenAI realtime model. Start and end times are available, but only when you enable TTS-aligned transcription and handle timed transcript objects. To get timestamps: • Enable TTS-aligned transcripts for the agent session (set
use_tts_aligned_transcript=True
). • Implement a
transcription_node
that accepts
TimedString
(or iterables of
TimedString
) and reads
start_time
and
end_time
(seconds relative to the agent turn). Example:
Copy code
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}', Start: {chunk.start_time}, End: {chunk.end_time}")
        yield chunk
Note:
TimedString
/ TTS-aligned transcription is experimental and requires the aligned-transcript feature to be enabled; without that, segments may not include timestamps. If you want, tell me how you’re creating your AgentSession and I’ll show where to set
use_tts_aligned_transcript
or review your transcription_node code. Sources: Text and transcriptions | LiveKit Documentation, with interactive elements