does `max_endpointing_delay` get compared against ...
# ask-ai
i
does
max_endpointing_delay
get compared against
last_speaking_time
to determine turn end?
t
Thanks for reaching out, Ed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely! The
max_endpointing_delay
is indeed compared directly with
last_speaking_time
to figure out when a turn should end. The system works out the wait time using this formula: • Python:
extra_sleep = last_speaking_time + endpointing_delay - time.time()
• JavaScript:
const extraSleep = lastSpeakingTime + endpointingDelay - Date.now();
When the turn detection model isn't very confident that the user has finished speaking, it uses
max_endpointing_delay
as the
endpointing_delay
. This helps the system decide how much longer to wait before finalizing the turn, based on the last speech it detected. If you'd like, I’m here to walk you through more details about how the turn detection process works—just let me know! Sources: livekit-agents/livekit/agents/voice/agent_session.py | agents/src/voice/audio_recognition.ts | Turn detection and interruptions | LiveKit Docs
i
so we seem to have a bug where
last_speaking_time
isn't getting updated. so when the agent runs an end of turn prediction, and determines that it isnt the end of turn, that actually gets overriden because the
last_speaking_time
is stale and so
max_endpointing_delay
is compared against that
t
I'm here to help you understand why the
last_speaking_time
might not be updating. There are a few common reasons this can happen: • No Speech Activity Detected: If no audio is sent or if VAD or STT doesn’t pick up any speech, the timestamp simply won’t update. • VAD or STT Not Enabled: It’s a good idea to double-check that either VAD or STT is turned on in your settings. • Event Propagation Issues: Sometimes, if VAD events like
END_OF_SPEECH
aren’t firing properly, the timestamp won’t show any speech activity. • Silent or Corrupted Audio Input: Extended silence or problems with the audio input can also stop updates from happening. • Task Interruptions: If background tasks like
_vad_task
or
_stt_task
aren’t running, the audio frames won’t get processed. Here’s a simple way to troubleshoot this: 1. Make sure VAD or STT is enabled and set up correctly. 2. Take a look at your logs for VAD events such as
START_OF_SPEECH
and
END_OF_SPEECH
. 3. Confirm that your audio input is working well and isn’t just silent. 4. Check that audio frames are flowing through and being processed as expected. 5. Review your settings for
min_endpointing_delay
and
max_endpointing_delay
to ensure they’re appropriate. If you’d like, I’m happy to walk you through any of these steps or provide more details. Just let me know! Sources: livekit-agents/livekit/agents/voice/agent_session.py | Understanding "silence detected on local audio track" warning