Skip to content

fix/preserve-stt-eos-timestamp-for-metrics#5755

Open
dhruvladia-sarvam wants to merge 1 commit into
livekit:mainfrom
dhruvladia-sarvam:fix/preserve-stt-eos-timestamp-for-metrics
Open

fix/preserve-stt-eos-timestamp-for-metrics#5755
dhruvladia-sarvam wants to merge 1 commit into
livekit:mainfrom
dhruvladia-sarvam:fix/preserve-stt-eos-timestamp-for-metrics

Conversation

@dhruvladia-sarvam
Copy link
Copy Markdown
Contributor

Problem

When turn_handling.turn_detection = "stt" is used with an STT plugin that emits SpeechEventType.END_OF_SPEECH (e.g. Sarvam, AssemblyAI) and no external VAD, EOUMetrics.transcription_delay and EOUMetrics.end_of_utterance_delay are always reported as 0.0.

Root cause

AudioRecognition._on_stt_event unconditionally overwrites self._last_speaking_time with time.time() whenever a FINAL_TRANSCRIPT (or PREFLIGHT_TRANSCRIPT) arrives and self._vad is None — even though the STT plugin already populated that field with the actual end-of-speech moment via END_OF_SPEECH. The framework's own TODO comment acknowledged this:

the correct way is to ensure STT fires SpeechEventType.END_OF_SPEECH and using that timestamp for _last_speaking_time

Fix

Skip the overwrite when turn_detection_mode == "stt", since in that mode the STT plugin is the authoritative source of speech boundaries.

Behavior matrix

External VAD turn_detection Before After
Yes any unaffected same
No "vad" / "manual" falls back to transcript time same
No "stt" overwrites STT timestamp → metrics = 0 preserves STT timestamp

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant