Hey, need help with taming `BackgroundAudioPlayer`...
# agents
f
Hey, need help with taming
BackgroundAudioPlayer
very simple code inside the tool call starts playing background audio, but never stops. In logs
Hold music stopped
is printed , but music keeps playing.
Copy code
try:
            # Play hold music if background audio player is available
            if self._background_audio_player:
                play_handle = self._background_audio_player.play(
                    AudioConfig(BuiltinAudioClip.HOLD_MUSIC, volume=0.5),
                    loop=True
                )
                logger.info("Hold music started")
            
            # Wait for the specified duration
            await asyncio.sleep(timeInSeconds)
        finally:
            # Stop the hold music when done if it was started
            if play_handle is not None:
                play_handle.stop()
                logger.info("Hold music stopped")
r
Can you modify this code so it reproduces the issue so I can try it? https://github.com/livekit/agents/blob/main/examples/voice_agents/background_audio.py
👀 1
Try to keep the code to the minimum needed to reproduce the issue.
f
will try ,thanks