I do not allow users to interrupt agent speech in ...
# ask-ai
i
I do not allow users to interrupt agent speech in my realtime multimodal agent. Is there a way to allow only specific phrases to interrupt speech?
t
Thanks for reaching out, Matthew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! LiveKit doesn’t have a built-in feature to allow interruptions only for specific phrases, but no worries—you can totally set this up yourself by listening to transcription events and checking if the transcript matches the phrases you want to allow. When it does, you just call
session.interrupt()
to pause the agent. Here’s a simple example to get you started:
Copy code
@session.on("user_input_transcribed")
def on_transcript(transcript: UserInputTranscribedEvent):
    if transcript.is_final and transcript.transcript.strip().lower() in ["stop", "pause", "help"]:
        session.interrupt()
This way, you have full control over which phrases can interrupt the agent. If you want me to help you with a more detailed setup or anything else, just let me know—I’m here for you! Sources: Agent speech and audio | LiveKit Docs | Turn detection and interruptions | LiveKit Docs
i
If I do not allow interruptions, does it still transcribe user speech?