Skip to content

fix(speech): keep the first words of streaming dictation - #39107

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix/dictation-streaming-start
Nov 6, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix/dictation-streaming-start

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12

What Changed

  • Before the first audio of each streaming dictation session, the speech worker feeds the online stream 1 s of digital silence. That audio goes through the same accept-and-decode loop as the speech. A streamPrimed flag is cleared whenever resetSessionState creates the next session's stream, which happens after stop and after discard.
  • The priming happens on the session's first feed, not when the stream is created, so a stop never waits on the next session's stream.

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:

Zipformer Streaming EN (en-20M) Before After
LibriSpeech, 73 clips: per-utterance WER 27.0% 16.1%
LibriSpeech: first word wrong 71/73 37/73
Dictation-style clips, 10: WER 57.7% 53.7%
162 s long clip: WER 7.8% 8.0%

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:

  • 0.5 s of silence barely helped (WER 27.9%).
  • 1 s helped most, and 1.5 s and 2 s were no better.
  • Real microphone noise before speech (0.5 s at -50 dBFS) didn't help on its own (30.6%).
  • Digital silence in front of that noise still did (21.0%).

So a real pause before you speak doesn't fix this, and the priming helps either way.

Other streaming models:

  • The bilingual zh-en zipformer barely shows the problem, and priming changed its WER from 15.5% to 14.2%.
  • The streaming paraformer was neutral to slightly better (40.0% → 38.2%).

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:

  • before: "UL HAD BEEN ASLEEP BUT SHE HEARD..."
  • after: "THE LITTLE GIRL HAD BEEN ASLEEP BUT SHE HEARD..."

Testing

  • I drove the real worker bundle on sherpa-onnx-darwin-arm64 1.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:

  • If you stay silent for 1.4 s before speaking, an empty endpoint fires. It posts nothing, the stream keeps its encoder state, and nothing is lost.
  • The 20 s forced cut on the first segment comes about 1 s earlier.

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • The same worker serves desktop, orca serve and phone dictation, so all three get the fix. Nothing in the wire format changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: db0b6eaf-a83a-4dd2-b7c6-e4b605319d1d
Commits

Reviewing files that changed from the base of the PR and between 60ced6e and 0f6451a.

Files selected for processing: 1

  • src/main/speech/stt-worker.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

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
AmoabaKelvin force-pushed the fix/dictation-streaming-start branch from fca652f to 0f6451a Compare November 6, 2026 18:00
@AmoabaKelvin
AmoabaKelvin merged commit 586d214 into main Nov 6, 2026
47 of 48 checks passed
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