i wanted to implement a custom word based interrup...
# ask-ai
p
i wanted to implement a custom word based interruption in voice agent while the agent is speaking.
t
Thanks for reaching out, Adarsh. 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 add custom word-based interruption to your voice agent using LiveKit's real-time transcription. Here's a simple way to approach it: • Real-Time Transcription: You can use the
stt_node
method to get both partial and final transcription events as they happen. • Keyword Detection: Keep an eye on the transcription stream for specific trigger words like "stop" or "wait." • Interrupt Agent: Once a trigger word is spotted, you can programmatically call
session.interrupt()
to pause the agent. If you'd like, I’d be happy to walk you through some detailed code examples or help you further with this setup. Just let me know! Sources: docs/index.yaml | Docs::Agents | livekit-agents/livekit/agents/voice/agent_activity.py
p
but dude lets say the agent was speaking and i say hello, even though i can detect this word in stt node, but the vad would stop agent's response since i have spoken
t
I understand how it can be a bit frustrating when VAD stops the agent's response as soon as the user starts speaking. To help with this, you can set up the agent to avoid interruptions during its speech. Here are some friendly options you might consider: • Disable Interruptions: You can set
allow_interruptions=False
either when creating the agent or during specific
say
operations. This way, the agent's response will continue smoothly without being cut off by user speech. • Threshold Parameters: Another approach is to use
min_interruption_duration
and
min_interruption_words
to ignore brief or accidental interruptions. • Manual Control: If you want more precise handling, you can manage interruptions yourself using
session.interrupt()
. If you'd like, I’d be happy to share some detailed examples for any of these methods to help you get started. Just let me know! Sources: basics/uninterruptable/README.md | livekit-agents/livekit/agents/voice/agent_activity.py | VoicePipelineAgent | LiveKit Docs | agents/src/voice/agent_activity.ts | Improving voice AI's turn detection with transformers
p
i guess you didnt understood the problem, agents is peaking and user then starts speaking continously, so what happens now is that the user is also speaking and agent is also speaking. either the human takes a little pause which is equal to vad min silence duration, and the agent stops, is it default or expected way or i am wrong here ? what setting to tweak or how much value . also are these related > or useful ? •
false_interruption_timeout
: This sets how many seconds the agent waits before deciding an interruption was false. For instance, if you set it to
1.0
, the agent will wait 1 second before resuming speech if it doesn’t detect any user input. •
resume_false_interruption
: This controls whether the agent should continue speaking after a false interruption. Just set it to
True
to have the agent pick up where it left off.
t
I understand how it can be a bit tricky when both the agent and user speak at the same time. LiveKit handles this with an interruption mechanism to keep the conversation smooth. If the user keeps speaking, the agent pauses, and then the system checks if the interruption was genuine or just a brief overlap. Here are some settings that control this behavior: • False Interruption Timeout: This is the time (in seconds) the agent waits to see if the user is still speaking before deciding the interruption wasn’t real. The default is
2.0
, but you can set it lower, like
1.0
, if you want the agent to resume faster. • Resume False Interruption: When this is set to
True
(which it is by default), the agent will pick up speaking again if no user input is detected during the timeout. To adjust these settings, you can use:
Copy code
session = AgentSession(
    false_interruption_timeout=1.0,  # Adjust timeout duration
    resume_false_interruption=True  # Enable resumption after false interruptions
)
If you’d like, I’m here to help you with these configurations or provide more details. Just let me know! Sources: Turn detection and interruptions | LiveKit Docs | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | tests/test_agent_session.py
p
explain workflow in exampler fashoion scenario, step by step how this setting works and what about my usecase ? False Interruption Timeout
t
Let me walk you through a simple example of how the False Interruption Timeout setting works in a situation, so it’s easier to understand: 1. Agent Starts Speaking: The agent begins delivering its response (like saying, "The weather today is sunny..."). 2. User Interrupts: The user starts talking (for example, saying "Hello"), and the agent pauses right away. 3. False Interruption Timer Starts: At this point, the system starts a timer based on the
false_interruption_timeout
value (say, 1 second). 4. System Monitors User Input: During this timeout, the system listens carefully for any valid user input (like transcribed words). 5. Two Possible Outcomes: ◦ Valid Interruption: If the user keeps speaking and the system detects valid input (for example, "Hello, can you hear me?"), the agent will stop its response completely. ◦ False Interruption: If no valid input is detected within that timeout (maybe the user just says "Hello" and then stops), the system treats it as a false interruption. 1. Agent Resumes: When the interruption is considered false, the agent picks up right where it left off (like continuing with "...with a high of 25 degrees"). So, in your case, if the user keeps talking, the interruption counts as valid and the agent stops. But if the user pauses briefly—less than the `false_interruption_timeout`—the agent will continue responding. You can tweak that timeout value (like setting it to 1 second) to make this behavior fit your needs perfectly. If you’d like, I’m here to help with more details or examples—just let me know!
p
no, but in my case the agent is not stopping if user speaks continously
t
I understand how important it is for the agent to stop promptly when the user speaks continuously. This usually relates to how interruption thresholds and false interruption handling are set up. Let me guide you through some steps to help you fix this: 1. Interruption Thresholds: Check the settings for
min_interruption_duration
(default 0.5 seconds) and
min_interruption_words
(default 0). To make the agent respond more quickly, try setting
min_interruption_duration=0.1
and
min_interruption_words=0
. 2. False Interruption Handling: If
false_interruption_timeout
is enabled (default 2.0 seconds), the agent might start speaking again if it doesn’t detect valid user input. You can set
false_interruption_timeout=None
to turn off this behavior and ensure the agent stops fully. 3. Allow Interruptions: Please double-check that
allow_interruptions=True
is enabled in your session configuration. Here’s an example configuration you can try:
Copy code
session = AgentSession(
    min_interruption_duration=0.1,  # Detect short user speech
    min_interruption_words=0,       # No word count required
    false_interruption_timeout=None, # Disable false interruption recovery
    resume_false_interruption=False, # Prevent resuming after interruption
    allow_interruptions=True         # Enable interruptions
)
If you’d like, I’m here to help you implement or test these settings step-by-step. Just let me know! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | complex-agents/turn-taking/README.md | Turn detection and interruptions | LiveKit Docs
p
what happens if min_interruption_words=0 set to 0 and 1 ?
t
The
min_interruption_words
setting helps decide the minimum number of words needed to recognize user speech as a valid interruption. Let me walk you through how it works with different values: • min_interruption_words=0: This means any detected speech, even a single sound or partial word, can trigger an interruption. It’s great for systems that need to be super responsive, but just a heads-up—it might sometimes pick up background noise or accidental sounds. • min_interruption_words=1: Here, at least one complete word has to be transcribed for the interruption to count. This helps reduce interruptions caused by noise or incomplete speech, though it might cause a tiny delay before the interruption happens. If you’d like me to explain anything further or help you set this up, please don’t hesitate to ask—I’m here to help!
p
is my issue correct or not just tell that, and explain what you understood from it "guess you didnt understood the problem, agents is peaking and user then starts speaking continously, so what happens now is that the user is also speaking and agent is also speaking. either the human takes a little pause which is equal to vad min silence duration, and the agent stops,"
t
Thank you for sharing your concern—I completely understand where you're coming from. From what you've described, it seems that when the agent is speaking and the user starts talking continuously, both end up speaking at the same time. The agent doesn’t stop right away; instead, they pause only if the user takes a short break that meets the VAD's minimum silence duration. This is actually how LiveKit's interruption feature is designed to work by default, using settings like
min_interruption_duration
and
min_interruption_words
to recognize valid interruptions. Please feel free to let me know if this matches what you've noticed or if you'd like me to explain anything further—I’m here to help!
p
what i am asking is interruption is also dependednt on vad min_silence_duration ?
t
Thanks for reaching out! I’d love to help clarify this for you. The interruption in LiveKit is actually not dependent on the VAD
min_silence_duration
. These two work independently: • VAD min_silence_duration: This setting helps determine when speech has ended by measuring how long the silence lasts. It’s used to trigger an END_OF_SPEECH event after a certain silent period. • Interruption Mechanism: Interruptions happen when new speech is detected, based on things like
min_interruption_duration
(the minimum length of speech) and
min_interruption_words
(the minimum number of words). So, to sum it up: interruptions are all about spotting new speech, while
min_silence_duration
focuses on recognizing when someone has stopped talking. If you’d like me to explain anything further or have more questions, just let me know—I’m here to help! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Turn detection and interruptions | LiveKit Docs