happy-mouse-590
07/29/2025, 8:53 PMtall-airline-16756
07/29/2025, 8:53 PMtall-airline-16756
07/29/2025, 8:53 PMmetrics_collected event in LiveKit triggers whenever there is a new metrics object available during an active session. This event is fired by various components within the LiveKit Agents framework, including:
• Speech-to-Text (STT)
• Large Language Models (LLM)
• Text-to-Speech (TTS)
• Voice Activity Detection (VAD)
• Voice Pipeline Agent (VPA)
The event carries metrics of various types, such as STTMetrics, LLMMetrics, TTSMetrics, VADMetrics, and EOUMetrics. To capture these events, you can subscribe to them on the `AgentSession`:
@session.on("metrics_collected")
def _on_metrics_collected(ev: MetricsCollectedEvent):
metrics.log_metrics(ev.metrics)
This provides detailed insights into duration, latency, and usage across different stages of the agent's operation.
Sources: Events and error handling | LiveKit Docs | SpeechEventType | LiveKit Agents | LLMEvent | LiveKit Agents | TTSEvent | LiveKit Agents | VADEventType | LiveKit Agents