How can I play an audio file during a function cal...
# ask-ai
a
How can I play an audio file during a function call
t
Thanks for reaching out, Anthony. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd be happy to help you play an audio file during a function call in LiveKit! You have a couple of great options to choose from: • Using
session.say()
with Pre-Synthesized Audio:
This approach lets you load a pre-recorded audio file (like a
.wav
), convert it into an
rtc.AudioFrame
, and stream it using an async generator. It’s perfect for playing short audio clips during agent responses. • Using `BackgroundAudioPlayer.play()`: This option is fantastic for playing audio clips on demand, with features like looping and managing multiple audio sources. It works well for background ambience or sound effects and supports formats such as
.wav
and
.ogg
. If you'd like, I can provide detailed examples or guide you through the implementation—just let me know how I can assist you further! Sources: tests/test_agent_session.py | Agent speech and audio | LiveKit Docs | examples/play_audio_stream.py | Docs::Agents | docs/index.yaml
a
What are the automatic thinking sounds
t
Hi there! I’d love to help you understand the automatic "thinking" sounds in LiveKit. These are gentle audio cues that play while an AI agent is processing, letting you know it’s actively working on a response. They’re brought to life using the
BackgroundAudioPlayer
class and include some handy built-in options like: • KEYBOARD_TYPING: This one mimics the sound of typing (file:
keyboard-typing.ogg
). • KEYBOARD_TYPING2: A slightly different typing sound variation (file:
keyboard-typing2.ogg
). You can easily configure these sounds using the
BuiltinAudioClip
enum and sync them with the agent’s lifecycle. If you’d like, I’m here to walk you through the setup or chat about any specific needs you have—just let me know! Sources: Docs::Agents | External data and RAG | LiveKit Docs | Agent speech and audio | LiveKit Docs | Agent speech and audio | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py