prehistoric-printer-73777
08/30/2025, 7:44 AMtall-airline-16756
08/30/2025, 7:44 AMtall-airline-16756
08/30/2025, 7:45 AMBackgroundAudioPlayer class, which plays hold music while the customer is being connected to another agent.
Here’s a quick rundown on how to set it up:
• First, initialize a BackgroundAudioPlayer instance in your session manager.
• Then, use the start_hold() method to mute the customer’s audio and start playing the hold music. For example:
def start_hold(self):
self.customer_session.input.set_audio_enabled(False)
self.customer_session.output.set_audio_enabled(False)
self.hold_audio_handle = self.background_audio.play(
AudioConfig("hold_music.mp3", volume=0.8),
loop=True,
)
• Once the transfer is done, just call stop_hold() to stop the music and turn the customer’s audio back on.
You can use your own audio files like MP3s or WAVs, or even built-in clips for the hold music. If you want, I’m here to help you with any part of the setup—just let me know!
Sources: examples/drive-thru/drivethru_agent.py | Agent speech and audio | LiveKit Docs | telephony/warm_handoff.py | meditation_assistant/audio_handler.py