important-judge-78504
09/16/2025, 3:43 PMtall-airline-16756
09/16/2025, 3:43 PMtall-airline-16756
09/16/2025, 3:44 PMstart_time and end_time in their transcription results. These timestamps usually come in seconds and mark the beginning and end of the recognized speech segment.
• Python SDK: If you're working with the Python SDK, you can turn on use_tts_aligned_transcript=True in the AgentSession. Doing this lets the transcription iterator provide TimedString objects that include start_time and end_time in seconds, relative to the agent's current turn. Just a heads-up, this feature is still experimental.
• Protocol or Client SDK Models: The LiveKit protocol and client SDKs (like Swift or Flutter) offer fields such as startTimestampMs and endTimestampMs within transcription-related structures, which capture timing in milliseconds.
• Voice Activity Detection (VAD): Another approach is to track the internal state when VAD detects speech presence or absence, helping you infer when user speech starts and ends.
For the most consistent and reliable timing, I’d recommend using STT plugins since they provide timing metadata directly. If you'd like, I’m here to walk you through implementing any of these methods or answer any questions you have!
Sources: Sources/LiveKit/Protos/livekit_models.pb.swift | livekit-plugins/livekit-plugins-google/livekit/plugins/google/stt.py | Text and transcriptions | LiveKit Docs | Text and transcriptions | LiveKit Docs | livekit/livekit_models.pb.goimportant-judge-78504
09/16/2025, 3:45 PMtall-airline-16756
09/16/2025, 3:46 PMpip install "livekit-agents[deepgram]~=1.2". Make sure you have your Deepgram API key ready, either set as an environment variable or passed directly when initializing.
2. Initialize Deepgram STT: Next, create an instance of the Deepgram STT with your preferred settings, like endpointing_ms which helps define the silence duration for speech endpointing:
from livekit.plugins import deepgram
stt = deepgram.STT(
model="nova-3",
language="en-US",
endpointing_ms=25
)
3. Retrieve Timestamps: You can then access the start_time and end_time from Deepgram's transcription results. Here's a simple example in Python:
def live_transcription_to_speech_data(language: str, data: dict, *, is_final: bool):
dg_alts = data["channel"]["alternatives"]
for alt in dg_alts:
start_time = alt["words"][0]["start"] if alt["words"] else 0
end_time = alt["words"][-1]["end"] if alt["words"] else 0
print(f"Start: {start_time}, End: {end_time}")
4. Integrate with AgentSession: Use your STT instance within the AgentSession to manage user turn detection and transcription events smoothly:
from livekit.agents import AgentSession
session = AgentSession(stt=stt)
5. Subscribe to Events: Finally, listen for transcription events like user_input_transcribed to get timing metadata easily:
@session.on("user_input_transcribed")
def on_transcript(event):
for alt in event.alternatives:
print(f"Start: {alt.start_time}, End: {alt.end_time}, Text: {alt.text}")
If you have any questions or need a hand with the setup or configuration, please don't hesitate to reach out. I'm here to help!
Sources: plugins/deepgram/src/stt.ts | Speech-to-text (STT) integrations | LiveKit Docs | Deepgram STT integration guide | LiveKit Docs | Deepgram STT integration guide | LiveKit Docs | livekit-agents/livekit/agents/voice/audio_recognition.py