{"message": ":sound::ear: typing should start...",...
# ask-ai
d
{"message": "🔉👂 typing should start...", "level": "INFO", "name": "collect-name-task", "pid": 131, "job_id": "AJ_ZUSGes5mKaPs", "timestamp": "2025-11-03T165039.650673+00:00"} {"message": "Checking for images (attempt 1/12)", "level": "INFO", "name": "collect-name-task", "pid": 131, "job_id": "AJ_ZUSGes5mKaPs", "timestamp": "2025-11-03T165039.655333+00:00"} # 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?" DOES NOT PLAY TYPING AUDIO
t
Thanks for reaching out, Billy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm here to help you get the typing audio issue sorted out! Could you please share a bit more about your setup? • Are you working with the Python SDK or the JavaScript/TypeScript SDK for LiveKit Agents? • Does the agent enter a "thinking" state while polling for images? If yes, could you tell me how this state gets triggered? • Is your agent running inside a live room connection, or are you using console/debug mode? Sources: examples/src/background_audio.ts | livekit-plugins/livekit-plugins-fireworksai/livekit/plugins/fireworksai/stt...
d
from livekit.agents import AgentTask, function_tool, RunContext, AgentSession, get_job_context, BackgroundAudioPlayer, AudioConfig, BuiltinAudioClip its supposed to play the audio and it does not.
t
I understand how frustrating it can be when the typing audio doesn’t play during image polling in the LiveKit Python SDK. Let’s work through some common causes together to get this sorted out: • Event Loop Blocking: It’s important that your image polling runs asynchronously using
await
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:
Copy code
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...
d
Copy code
background_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 play
t
I understand how important it is for the
thinking_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.py
d
IT DOES NOT PLAY
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!