I am having problem trying to play ambient sounds ...
# telephony
h
I am having problem trying to play ambient sounds using background player in SIP calls. `
Copy code
background_audio = BackgroundAudioPlayer(
            # Continuous office ambience to simulate real dispatch office
            ambient_sound=AudioConfig("office_background_one.mp3", volume=0.6),                      thinking_sound=[
                AudioConfig("keyboard_one.mp3", volume=0.7),
                AudioConfig("keyboard_two.mp3", volume=0.6),
            

try:
    await session.start(
        agent=agent,
        room=context.room,
        room_input_options=RoomInputOptions(
        #noise_cancellation=noise_cancellation.BVC(),  # Telephony-optimized BVC for SIP calls
        )
    )  
    try:       
        await background_audio.start(room=context.room, agent_session=session)       
    except Exception as bg_error:       
        logger.error(f"Background audio failed to start: {bg_error}")
except Exception as session_error:
    logger.error(f"Session start failed: {session_error}")
    raise
` Using Twilio
r
What problem are you having?
Maybe the code are not finding the MP3 files you are referencing?
h
`
Copy code
background_audio = BackgroundAudioPlayer(
    ambient_sound=AudioConfig("office_background_one.mp3", volume=0.6),
    thinking_sound=[
        AudioConfig("keyboard_one.mp3", volume=0.7),
        AudioConfig("keyboard_two.mp3", volume=0.6),
    ],
)
` did this too
calls happen correctly, but I cant here any background audio
r
Maybe the code are not finding the MP3 files you are referencing?
h
Copy code
background_audio = BackgroundAudioPlayer(
    ambient_sound=AudioConfig(BuiltinAudioClip.OFFICE_AMBIENCE, volume=0.6),
    thinking_sound=[
        AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING, volume=0.7),
        AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING2, volume=0.6),
    ],
)
thank you I will try that, I also saw some example here where another guy is trying it with SIP
r
The example I just shared was for SIP
Should not matter which source remote participant joins from. It is independent of the background audio.
h
I am trying your example
you are using session.say() to play the audio, can this be used when the agent is talking
r
There are two parts. See the background audio part.
But I expect this is probably the more important part for your needs:
Copy code
audio_path = Path(__file__).parent
audio_file = f"{audio_path}/pre_roll_audio.mp3"
closed_audio_file =  f"{audio_path}/closed.mp3"