Hey, I’ve got a Python agent deployed with a React...
# agents
p
Hey, I’ve got a Python agent deployed with a React Native client acting as a voice assistant in our app. I’m running into an issue with session handling: When the user taps the “mute mic” button on the client, I want the agent’s speech to stop immediately. But right now, it keeps talking until it finishes its response. Does anyone know if this can be handled on the backend, or is there a way to manage it on the frontend without muting the device speakers (since other services may still need audio)?
d
It looks like you would use the
interrupt()
method for this. Then you could tie it to your front end mute button with a RPC. Not exactly sure how your app is setup, but the microphone mute is typically meant for the user's local input device. You may be better off adding an additional agent mute/interrupt button. Then you could manage states separately in case the user ever did want to mute themselves, but let the agent finish speaking. Good luck!
Copy code
handle = session.say("Hello world")
handle.interrupt()

# or from the session
session.interrupt()
https://docs.livekit.io/agents/build/audio/#interruptions
p
got it, thanks