Skip to content

Realtime transcription: recognize an utterance while the silence that ends it goes on, so that completed comes as it is committed #230

Closed

Description

@kein5

Hi, this is a proposal from a downstream integration: a desktop app that sends a microphone to speech serve's Realtime transcription (server_vad), translates each completed utterance and speaks the translation with another speech serve. We measure the time from the end of speech to the translated voice, and part of it is a wait that the server could overlap with the silence it already waits for.

What happens

With server_vad, an utterance is recognized once the silence after it has lasted silence_duration_ms and its region is certain, so conversation.item.input_audio_transcription.completed comes the recognition's time after speech_stopped and committed. With Qwen3-ASR 0.6B Q8_0 on an RTX 4080 SUPER (Vulkan, Linux), silence_duration_ms 400 and prefix_padding_ms 200, that is 54 / 111 ms after the commit (p50 / p95 over 36 utterances: 6 Japanese sentences of 2.5 to 5 s sent 3 times in each of 2 rounds, load average below 1.5).

The detection knows the region's end well before the region is certain: where the speech probability fell below the threshold less 0.15. If the silence lasts and no region starts within twice speech_pad_ms, the region is given with that end plus speech_pad_ms, and that audio has all arrived once the silence has lasted speech_pad_ms (200 ms here), 200 ms before the commit.

What we propose

Recognize the region's audio to that end while the silence goes on, and let the commit of a region that ends there take that recognition:

  • C API: int speech_detection_quiet(const speech_detection *, double * end) (4.3): whether the region under way has fallen quiet (its probability fell below the threshold less 0.15 and has not risen above the threshold since, and it is longer than min_speech_duration_ms), with the padded end it is given with if the silence lasts and no region follows within twice speech_pad_ms. It reads RegionStream's temp_end_; nothing else in the detection changes.
  • Utterance assembly (tools/common/utterances.cpp): once the detection says the utterance under way is quiet and its audio has reached that end, the worker recognizes those samples (provisional false, the last reading as draft) before any reading. The commit of a region with the same first and last sample takes that recognition instead of one of its own; any other commit, speech that resumes, clear, ask and the end drop it and cancel it if it runs. Readings of that utterance stop meanwhile, as its audio is not expected to grow. An utterance enhanced before its recognition is left as it is.

The recognition reads the same samples as the commit's would; only when it runs moves. Its draft is the last reading before it, which can be one reading older than the one the commit's recognition would have. The cost is a recognition thrown away when speech resumes between speech_pad_ms and silence_duration_ms of silence: in our 7 sentences, 8 of 18 utterances had such a pause.

What we measured

A prototype is on our fork: https://github.com/kein5/speech.cpp/tree/realtime-recognize-before-commit (one commit on main, 0.11.1; measured with the same commit on 0.11.0). Against a build of 0.11.0 from the same machine, with the same client and audio:

Build committed to completed, p50 / p95 End of speech to completed, p50 / p95 (utterances not cut in two)
0.11.0 53.6 / 111.1 ms 594.5 / 676.7 ms
the prototype 0.1 / 0.2 ms 540.2 / 610.8 ms

Both builds were built from source the same way (Release, Vulkan, GGML_NATIVE=OFF) and served the same models (Qwen3-ASR 0.6B Q8_0 and Silero VAD v6.2 F32). The client sent the audio at 24 kHz in 20 ms pieces in real time, with silence_duration_ms 400, prefix_padding_ms 200 and the default threshold, and timed the events as they arrived; the "end of speech" is the last 10 ms of each recording within 30 dB of its loudest 10 ms.

Transcripts: compared by hash, the prototype gave no transcript that 0.11.0 did not. One sentence came out as one of two transcripts in both builds, in a different proportion (0.11.0: 4 and 2 times; the prototype: 2 and 4). We take that to be the variation 0.11.0 already has between runs (the draft each recognition gets, or the GPU's order of sums), and did not look further.

Cost: in one round of 24 utterances, the prototype ran 12 more recognitions to completion than 0.11.0 and cancelled 2, all at pauses of 200 to 400 ms within a sentence; each is one recognition of the utterance so far (about 50 ms on this GPU). Readings stop meanwhile.

Not run: speech-api-check detect, as the official dumps of reference/silero-vad are not on our machine; checks/api/speech-api-detection-stream.c now also asks that each region given before the end had its end said by speech_detection_quiet() first, and compiles. The server and realtime smoke scripts were not run. Only Linux with Vulkan was built.

Questions

  • Would you take this, and in this shape? We are happy to turn the prototype into a pull request with an ADR and the checks you want, or to leave the implementation to you.
  • speech_detection_quiet() is one way to let the assembly know the end early. Extending speech_detection_speaking() would be a major version change, which is why we added a function.

Activity

  1. nyosegawa commented on Nov 21, 2026

    @nyosegawa
    Owner

    Thanks for the detailed proposal and the prototype. We've taken the idea, in a slightly different shape, in #232 and #233.

    While trying it, we found that with OpenAI's defaults (prefix_padding_ms 300, silence_duration_ms 500) the prototype's early recognition was always dropped. With Silero VAD's padding, a region's end waits until twice speech_pad_ms of silence has passed, so for the last 100 ms before the commit the region is no longer reported as quiet. Your measurement used 400 and 200, where that wait does not exist.

    So we went at that wait first. #232 pads the speech the detection finds in the tools, as OpenAI's reference describes a turn, so an utterance is committed once silence_duration_ms has passed: after 500 ms with the defaults instead of 600, and sooner whenever silence_duration_ms is shortened. Then #233 adds speech_detection_ending() (C API 4.3), and reads the utterance to the end it would take while the silence goes on. The commit takes that reading when the samples are the same; if speech resumes, it counts as an ordinary reading, so nothing is thrown away.

    On an Apple M5 with the defaults, the median time from the end of speech to completed went from 0.79–0.80 s to 0.58–0.59 s with Qwen3-ASR 0.6B, and from 0.96–1.00 s to 0.62–0.66 s with 1.7B. Both will be in 0.11.2.

    Thanks again for looking into this so carefully.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions