how can I cancel all ongoing speech on an agent (e...
# ask-ai
w
how can I cancel all ongoing speech on an agent (even if that speech is uninterruptible)
t
Thanks for reaching out, Drew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you with cancelling ongoing speech on a LiveKit VoicePipelineAgent! You can easily stop all speech, even if it's marked as uninterruptible, by using the
agent.interrupt()
method along with the
interrupt_all=True
parameter. Here’s a quick rundown of how it works: • The
agent.interrupt()
method will immediately stop any speech the agent is currently making. • By adding
interrupt_all=True
, it also halts any speech that’s waiting in the pipeline. • Importantly, this method works no matter the
allow_interruptions
setting, so it can interrupt speech that would normally be uninterruptible. Here’s an example in Python to guide you:
Copy code
# Interrupt current and all pending speech
agent.interrupt(interrupt_all=True)
Just a quick note: this feature is currently available only in the Python SDK. If you’re working with another language, I recommend checking the latest documentation or exploring similar session control options that might help achieve the same result. Sources: VoicePipelineAgent | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | Agent speech and audio | LiveKit Docs