dazzling-truck-32153
11/03/2025, 5:09 PMtall-airline-16756
11/03/2025, 5:09 PMtall-airline-16756
11/03/2025, 5:10 PMdazzling-truck-32153
11/03/2025, 5:11 PMtall-airline-16756
11/03/2025, 5:12 PMawait and asyncio.sleep(). If there are blocking operations, they might be stopping the audio from playing smoothly.
• Agent State Management: The typing audio plays only when the agent is in a "thinking" state. Could you please check if your agent is transitioning to this state during image polling?
• Configuration: Double-check that the BackgroundAudioPlayer is set up properly with a thinking_sound, and that the agent_session is passed correctly to background_audio.start().
Here’s a simple example of how to keep your image polling non-blocking:
async def poll_images():
while True:
# Your image processing logic here
await asyncio.sleep(0.5) # Poll interval
If you could confirm whether your image polling is asynchronous and if the agent enters the "thinking" state during this time, it would really help us narrow down what’s going on. I’m here to help every step of the way!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real...dazzling-truck-32153
11/03/2025, 5:13 PMbackground_audio = BackgroundAudioPlayer(thinking_sound=AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING, volume=0.8))
# Polling configuration
max_attempts = 12 # Total attempts
sleep_duration = 2 # Seconds between checks
logger.info("🔉👂 typing should start...")
await background_audio.start(room=ctx.room, agent_session=self.session)
for attempt in range(max_attempts):
logger.info(f"Checking for images (attempt {attempt + 1}/{max_attempts})")
result = await check_if_image(session)
if result > 0:
logger.info(f"✅ Found {result} images on attempt {attempt + 1}!")
self.complete(True)
return
# Don't sleep after the last attempt
if attempt < max_attempts - 1:
logger.info(f"No images found, waiting {sleep_duration} seconds before next check...")
await asyncio.sleep(sleep_duration)
await background_audio.aclose()
# If we get here, no images were found after all attempts
logger.info("No images found after all attempts")
return "Say: I still haven't received any photos after checking a few times. Would you mind trying to send them again?"
here is the code it does not playtall-airline-16756
11/03/2025, 5:14 PMthinking_sound in BackgroundAudioPlayer to play smoothly during asynchronous operations, including loops with asyncio.sleep(). It sounds like the sound currently only plays when the agent enters a "thinking" state, and from what you've shared, it seems the agent might not be switching to "thinking" during the image polling process.
Let’s try these steps together to get this working:
• Make sure the agent explicitly enters the "thinking" state right when the image polling starts. This step is key for triggering the thinking_sound.
• Double-check that the BackgroundAudioPlayer is properly initialized and started with the agent_session parameter.
• Try testing with a simpler example, like a single asyncio.sleep() call, to see if the thinking_sound plays as expected in that scenario.
If you’re still running into trouble, could you please let me know if the agent’s state is actually changing to "thinking" during the polling? That info will really help us figure out the next best steps.
Sources: examples/voice_agents/background_audio.pydazzling-truck-32153
11/03/2025, 5:14 PMtall-airline-16756
11/03/2025, 5:14 PM