Is there a built-in way to scope BackgroundAudioPl...
# ask-ai
b
Is there a built-in way to scope BackgroundAudioPlayer.thinking_sound to only fire during tool calls instead of every LLM turn? Currently it triggers on every agent_state == "thinking" transition which makes the typing sound play between every turn of conversation. The docs imply it's tied to tool calls but in practice it's tied to the broader thinking state. Would love either a min_duration_ms threshold parameter or a way to scope it to function execution only.
✅ 1
t
Thanks for reaching out, Randy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I looked into the BackgroundAudioPlayer behavior you described. Short answer: There is no built-in way to scope
BackgroundAudioPlayer.thinking_sound
to only tool/function calls or to set a
min_duration_ms
.
thinking_sound
fires whenever the agent enters the "thinking" state (which happens for any LLM turn, not just tool execution). Workarounds you can use: • Remove
thinking_sound
from the automatic BackgroundAudioPlayer config and play audio manually inside your tool functions using
background_audio.play()
(or
context.session.say()
if you prefer TTS). This ensures the typing/hold sound only runs during actual tool execution. • Pre-synthesize and cache any audio clips to avoid TTS latency when playing them during tool calls. • If needed, use
context.disallow_interruptions()
while playing a tool-specific audio cue to prevent premature interruption. If you want, tell me which SDK/language you’re using and I’ll give a short code example for playing the audio only inside tool execution. Sources: Background audio | LiveKit Documentation | Turns overview | LiveKit Documentation | External data and RAG | LiveKit Documentation | Function tool definition | LiveKit Documentation | Audio customization | LiveKit Documentation, with interactive elements