Build speech-to-text into the bridge; add droplet deployment examples

STT_PROVIDER now defaults to "builtin": Whisper (onnx-community/whisper-base,
q8) runs in the bridge process on the CPU via @huggingface/transformers, so
no provider account is needed and recordings stay on the bridge host. Silent
captures are detected by level before the model runs. The external
OpenAI-compatible adapter remains available.

Tests: 130 unit/integration; 4 scenarios with the real model on a real
speech recording (npm run test:real-stt). Not tested on audio from the
glasses or on a droplet.

deploy/ and docs/deploy-droplet.md are examples that have not been run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-18 18:31:30 -08:00
co-authored by Claude Fable 5.2
parent 3c9e094977
commit 6d74f9e121
29 changed files with 1602 additions and 42 deletions
+54 -4
View File
@@ -1,6 +1,8 @@
# Test evidence
Recorded 2026-11-18 on the development machine (Linux x64, Node 22.23.2) at commit `4687cc0`.
Recorded 2026-11-18 on the development machine (Linux x64, Node 22.23.2). The first slice was
recorded at commit `4687cc0`; the built-in speech-to-text section was added afterwards and all
suites were re-run with it in place.
These are the results of commands that were actually run. Nothing here is device evidence.
## What kind of evidence each suite is
@@ -10,6 +12,7 @@ These are the results of commands that were actually run. Nothing here is device
| `npm test` | Client and bridge code, HTTP between them, SQLite, Even's `pretext` measurement, the SDK's event parser | Glasses, STT, Hermes | Hermeven's own logic and failure handling | Anything about Even hardware, real STT or real Hermes |
| `npm run test:simulator` | The client running in Even's simulator 0.9.5 through the real SDK bridge; the bridge | STT, Hermes; audio is ALSA's silent null device | The app boots, draws, takes gestures and uploads audio in Even's own simulator | Hardware behaviour, real audio pacing, lock screen, lifecycle |
| `npm run test:real-hermes` | The bridge and a real `hermes gateway` v0.23.1 | The language model behind Hermes | Hermes's admission, idempotency, session continuity and stop behave as the adapter assumes | A real model, tools, approvals, or Dan's deployment |
| `npm run test:real-stt` | The bridge and its built-in Whisper model, on a real speech recording | Glasses, Hermes | Speech uploaded as a capture is really transcribed and the words reach the agent | The G2 microphone, noise, accents, other languages, a droplet's speed |
## Results
@@ -25,8 +28,8 @@ Exit 0, no diagnostics, for contracts, bridge, client and tests.
```
$ npm test
Test Files 7 passed (7)
Tests 122 passed (122)
Test Files 8 passed (8)
Tests 130 passed (130)
```
Run after a clean `npm ci`. Six consecutive full runs were green after the fix described under
@@ -36,6 +39,7 @@ Run after a clean `npm ci`. Six consecutive full runs were green after the fix d
|---|---|---|
| `packages/contracts/test/contracts.test.ts` | 4 | Schema acceptance and rejection, error-code retryability |
| `services/bridge/test/units.test.ts` | 13 | Config guards, credential expiry and renewal, pairing codes, adapter helpers |
| `services/bridge/test/builtinWhisper.test.ts` | 8 | Built-in STT adapter with a stand-in recogniser: silence gate, language, ordering, cancel, load failure |
| `apps/even-client/test/reducer.test.ts` | 24 | State transitions, cancellation, stale and late results, connection loss |
| `apps/even-client/test/layout.test.ts` | 16 | Pagination, Unicode, long answers, plain-text conversion, HUD frames fit |
| `apps/even-client/test/events.test.ts` | 8 | Gesture mapping through the SDK's parser, the tap-has-no-eventType quirk |
@@ -142,6 +146,50 @@ Two of the nine failed on the first run because the stub model mistook Hermes's
Timings seen here (stub model, loopback, one sample each): first turn about 1.4 s in Hermes;
later turns well under 1 s. These are not performance figures for anything real.
### Built-in speech-to-text, real model, real speech
```
$ npm run test:real-stt
Tests 4 passed (4)
```
`onnx-community/whisper-base`, 8-bit weights, run in the bridge process on the CPU. The input is
`tests/real-stt/fixtures/jfk.wav`, 11.0 s of clean archive speech, uploaded through
`POST /v1/turns` as raw PCM exactly as the client uploads a capture.
| Scenario | Result |
|---|---|
| Real speech is transcribed and the transcript is what the (fake) agent receives | pass |
| Three seconds of digital silence: `stt_empty`, the agent is not called | pass |
| Three seconds of very quiet noise: `stt_empty` | pass |
| A second recording with the model already loaded | pass |
Transcript produced: "And so my fellow Americans, ask not what your country can do for you, ask
what you can do for your country." That matches the recording.
Measurements from this run, one sample each, on an Intel i7-13850HX desktop:
| Measurement | Value |
|---|---|
| Model load (files already cached) | 1.2 to 3.8 s |
| 11.0 s of speech | 1.6 s |
| Memory (resident) after loading / after transcribing | about 0.5 GB / 0.8 GB |
| Longest event-loop pause during transcription | 0.39 s |
| Same clip with the process pinned to one core | 1.7 s (no slower) |
Things this run also showed that are worth knowing:
- When the same clip was cut off mid-sentence at 6 s, the model wrote "ask not what you are
coming" for the truncated ending. A recording that stops mid-word (for example at the capture
cap) can end in invented words.
- Whisper produces short invented phrases for silent input, which is why silence is detected by
level before the model runs. The level threshold (-55 dBFS) was chosen without any G2 audio and
may be wrong for the real microphone in either direction.
- Nothing here measures a droplet. See `docs/deploy-droplet.md`.
The bridge process was also started with default settings: it logged `stt.loading`, then
`stt.ready`, and answered `/healthz` throughout.
### Build and packaging
```
@@ -175,7 +223,9 @@ unauthenticated `/v1/device` answered 401, `bridge:cli -- pair` printed a code,
- A physical G2, the R1 ring, the Even phone app, any phone.
- The microphone with the phone locked or the app in the background.
- Real speech-to-text, in any language.
- Speech-to-text on audio from the glasses, with background noise, or in any language but English.
- The external (`openai-compatible`) STT adapter against a real provider.
- Anything on a DigitalOcean droplet: `docs/deploy-droplet.md` and `deploy/*` are untested.
- A real language model, real tools, a real approval prompt.
- Hermes `waiting_for_approval`, `unknown`, `interrupted` and stopped-short runs against real
Hermes (fake only).