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
+6 -4
View File
@@ -31,6 +31,7 @@ DigitalOcean droplet.
| Tests | `services/bridge/test/builtinWhisper.test.ts`, `tests/real-stt/*` (with a public-domain speech fixture) |
| Deployment examples, **not run on a droplet** | `deploy/*`, `docs/deploy-droplet.md` |
| New dependency | `@huggingface/transformers` 4.3.2 (brings ONNX Runtime and `sharp`) |
| Whisper moved to a worker thread; polling shortened (bridge 150 ms; app 200/400/1000 ms by elapsed time) | `services/bridge/src/stt/whisperWorker.mjs`, `builtinWhisper.ts`, `config.ts`, `apps/even-client/src/core/controller.ts` |
## Changed files
@@ -54,8 +55,8 @@ Full detail, including failures along the way, is in `docs/test-evidence.md`.
|---|---|
| `npm ci` | clean install, 0 vulnerabilities reported |
| `npm run typecheck` | exit 0 |
| `npm test` | 130 passed, 0 failed (8 files) |
| `npm run test:real-stt` | 4 passed, 0 failed |
| `npm test` | 131 passed, 0 failed (8 files) |
| `npm run test:real-stt` | 7 passed, 0 failed |
| `npm run test:simulator` | 6 passed, 0 failed; 10 consecutive runs of the final revision |
| `npm run test:real-hermes` | 9 passed, 0 failed |
| `npm run client:build` | built; bundle searched for server secrets, none |
@@ -68,7 +69,7 @@ Full detail, including failures along the way, is in `docs/test-evidence.md`.
| Fakes only | 122 tests |
| Even simulator 0.9.5 | 6 scenarios, screenshots in `docs/evidence/simulator/` |
| Real Hermes v0.23.1, stub model | 9 scenarios |
| Real STT | 4 scenarios: built-in Whisper on one clean archive recording |
| Real STT | 7 scenarios: built-in Whisper on one clean archive recording |
| Real model or tools | none |
| Physical device | **none** |
@@ -107,7 +108,8 @@ Offered as places to look, not as findings.
- The client holds captured audio in memory for a possible resend until the user discards it.
- The real-Hermes test covers neither approvals nor the `unknown` status.
- The built-in speech model is fetched from the Hugging Face hub at first start with no pinned
revision or hash, and runs in the bridge's own process (a measured 0.4 s event-loop pause).
revision or hash. It runs in a worker thread of the bridge process, in plain JavaScript
(`whisperWorker.mjs`) that the type checker does not cover.
- The silence threshold in `builtinWhisper.ts` was chosen without any audio from the glasses.
- The systemd hardening options in `deploy/` have never been run with ONNX Runtime.