Repository navigation
fix(speech): keep the first words of streaming dictation - #39107
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
10 of 11 tasks
AmoabaKelvin
force-pushed
the
fix/dictation-streaming-start
branch
from
November 6, 2026 17:48
2306f32 to
fca652f
Compare
A new streaming stream starts with empty encoder caches, and zipformer en-20M then drops most of the first second of speech: the first word was wrong on 71 of 73 LibriSpeech clips. Each session's stream now takes a second of silence before its first audio. That cuts per-utterance WER from 27.0% to 16.1%. The priming runs on the first feed so stop never waits for it.
AmoabaKelvin
force-pushed
the
fix/dictation-streaming-start
branch
from
November 6, 2026 18:00
fca652f to
0f6451a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
With the "Zipformer Streaming EN" voice model, the first word or two you said usually went missing. "Mister Quilter is the apostle..." came out as "is the apostle...". Every new dictation now starts by giving the model a moment of silence, so it's ready before your voice arrives.
What Changed
streamPrimedflag is cleared wheneverresetSessionStatecreates the next session's stream, which happens after stop and after discard.Measured with the bundled worker on the real sherpa-onnx 1.12.37 addon. One warm worker ran every clip in order, with 100 ms feeds and stop/reset between clips, which is how Orca uses it:
Why
A new stream starts with empty encoder caches. Zipformer en-20M then produces no tokens for roughly the first 1–1.7 s of speech. The trace for "It is obviously unnecessary..." showed the first token at 1.72 s. Feeding the whole clip at once drops the same words, so the 100 ms chunking isn't the cause. sherpa-onnx 2.0.1 behaves the same way.
I measured other lead-ins on the same 83 clips:
So a real pause before you speak doesn't fix this, and the priming helps either way.
Other streaming models:
Since no model got worse, priming applies to every streaming model rather than special-casing one.
Priming costs 13 ms for en-20M and 35 ms for the bilingual model, once per session, on the first feed.
This is a workaround for a weak model start, not a fix to the model, and the en-20M first word is still wrong on half the clips. Swapping the default streaming model is for the catalog work in a later wave.
Linked Issue
No issue. This came from the on-device dictation benchmark (Wave 0 of the dictation plan).
Visual Proof
N/A. The change is in the words the transcript contains, not anything on screen. The before/after transcripts above come from the real-addon run. For example,
ls-1272-135031-0003:Testing
I drove the real worker bundle on
sherpa-onnx-darwin-arm641.12.37 with zipformer en-20M over 84 bench clips and compared it against a bundle built from main. That produced the table above.I swept lead-in lengths and noise levels directly on the addon, and ran the bilingual zipformer and the streaming paraformer from Orca's catalog.
Focused vitest:
stt-worker.test.ts,stt-service.test.ts,runtime-mobile-dictation-controller.test.ts. The changed-file checks passed.I tested on macOS only. Linux and Windows run the same JS and the same sherpa version.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
No test was added. The fix only shows up when the native model decodes, so a unit test would just assert that a mock received zeros.
Risk
The riskiest part is the endpoint timing for the first segment of a session, because the primed second counts as trailing silence:
The first partial also arrives 13–35 ms later.
A plain revert undoes all of this.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
orca serveand phone dictation, so all three get the fix. Nothing in the wire format changes.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)