is there a way to access interruption events? e.g...
# ask-ai
b
is there a way to access interruption events? e.g., timestamps when exactly the speech of assistant or user was interrupted?
t
Thanks for reaching out, mateuszkasprowicz. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're exploring how to access interruption events and their timestamps in LiveKit! You can do this using several helpful event listeners and fields: • Event Timestamps: Events such as
UserStateChangedEvent
and
AgentStateChangedEvent
come with a
created_at
timestamp, which tells you exactly when speech or state changes happen. • Interruption Indicators: The
PlaybackFinishedEvent
includes an
interrupted
field and a
playback_position
timestamp, so you can see precisely when playback was interrupted. • Speech Handle: The
SpeechHandle.interrupted
property helps you know if a specific speech was interrupted. • False Interruptions: The
AgentFalseInterruptionEvent
provides useful details like
resumed
and
created_at
to track false interruptions. These tools are designed to help you monitor and log interruptions smoothly. If you'd like, I’m here to guide you through implementing any of these—just let me know! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Events and error handling | LiveKit docs | agents/src/voice/agent_activity.ts | Turn detection and interruptions | LiveKit Docs
b
let's assume I'm using Silero VAD, EnglishModel tunr detection and separate STT I'm interested in cases when a user made a long pause, turn was marked as completed, assistant started speaking, and user interrupted - what's the best way to get the exact timestamp of the interruption?
t
To help you get the exact timestamp of a user interruption when using Silero VAD, EnglishModel turn detection, and separate STT, here’s a simple step-by-step guide: 1. Listen for VAD Events: You can use the
on_vad_inference_done
method to catch VAD events. The
speech_duration
and
silence_duration
fields are really useful to figure out the interruption timestamp. 2. Calculate Interruption Timestamp: Just apply this formula:
interruption_timestamp = current_time - silence_duration
. This will help you pinpoint when the user started speaking. 3. STT Verification (Optional): If you have it set up, double-check that the transcript has a minimum word count before confirming the interruption. This adds an extra layer of accuracy. 4. Event Listeners: Keep an eye on
UserStateChangedEvent
or
AgentStateChangedEvent
to know exactly when the assistant starts speaking and when the user interrupts. If you’d like, I’m here to help you implement this or clarify anything further. Just let me know! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | examples/src/realtime_turn_detector.ts | Turn detection and interruptions | LiveKit Docs