a
hello
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! How can I help you today? I'm here to make sure you get the support you need.
a
where to use this formula total_latency = eou.end_of_utterance_delay + llm.ttft + tts.ttfb in agent.py code
t
I'm glad you asked about the formula
total_latency = eou.end_of_utterance_delay + llm.ttft + tts.ttfb
! This is a great way to capture the end-to-end latency in a LiveKit agent conversation by combining the delays from end-of-utterance detection, LLM response, and TTS generation. Let me walk you through how you can implement this in your
agent.py
code: 1. First, keep track of the metrics for each part:
eou.end_of_utterance_delay
,
llm.ttft
, and
tts.ttfb
. 2. Make sure to store these metrics with a unique identifier like
speech_id
so you can easily correlate them. 3. Once you have all the metrics, calculate the total latency using the formula. 4. If you want, you can also log this latency or send it to a monitoring system to keep an eye on performance. If you'd like, I’d be happy to provide a detailed code example or help clarify any part of this process. Just let me know! Sources: How can I reduce latency in voice agents using STT, TTS and LLM? | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik... | tests/test_agent_session.py | metrics/send-metrics-to-3p/send_metrics_to_3p.py