How to track latency? STT-LLM-TTS?
# ask-ai
a
How to track latency? STT-LLM-TTS?
t
Thanks for reaching out, Gamal. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It sounds like you want to measure latency across your STT → LLM → TTS pipeline. Here’s the quickest way to track it end-to-end: • Collect metrics per stage: ◦ STT:
STTMetrics
(e.g.,
audio_duration
,
duration
,
streamed
) ◦ LLM:
LLMMetrics
(
ttft
,
duration
, token counts) ◦ TTS:
TTSMetrics
(
ttfb
,
duration
,
audio_duration
) ◦ Turn timing:
EOUMetrics
(
end_of_utterance_delay
,
transcription_delay
,
on_user_turn_completed_delay
) ◦ Docs: Logs, metrics, and telemetry • Correlate by turn: ◦ Use the shared
speech_id
in LLM/TTS/EOU metrics to stitch STT → LLM → TTS for each user turn. • Subscribe and emit: ◦ Enable AgentSession metrics and subscribe to the
metrics_collected
event to receive these records from your agent runtime. Agent session integration • Trace end-to-end: ◦ Enable OpenTelemetry tracing to capture timing across nodes (session start → STT → LLM → TTS). Metrics & telemetry • What to watch (targets): ◦ TTFT (LLM): < 300 ms ◦ TTFB (TTS): < 200 ms ◦ End-to-end (speech end → agent speech start): < 1000 ms ◦ Latency tips: deploy agents close to your STT/LLM/TTS providers. Operational guidance Would you like example code to subscribe to
metrics_collected
and compute end-to-end latency per
speech_id
? Sources: Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | Logs, metrics, and telemetry | LiveKit Docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | Community & Support | livekit/livekit_composite | DeepWiki