How to avoid Agent speech while a function/tool ca...
# ask-ai
l
How to avoid Agent speech while a function/tool call is in process. Reason I am asking is because the function/tool call can also result in agent speaking, which can interfere
t
Thanks for reaching out, Deepak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To keep the agent from talking while a function or tool is running, here are some handy tips you can try: • Use Background Audio: Swap out the agent’s speech with background sounds (like “thinking” noises) while the tool is working. It’s a great way to show something’s happening without any speech getting in the way. • Control Interruptions: You can use
RunContext.disallow_interruptions()
to make sure nothing interrupts those important operations. • Wait for Speech Completion: Try
RunContext.wait_for_playout()
so the agent finishes talking before the tool kicks in. • Automatic State Management: The system’s pretty smart—it switches the agent’s state to “thinking” automatically during tool execution to keep things smooth. • Control Speech Scheduling: You can tweak the
tool_choice
parameter to turn off speech when the tool responds. Using background audio is especially great for keeping users engaged without overlapping speech. If you want, I’m happy to share more details or examples to help you get this set up! Sources: examples/voice_agents/silent_function_call.py | External data and RAG | LiveKit Docs
l
Can I filter out a Agent's speech?
t
Hey there! You’ve got a few neat ways to filter out an agent's speech, and I’d love to walk you through them: • Disable Agent Audio Output: You can use
RoomOutputOptions(audio_enabled=False)
to stop the agent from producing any audio, but it’ll still listen and accept speech input. • Filter Content Before TTS: Try using a
before_tts_cb
callback to catch and tweak the agent’s text before it gets sent to the TTS engine. • Content Filtering in LLM Pipeline: You could override the
llm_node
method in your agent to dynamically filter out specific content. • Fixed Participant Processing: By setting a fixed participant identity, the agent will only process audio from certain participants—this way, it won’t pick up its own audio. • External STT Provider: If you’re using Speechmatics STT, you can configure it to ignore certain speakers (like the agent) with
ignore_speakers
or
focus_speakers
. If you want, I’m happy to share more details or examples for any of these—just let me know! Sources: How to Set Up Speech-to-Text Input with Text-Only Output in LiveKit Agents | chain-of-thought-tts/README.mdoc | pipeline-llm/llm_powered_content_filter.py | How to set a fixed participant for agent audio processing | livekit-agents/livekit/agents/voice/agent_activity.py