Skip to content

fix: report speech end timestamps across stt plugins - #7796

Merged
chenghao-mou merged 50 commits into
chenghao/fix/AGT-3678-stt-timestamp-anchorfrom
chenghao/fix/AGT-3678-stt-eos-timestamps
Nov 2, 2026
Merged

chenghao-mou merged 50 commits into
chenghao/fix/AGT-3678-stt-timestamp-anchorfrom
chenghao/fix/AGT-3678-stt-eos-timestamps

Conversation

@chenghao-mou

@chenghao-mou chenghao-mou commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Report speech-end timestamps for live-tested STT configurations and retain clock fixes across providers. Sarvam realtime keeps untimed EOS with corrected manual ordering. Untimed transcripts that follow EOS retain the current turn’s boundary.

Paced tests follow @Malik1234567891011's proposal. AssemblyAI gateway parameter forwarding is tracked separately in livekit/agent-gateway#1827.

Stacked on #7795. Addresses AGT-3678 (Linear) and #7651 (@AndrazP's diagnosis). Reconnect handling follows @longcw's review.

@davidzhao’s review identified delayed local VAD timestamps; his Gradium and consumer findings were also reproduced. The fixes remove synthetic padding from Gradium timing, use captured audio time for OpenAI and Mistral local VAD, and retain EOS across untimed finals.

Plugin status

Changes are relative to #7795, which supplies the shared clock fix. Only changed production paths are listed. EOS checks use the paced stream tests.

Live checks ran on 2026-10-30; Gradium, OpenAI, and Mistral were rechecked on 2026-11-01. Reconnect checks use real provider connections and verify the original audio timeline after reconnection. OpenAI also reuses a live pooled socket; Sarvam checks nonzero session offsets. RTZR's English-fixture WER remains exempt; its speech timing passed. Reson8’s internal-reconnect probe adds a 1 s delay before reopening to avoid its connection limit; the socket-failure probe uses the normal retry path.

Plugin / path Clock fix in this PR EOS reporting in this PR Live test validation
AssemblyAI (direct) Unchanged Updated: final word end Passed: Universal-3.6 Pro and Universal-3.5 Pro EOS
AWS Fixed: idle reconnect Deferred Passed: idle-timeout reconnect and transcript timing
Azure Speech SDK Fixed: reconnect Updated: recognized speech boundary Passed: reconnect and timed EOS
Baseten Whisper Fixed: reconnect Deferred Passed: reconnect, socket failure, and transcript timing
Cartesia ink-whisper (legacy) Fixed: reconnect Updated: word end on EOS; transcript spans unchanged Passed: reconnect and timed EOS
Deepgram Nova Fixed: reconnect Updated: word end / last_word_end Passed: internal reconnect, socket failure, and timed EOS
Deepgram Flux Fixed: reconnect Updated: word end Passed: reconnect and timed EOS
ElevenLabs realtime Fixed: reconnect Updated: committed word timing Passed: Scribe v2 reconnect and timed EOS with timestamps and server VAD
Fireworks Fixed: reconnect Deferred Not live validated: no available streaming endpoint
Gladia Fixed: reconnect Updated: utterance end Passed: reconnect and timed EOS
Google Fixed: reconnect Updated: speech event / transcript boundary Passed: reconnect and timed EOS with voice activity events
Gradium Fixed: reconnect and synthetic silence offsets Updated: end_text.stop_s Passed: US endpoint reconnect and repeated timed EOS with default vad_flush=True
Inworld Fixed: reconnect Updated: requested word timestamps Passed: inworld-stt-1 reconnect and timed EOS
Mistral realtime Fixed: connection reset and local VAD capture timing Updated: local VAD speech end Passed: Voxtral 2602 and Voxtral 3 reconnect and timed EOS with local VAD; native Voxtral 3 EOS remains untimed
NVIDIA Riva Fixed: word timestamp units (milliseconds to seconds) Unchanged; untimed EOS Passed: English and multilingual Parakeet streaming and word timing
OpenAI realtime Fixed: reconnect, pooled connection offsets, and local VAD capture timing Updated: server / local VAD speech end Passed: model-change reconnect, live socket reuse, and server/local VAD EOS
Reson8 Fixed: internal reconnect Unchanged; untimed EOS Passed: reconnect, socket failure, transcript timing, and shutdown
RTZR Fixed: segment reconnect and word offsets Updated: last word end Passed: segment reconnect and native Korean speech timing
Sarvam realtime Fixed: session offsets Manual ordering fixed; remains untimed Passed: provider timestamp offsets, VAD ordering, and manual-to-VAD switch
SimpliSmart Fixed: reconnect Unchanged; emits no EOS Not live validated: no available streaming deployment
SmallestAI Fixed: reconnect Deferred Passed: Pulse reconnect and transcript timing
Soniox Fixed: reconnect Updated: source token end Passed: stt-rt-v5 reconnect and timed EOS
Speechmatics Unchanged Updated: final segment end Passed: Linden-1 timed EOS
xAI Fixed: reconnect and timestamp offsets Updated: word timing Passed: reconnect and timed EOS
LiveKit inference: word-timed models Unchanged Updated: final word end Passed: Nova-3, AssemblyAI Universal Streaming, and xAI timed EOS
Initial prompt and agent context

Model: GPT-6 Astra

Can you investigate 3678? I believe this is a STT plugin reporting gap.

Can you create a PR to address the EOS speech end time reporting gap?

yes, we need to fix all of them. and verify them one by one please.

sorry, I think I was in a wrong thread. 11labs is not special from other plugins in this thread.

okay, let's add that. But let's verify every changed plugin before committing

let's skip baseten and azure changes for now

Clarification for Azure-related exclusions:

Only microsoft_ai

so for plugins we don't have credentials, we skip the live verification. but we double check the docs and implementation to make sure it is reasonable.

Latest scope:

we should reduce the end time reporting to the ones we validated live, and keep clock fixes

and also double check the ones mentioned in the original issue.

Final validation scope:

can you add a column to the table to show live test validated, even if it is just clock fixing?

SLNG is sunsetting so we can drop that changes too. we should drop plugins that are both unchanged and deffered.

chenghao-mou and others added 5 commits October 13, 2026 22:22
The default stt_node offsets provider timestamps from the session start,
but the recognizer converted them with the pipeline's first audio frame.
On a pipeline created after a handoff the two bases differ by the
session's age, so stopped_speaking_at landed in the future and was
clamped to the arrival time.

The stream now absorbs the delay between its creation and its first
frame, and re-anchors on the next frame after a reconnect, so its offset
is exact on the caller's timeline. The default node records the base it
measured from on the pipeline, and the recognizer adds that same base.
A custom node that forwards provider timestamps untouched is anchored on
the pipeline's creation, when it opens its stream.

Addresses AGT-3678

Co-authored-by: Andraž Pajtler <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
…irst-audio based

Two review findings. A frame queued while a connection fails is the
first audio the next connection sends, but the offset was only anchored
on push, so that frame kept the old connection's offset. The stream now
anchors on the first frame each attempt consumes, with the capture time
recorded at push.

A node that builds events itself, relative to its first frame, was
anchored on the pipeline's creation. An undeclared offset now means the
stream's timeline starts with its first audio, so such streams keep a
zero offset and the pipeline is stamped by the first frame pushed, as
before this change. Only the default node, which declares a
session-relative offset, is anchored on the session input start.
A resampler can hold audio across pushes, so its first output can carry
samples from an earlier frame. Stamping it with the push that released
it anchored the offset late by the time between the two pushes. Track
the capture time of the oldest held sample and stamp each resampled
frame from there.
A resampler can release audio from several pushes at once. Stamping the
later outputs by adding durations erased the gap between those pushes,
so a retry starting on one of them was anchored early. Track the held
input as capture spans and advance through them per output frame.
Carry provider speech-end timing through END_OF_SPEECH so STT turn
metrics retain the word timestamp instead of replacing it with event
arrival. Keep unknown timestamps unset and clear Deepgram's cached
final timing between turns and connections.

Addresses AGT-3678 and the EOS reporting case in #7651.

Co-authored-by: Andraž Pajtler <[email protected]>
@chenghao-mou
chenghao-mou requested a review from a team as a code owner October 13, 2026 22:11
@chenghao-mou chenghao-mou added plugins review_effort:high Needs broad context and substantial validation labels Oct 13, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

Keep the change small. The offset is anchored on the first frame pushed
to each attempt; a frame still queued when a connection fails is left
as a TODO. Resampled frames are no longer stamped individually, so
resampler buffering is a millisecond-level approximation.
Apply speaker filtering and formatting only to transcripts so timed EOS
events still close turns and do not rewrite shared transcript text.
Use word timing for Inference endpoints; billed audio duration does not
identify when speech ended.
devin-ai-integration[bot]

This comment was marked as resolved.

Soniox and Speechmatics Linden gateway finals carry utterance spans without
word timestamps. Preserve those endpoints when every configured model uses
that duration contract. Leave billing and unknown durations untimed.

The timing semantics were checked against agent-gateway 69bcc23d088b.
@chenghao-mou
chenghao-mou added this pull request to stack #7798 October 13, 2026 22:52
@chenghao-mou
chenghao-mou marked this pull request as draft October 13, 2026 23:48
chenghao-mou and others added 10 commits October 14, 2026 00:48
Carry provider speech end timestamps and local VAD anchors through endpoint events. Normalize stream offsets and exclude billing duration, trailing silence, and audio from earlier pooled sessions. Add provider-specific regression coverage.

Addresses AGT-3678

Co-authored-by: Andraž Pajtler <[email protected]>
The stream encoded one timeline in six fields and turned the caller's
origin into an offset and back. Move the timeline into
RecognizeStream._InputChan, which sees every push and every read.

The channel stores the origin and anchors the offset when a connection
reads its first frame. That frame was captured at the last push minus
the audio still queued. This fixes the case where a connection fails
before it reads: the retry now anchors on the oldest queued frame, not
on the next push.

A value set through the setter now means that the timeline began that
many seconds ago, also after the first frame.
The push-audio stub left input_started_at as a truthy MagicMock, so no
test reached the stamping branch. Reset it to None and assert it again.
State the pipeline anchor contract next to the field.
The anchor took the last push minus the queued audio. A pause between
queued frames is not in that sum, so the anchor moved forward by the
pause. Also keep the push time of each queued frame. A frame is pushed
after it is captured, so both values are upper bounds on its capture
start: take the earlier one. It is exact across a pause and for a burst
of buffered audio.
A leg was seeded only when it was created. If the caller set the offset
after the first leg started, that leg kept a zero offset. Seed a leg
that was not seeded when the first frame is forwarded to it. The outer
stream has read that frame, so its timeline has a start.
The module docstring said a custom node is anchored on the pipeline's
creation. It counts from its first audio, as on main.
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

STT Test Results

Status: ✗ Some tests failed

Metric Count
✓ Passed 29
✗ Failed 5
× Errors 0
→ Skipped 21
▣ Total 55
⏱ Duration 428.7s
Failed Tests
  • tests.test_stt::test_stream[livekit.plugins.nvidia]
    self = <livekit.plugins.nvidia.stt.SpeechStream object at 0x78549d10e7e0>
    config = config {
      encoding: LINEAR_PCM
      sample_rate_hertz: 16000
      language_code: "en-US"
      max_alternatives: 1
      audio_chan...automatic_punctuation: true
      model: "parakeet-1.1b-en-US-asr-streaming-silero-vad-sortformer"
    }
    interim_results: true
    
    
        def _recognition_worker(self, config: riva.client.StreamingRecognitionConfig) -> None:
            error = None
            try:
                audio_generator = self._audio_chunk_generator()
      
                response_generator = self._asr_service.streaming_response_generator(
                    audio_generator, config
                )
      
    >           for response in response_generator:
                                ^^^^^^^^^^^^^^^^^^
    
    livekit-plugins/livekit-plugins-nvidia/livekit/plugins/nvidia/stt.py:236: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <riva.client.asr.ASRService object at 0x78549d10e3f0>
    audio_chunks = <generator object SpeechStream._audio_chunk_generator at 0x78549d5b1b40>
    streaming_config = config {
      encoding: LINEAR_PCM
      sample_rate_hertz: 16000
      language_code: "en-US"
      max_alternatives: 1
      audio_chan...automatic_punctuation: true
      model: "parakeet-1.1b-en-US-asr-streaming-silero-vad-sortformer"
    }
    interim_results: true
    
    
        def streaming_response_generator(
            self, audio_chunks: Iterable[bytes], streaming_config: rasr.StreamingRecognitionConfig
        ) -> Generator[rasr.StreamingRecognizeResponse, None, None]:
            """
            Generates speech recognition responses for fragments of speech audio in :param:`audio_chunks`.
            The purpose of the method is to perform speech recognition "online" - as soon as
            audio is acquired on small chunks of audio.
      
            All available audio chunks will be sent to a server on first ``next()`` call.
      
            Args:
                audio_chunks (:obj:`Iterable[bytes]`): an iterable object which contains raw audio fragments
    
  • tests.test_stt::test_stream[livekit.plugins.fireworksai]
    self = <livekit.plugins.fireworksai.stt.SpeechStream object at 0x7303cb834a10>
    
        async def __anext__(self) -> SpeechEvent:
            try:
    >           val = await self._event_aiter.__anext__()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    E           StopAsyncIteration
    
    livekit-agents/livekit/agents/stt/stt.py:687: StopAsyncIteration
    
    During handling of the above exception, another exception occurred:
    
    stt_factory = <function parameter_factory.<locals>.<lambda> at 0x7303bcf1c540>
    request = <FixtureRequest for <Coroutine test_stream[livekit.plugins.fireworksai]>>
    
        @pytest.mark.usefixtures("job_process")
        @pytest.mark.parametrize("stt_factory", STTs + STREAM_ONLY_STTs)
        async def test_stream(stt_factory: Callable[[], STT], request):
            plugin_id = request.node.callspec.id
            frames, transcript, _ = await make_test_speech(
                chunk_duration_ms=STREAM_CHUNK_DURATION_MS, sample_rate=SAMPLE_RATE
            )
            silence = rtc.AudioFrame.create(
                sample_rate=SAMPLE_RATE,
                num_channels=1,
                samples_per_channel=SAMPLE_RATE * STREAM_CHUNK_DURATION_MS // 1000,
            )
            frames.extend([silence] * (TRAILING_SILENCE_DURATION_MS // STREAM_CHUNK_DURATION_MS))
      
            # TODO: differentiate missing key vs other errors
            try:
                stt_instance: STT = stt_factory()
            except ValueError as e:
                pytest.skip(f"{plugin_id}: {e}")
      
            async with stt_instance as stt:
                label = f"{stt.model}@{stt.provider}"
                if not stt.capabilities.streaming:
                    pytest.skip(f"{label} does not support streaming")
      
                for attempt in range(MAX_RETRIES):
                    try:
                        started_at = time.monotonic()
                        async with stt.stream() as stream:
                            async with asyncio.timeout(120):
    >                           events, audio_started_at = await collect_stream_events(stream, frames)
    
  • tests.test_stt::test_stream[livekit.plugins.mistralai.realtime_v3]
    self = <mistralai.extra.realtime.transcription.RealtimeTranscription object at 0x7303cb56abd0>
    model = 'voxtral-mini-transcribe-realtime-3', audio_format = None
    target_streaming_delay_ms = None, server_url = None, timeout_ms = None
    http_headers = {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx2/2.13.1'}
    
        async def connect(
            self,
            model: str,
            audio_format: Optional[AudioFormat] = None,
            target_streaming_delay_ms: Optional[int] = None,
            server_url: Optional[str] = None,
            timeout_ms: Optional[int] = None,
            http_headers: Optional[Mapping[str, str]] = None,
        ) -> RealtimeConnection:
            if timeout_ms is None:
                timeout_ms = self._sdk_config.timeout_ms
      
            security = self._sdk_config.security
            if security is not None and callable(security):
                security = security()
      
            resolved_security = get_security_from_env(security, models.Security)
      
            headers: dict[str, str] = {}
            query_params: dict[str, str] = {}
      
            if resolved_security is not None:
                security_headers, security_query = get_security(resolved_security)
                headers |= security_headers
                for key, values in security_query.items():
                    if values:
                        query_params[key] = values[-1]
      
            # The websocket handshake bypasses the SDK's before-request hooks, so service-account
            # auth has to be applied here too, with the same precedence.
            caller_authorization = any(
                name.lower() == "authorization" for name in (http_headers or {})
            )
            if self._sdk_config.security is None and not caller_authorization:
                token = read_service_account_token()
                if token is not None:
                    headers["Authorization"] = bearer_header(token)
      
            if http_headers is not None:
                headers |= dict(http_headers)
    
  • tests.test_stt::test_stream[livekit.plugins.mistralai.realtime_v3_vad]
    self = <mistralai.extra.realtime.transcription.RealtimeTranscription object at 0x7303cb19cb00>
    model = 'voxtral-mini-transcribe-realtime-3', audio_format = None
    target_streaming_delay_ms = None, server_url = None, timeout_ms = None
    http_headers = {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx2/2.13.1'}
    
        async def connect(
            self,
            model: str,
            audio_format: Optional[AudioFormat] = None,
            target_streaming_delay_ms: Optional[int] = None,
            server_url: Optional[str] = None,
            timeout_ms: Optional[int] = None,
            http_headers: Optional[Mapping[str, str]] = None,
        ) -> RealtimeConnection:
            if timeout_ms is None:
                timeout_ms = self._sdk_config.timeout_ms
      
            security = self._sdk_config.security
            if security is not None and callable(security):
                security = security()
      
            resolved_security = get_security_from_env(security, models.Security)
      
            headers: dict[str, str] = {}
            query_params: dict[str, str] = {}
      
            if resolved_security is not None:
                security_headers, security_query = get_security(resolved_security)
                headers |= security_headers
                for key, values in security_query.items():
                    if values:
                        query_params[key] = values[-1]
      
            # The websocket handshake bypasses the SDK's before-request hooks, so service-account
            # auth has to be applied here too, with the same precedence.
            caller_authorization = any(
                name.lower() == "authorization" for name in (http_headers or {})
            )
            if self._sdk_config.security is None and not caller_authorization:
                token = read_service_account_token()
                if token is not None:
                    headers["Authorization"] = bearer_header(token)
      
            if http_headers is not None:
                headers |= dict(http_headers)
    
  • tests.test_stt::test_stream[livekit.plugins.mistralai.realtime]
    self = <mistralai.extra.realtime.transcription.RealtimeTranscription object at 0x78548c993c50>
    model = 'voxtral-mini-transcribe-realtime-2602', audio_format = None
    target_streaming_delay_ms = None, server_url = None, timeout_ms = None
    http_headers = {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx2/2.13.1'}
    
        async def connect(
            self,
            model: str,
            audio_format: Optional[AudioFormat] = None,
            target_streaming_delay_ms: Optional[int] = None,
            server_url: Optional[str] = None,
            timeout_ms: Optional[int] = None,
            http_headers: Optional[Mapping[str, str]] = None,
        ) -> RealtimeConnection:
            if timeout_ms is None:
                timeout_ms = self._sdk_config.timeout_ms
      
            security = self._sdk_config.security
            if security is not None and callable(security):
                security = security()
      
            resolved_security = get_security_from_env(security, models.Security)
      
            headers: dict[str, str] = {}
            query_params: dict[str, str] = {}
      
            if resolved_security is not None:
                security_headers, security_query = get_security(resolved_security)
                headers |= security_headers
                for key, values in security_query.items():
                    if values:
                        query_params[key] = values[-1]
      
            # The websocket handshake bypasses the SDK's before-request hooks, so service-account
            # auth has to be applied here too, with the same precedence.
            caller_authorization = any(
                name.lower() == "authorization" for name in (http_headers or {})
            )
            if self._sdk_config.security is None and not caller_authorization:
                token = read_service_account_token()
                if token is not None:
                    headers["Authorization"] = bearer_header(token)
      
            if http_headers is not None:
                headers |= dict(http_headers)
    
Skipped Tests
Test Reason
tests.test_stt::test_recognize[livekit.plugins.fireworksai] unknown@FireworksAI does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.assemblyai] universal-3-6-pro@AssemblyAI does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.speechmatics] linden-1@Speechmatics does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.soniox] stt-rt-v5@Soniox does not support batch recognition
tests.test_stt::test_recognize[livekit.agents.inference] unknown@livekit does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.aws] unknown@Amazon Transcribe does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.azure] unknown@Azure STT does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.cartesia._legacy] ink-whisper@Cartesia does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.reson8] livekit.plugins.reson8: Reson8 API key is required, either as argument or RESON8_API_KEY env var
tests.test_stt::test_recognize[livekit.plugins.deepgram.STTv2] flux-general-en@Deepgram does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.mistralai.realtime_v3] voxtral-mini-transcribe-realtime-3@MistralAI does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.gradium.STT] default@Gradium does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.cartesia] ink-2@Cartesia does not support batch recognition
tests.test_stt::test_recognize[livekit.plugins.nvidia] unknown@unknown does not support batch recognition
tests.test_stt::test_stream[livekit.plugins.fal] Wizper@Fal does not support streaming
tests.test_stt::test_stream[livekit.plugins.openai] [email protected] does not support streaming
tests.test_stt::test_stream[livekit.plugins.elevenlabs] scribe_v1@ElevenLabs does not support streaming
tests.test_stt::test_stream[livekit.plugins.reson8] livekit.plugins.reson8: Reson8 API key is required, either as argument or RESON8_API_KEY env var
tests.test_stt::test_stream[livekit.plugins.xai] livekit.plugins.xai: xAI API key is required
tests.test_stt::test_stream[livekit.plugins.rtzr] livekit.plugins.rtzr: RTZR_CLIENT_ID and RTZR_CLIENT_SECRET must be set
... ... and 1 more

Triggered by workflow run #5474

Reanchor each Reson8 connection on its first audio frame instead of rewriting the caller timeline. Exercise real input and shutdown in the reconnect test, and correct the Sarvam offset comment.

@davidzhao davidzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

another one from codex:

[OpenAI](https://github.com/livekit/agents/blob/864446bc8/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py#L837) and [Mistral](https://github.com/livekit/agents/blob/864446bc8/livekit-plugins/livekit-plugins-mistralai/livekit/plugins/mistralai/stt.py#L553) calculate speech end from the wall clock when the VAD event is consumed. Their VAD receives audio after connection setup and through a sender that can block. I queued captured audio behind a nine-second OpenAI configuration delay: expected EOS was 1000.7, but it reported 1009.7. Map the VAD boundary to captured audio time, and test queued audio during setup and reconnect.

chenghao-mou and others added 2 commits November 1, 2026 12:20
Map Gradium provider timestamps around inserted VAD silence. Anchor OpenAI
local VAD events to captured audio, including queued audio and reconnects.
Keep the current STT boundary when an untimed final arrives.

Co-authored-by: David Zhao <[email protected]>
Queued audio can reach VAD after connection setup or a blocked send. Use
its audio timestamp with the capture anchor so those delays do not shift
the speech boundary. Cover setup and send delays on first connect and
reconnect, and retain the boundary across a slow flush.

Co-authored-by: David Zhao <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

chenghao-mou and others added 2 commits November 1, 2026 13:07
Move the padding bookkeeping into a _PaddedTimeline helper. Provider
timestamps arrive in order, so padding that ends before a timestamp is
folded into a running total instead of being summed on every lookup for
the rest of the connection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devin-ai-integration[bot]

This comment was marked as resolved.

@chenghao-mou

Copy link
Copy Markdown
Member Author

another one from codex:

[OpenAI](https://github.com/livekit/agents/blob/864446bc8/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py#L837) and [Mistral](https://github.com/livekit/agents/blob/864446bc8/livekit-plugins/livekit-plugins-mistralai/livekit/plugins/mistralai/stt.py#L553) calculate speech end from the wall clock when the VAD event is consumed. Their VAD receives audio after connection setup and through a sender that can block. I queued captured audio behind a nine-second OpenAI configuration delay: expected EOS was 1000.7, but it reported 1009.7. Map the VAD boundary to captured audio time, and test queued audio during setup and reconnect.

updated the timestamp to use the event creation time instead.

@chenghao-mou
chenghao-mou merged commit 26a0977 into main Nov 2, 2026
25 of 26 checks passed
@chenghao-mou
chenghao-mou deleted the chenghao/fix/AGT-3678-stt-eos-timestamps branch November 2, 2026 20:53
chenghao-mou added a commit that referenced this pull request Nov 2, 2026
Port #7795 and #7796 onto the shared STT
connection coordinator, with #7739 that they build on. Each
provider connection restarts the input clock. RTZR detects idle in the send
loop, and Gladia and Reson8 re-anchor each session on its first frame.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
peirangong-baseten added a commit to peirangong-baseten/agents that referenced this pull request Nov 12, 2026
Conflict in tests/test_plugin_baseten_stt.py: main (livekit#8510) moved the Whisper
tests onto an in-process FakeWebSocket under virtual time. The v2 tests are
moved the same way, since a real local server times out on the virtual
clock: the fake server now answers each event as the client sends it, and its
segment times count the socket's own audio.

main (livekit#7796) also re-anchors start_time_offset on the first frame each
connection reads. A reconnected v2 socket's clock starts at the replayed
audio, before that frame, so the stream now uses the live offset only until
its first reconnect after reading audio, and keeps that anchor from then on.
The offset test starts its audio 1 s after the offset is set and fails both
with the anchor read at connect time and with the live offset throughout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dhruvladia-sarvam added a commit to dhruvladia-sarvam/agents that referenced this pull request Nov 18, 2026
Conflict in tests/test_plugin_sarvam_stt.py: main added REST timestamp
tests where this branch added the transcription_delay test; both kept.

STTRealtime goes back to main: livekit#7796 keeps its END_OF_SPEECH untimed
(test_manual_eos_precedes_final_received_during_send), and its finals
already carry audio-position timing. This PR now changes only the
legacy sarvam.STT stream.

With livekit#7796's framework change, an untimed final after END_OF_SPEECH no
longer replaces the turn's anchor, so the transcription_delay test also
covers a final that arrives after the EOS fallback. The fake WebSocket
gains a no-op ping, because that case idles past the liveness probe
interval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins review_effort:high Needs broad context and substantial validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants