in livekit 1.x version how to know if the user int...
# ask-ai
b
in livekit 1.x version how to know if the user interrupted the agent
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! When working with LiveKit 1.x, you have several ways to detect if a user has interrupted an agent. Here are some helpful methods you can use: • The
interrupted
flag in the
ChatMessage
object, which gets set whenever an interruption happens. • The
agent_speech_interrupted
event, which is triggered when the agent is interrupted while speaking. • The
agent_state_changed
event, where the state changes from "speaking" to "listening" once an interruption occurs. • The
PlaybackFinishedEvent
, where the
interrupted
field will be
True
if the playback was interrupted. On top of that, you can customize how interruptions behave by adjusting the
AgentSession
parameters to fit your needs: • allow_interruptions: Set this to
False
if you want to disable interruptions (by default, it’s
True
). • min_interruption_duration: This sets the minimum speech duration in seconds required to trigger an interruption (default is 0.5 seconds). • min_interruption_words: This defines the minimum number of transcribed words needed to consider it an interruption (default is 0). And if you want to take manual control, you can always call the
session.interrupt()
method to immediately stop any ongoing or queued speech. Sources: livekit-agents/livekit/agents/voice/agent_session.py | Turn detection and interruptions | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | VoicePipelineAgent | LiveKit Docs
b
PlaybackFinishedEvent how to get this event? give code example also will theinterrupt field be there if it is user speaking and agent interrupted?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!