Skip to content

perf(dictation): pre-encode pause-separated chunks during long captures - #3077

Merged
kitlangton merged 2 commits into
devfrom
background-pause-chunks
Nov 29, 2026
Merged

kitlangton merged 2 commits into
devfrom
background-pause-chunks

Conversation

@kitlangton

Copy link
Copy Markdown
Collaborator

Pre-encode completed pause-separated chunks offline during long dictations so release only decodes the final tail.

Before

When Live Text is off, PR #3057 stopped running Unified English's punctuation-dropping live stream. Short dictations got faster, but long 30–84 s dictations waited until key-up to decode the entire clip in one offline pass (~377–487 ms).

After

While a dictation records without a live stream, PauseChunks watches the resampled 16 kHz audio through PauseSegmenter::for_dictation() (≥10 s piece + ≥400 ms pause, or ≥18 s + ≥300 ms).

  • Short dictations (<10 s): zero chunks seal and zero engine commands are sent — identical single-clip source=offline path.
  • Long dictations: each sealed chunk (with excess leading silence trimmed to 100 ms so inter-chunk pauses do not degrade punctuation) runs through the same offline whole-clip decoder on the single TranscriptionEngine thread (bounded to 2 in-flight chunks) while capture continues.
  • Release: finish_with_chunks verifies contiguous coverage of 0..sealed_end, decodes only the final tail chunk (skipping it when Silero VAD finds no speech), and joins the trimmed pieces with single spaces (source=chunked).
  • Fallback & cancellation: cancel (Esc), short-tap discard, near-silent discard, model switches, Command::Run/Reload, Labs › Words on screen terms, or any chunk error aborts in-flight chunks cleanly and falls back to full-clip offline decoding.

Measured (Unified English Q8_0 on Metal, 56.7 s multi-sentence speech fixture)

Case Source Release latency (3 runs) Median
Before (whole clip, 56.7 s) offline 377 / 392 / 401 ms 392 ms
After (5 pause chunks, 5.2 s tail) chunked 58 / 60 / 60 ms 60 ms
Short clip (6.8 s, 0 chunks) offline 58 ms 58 ms

Exact string parity with synchronous pause-split offline decoding, zero word errors vs whole-clip, and closing sentence punctuation preserved.

Read: src/transcription/engine/pause_chunks.rs, src/transcription/pause_segmenter.rs, src/transcription/engine.rs, src/dictation.rs.

@kitlangton
kitlangton merged commit 12d20a5 into dev Nov 29, 2026
4 checks passed
@kitlangton
kitlangton deleted the background-pause-chunks branch November 29, 2026 01:44
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