Run Whisper in a worker thread; shorten polling

The speech model now lives in a worker thread (whisperWorker.mjs), so
loading and transcribing no longer block the bridge's HTTP server or its
Hermes polling. Measured longest event-loop pause during transcription:
387 ms before, 3 ms after. A dead worker is replaced on the next request;
closing the bridge terminates it.

Polling: bridge to Hermes every 150 ms (was 500). The app polls the bridge
every 200 ms for the first 8 s of a turn, 400 ms until 30 s, then 1 s
(was a fixed 700 ms).

Tests: 131 unit/integration, 7 real-speech, 9 real-Hermes, 6 simulator,
all passing. Effect on a phone or a droplet is not measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-18 18:39:28 -08:00
co-authored by Claude Fable 5.2
parent 6d74f9e121
commit 0c9dcd864f
14 changed files with 212 additions and 31 deletions
+4 -3
View File
@@ -56,9 +56,10 @@ Stated so they are not mistaken for protections.
3a. **The built-in model's files are downloaded from the Hugging Face hub on first start** and
are not pinned to a revision or checked against a known hash. A compromised hub account or
path could serve different weights. Pinning a revision is a follow-up.
3b. **While a recording is being transcribed the bridge can pause for a few hundred
milliseconds** (measured about 0.4 s), because the model runs in the same process. Harmless
for one user; a worker thread would remove it.
3b. **The speech model runs in a worker thread of the bridge process**, not a separate
sandboxed process. It no longer stalls the bridge (measured 3 ms), but a crash inside the
native runtime could still take the bridge down; systemd restarts it and in-flight turns are
recovered or failed honestly.
4. **In the simulator, raw audio frames are echoed to the WebView console.** Whether the phone
does the same is unknown and is on the device checklist. If it does, recordings would be
visible to whoever can read that console.