Skip to content

Add first interim STT latency metric - #6535

Open
spyrux wants to merge 5 commits into
livekit:mainfrom
spyrux:spyrux/stt-first-interim-metric
Open

Add first interim STT latency metric#6535
spyrux wants to merge 5 commits into
livekit:mainfrom
spyrux:spyrux/stt-first-interim-metric

Conversation

@spyrux

@spyrux spyrux commented Jul 24, 2026

Copy link
Copy Markdown

closes #6533 — STT time-to-first-partial metric (#6533)

Summary

Adds first_interim_delay: the elapsed time from VAD detecting speech onset to the first interim (partial) STT
transcript for a user turn.

The metric is:

  • captured once, on the first interim STT event for each turn
  • reset when the user turn is cleared or completed
  • exposed in EOUMetrics
  • included in the per-turn metrics report
  • recorded as the lk.agents.turn.first_interim_delay OpenTelemetry histogram

A missing interim transcript is represented as unavailable in the turn report and 0.0 in the existing EOUMetrics
event convention.

Tests

pytest tests/test_end_of_turn_metrics.py tests/test_stt_first_interim_metric.py

- verifies the delay is calculated from speech onset
- verifies the metric is unavailable when no interim transcript arrives

@CLAassistant

CLAassistant commented Jul 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@spyrux
spyrux marked this pull request as ready for review July 24, 2026 07:48
@spyrux
spyrux requested a review from a team as a code owner July 24, 2026 07:48
devin-ai-integration[bot]

This comment was marked as resolved.

)

elif ev.type == stt.SpeechEventType.INTERIM_TRANSCRIPT:
if self._first_interim_time is None and self._speech_start_time is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This marks an interim as received before checking that it contains any text. Deepgram v1 forwards non-final Results even when alt["transcript"] is empty, so the first blank result wins the timestamp and the metric no longer measures first transcript latency; gate this on ev.alternatives[0].text.

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.

STT time-to-first-partial metric (speech onset → first interim), the STT analog of ttft/ttfb

3 participants