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:
@@ -6,7 +6,7 @@ G2 mic / touch / HUD
|
||||
Even phone app -- WebView running apps/even-client (public Even Hub SDK)
|
||||
| HTTPS, device credential, polling
|
||||
services/bridge (Fastify + SQLite)
|
||||
|-- STT adapter --> an OpenAI-compatible transcription endpoint you choose
|
||||
|-- STT adapter --> built-in Whisper (in process), or an external endpoint
|
||||
|-- Hermes adapter --> Hermes API server (Runs API) for one configured profile
|
||||
```
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ exactly in `apps/even-client/package.json`.
|
||||
| Vite / Vitest | 8.3.8 / 5.1.1 |
|
||||
| Fastify / @fastify/cors | 5.12.8 / 11.4.3 |
|
||||
| better-sqlite3 | 13.2.0 |
|
||||
| @huggingface/transformers (ONNX Runtime 1.30.0) | 4.3.2 |
|
||||
| Speech model | `onnx-community/whisper-base`, `q8` |
|
||||
| @sinclair/typebox | 0.34.52 |
|
||||
| pino | 10.4.0 |
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Running the bridge on a DigitalOcean droplet
|
||||
|
||||
**Status: written, not run.** These steps have not been executed on a droplet. The bridge, the
|
||||
built-in speech model and the Hermes adapter have only been run on the development desktop.
|
||||
Creating the droplet, pointing DNS at it and starting services are Dan's actions.
|
||||
|
||||
## What runs where
|
||||
|
||||
```
|
||||
phone (Even app) --HTTPS--> Caddy :443 --> bridge 127.0.0.1:8787 --> Hermes 127.0.0.1:8642
|
||||
|
|
||||
built-in Whisper (in the bridge process)
|
||||
```
|
||||
|
||||
The bridge listens on loopback only. Caddy is the only thing exposed, and it provides the
|
||||
certificate. Speech is transcribed inside the bridge, so recordings never leave the droplet.
|
||||
|
||||
Hermes can run on the same droplet (shown above) or elsewhere; if elsewhere, `HERMES_BASE_URL`
|
||||
must be `https://`.
|
||||
|
||||
## Sizing
|
||||
|
||||
Measured on the development desktop (Intel i7-13850HX), bridge with `whisper-base`, 8-bit
|
||||
weights:
|
||||
|
||||
| Measurement | Value |
|
||||
|---|---|
|
||||
| Memory after loading the model | about 0.5 GB |
|
||||
| Memory after transcribing | about 0.8 GB |
|
||||
| 11 s of speech, process pinned to one core | about 1.7 s |
|
||||
| Same, `whisper-tiny` | about 1.2 s, about 0.6 GB |
|
||||
| Model download on first start | about 80 MB (`base`), cached afterwards |
|
||||
| Longest pause of the bridge's event loop while transcribing | about 0.4 s |
|
||||
|
||||
Pinning to one core made no difference to speed, so extra cores will not help; a single droplet
|
||||
vCPU is the relevant unit. **A shared droplet vCPU is slower than that desktop core by an amount
|
||||
that has not been measured.** If it were three times slower, 11 s of speech would take about 5 s,
|
||||
well inside the 30 s deadline.
|
||||
|
||||
Suggested starting point, to be confirmed by measuring on the droplet: **2 GB RAM, 1 to 2 vCPU**
|
||||
for the bridge alone. 1 GB is likely too tight alongside the OS. If Hermes shares the droplet,
|
||||
add whatever Hermes needs; that was not measured.
|
||||
|
||||
If transcription is too slow on the droplet, set `STT_MODEL=onnx-community/whisper-tiny`
|
||||
(faster, less accurate) or, for English only, `onnx-community/whisper-base.en`.
|
||||
|
||||
## Steps
|
||||
|
||||
1. **Droplet and DNS.** Ubuntu LTS. Point a hostname at it (for example `bridge.example.com`).
|
||||
Firewall: allow 22, 80 and 443 only.
|
||||
2. **Packages.** Node.js 22.13 or later, git, Caddy.
|
||||
3. **User and directories.**
|
||||
```sh
|
||||
useradd --system --home /opt/hermeven --shell /usr/sbin/nologin hermeven
|
||||
mkdir -p /opt/hermeven /var/lib/hermeven /etc/hermeven
|
||||
chown hermeven:hermeven /var/lib/hermeven
|
||||
```
|
||||
4. **Code.** Clone the repository into `/opt/hermeven`, then `npm ci`. (The dev dependencies are
|
||||
needed: the bridge runs through `tsx`.)
|
||||
5. **Configuration.** Copy `deploy/bridge.env.example` to `/etc/hermeven/bridge.env`, fill it
|
||||
in, `chmod 600`, `chown hermeven`.
|
||||
6. **Hermes.** Enable its API server with a key, bound to `127.0.0.1`. Use a read-only or test
|
||||
profile first.
|
||||
7. **Service.** Copy `deploy/hermeven-bridge.service` to `/etc/systemd/system/`, then
|
||||
`systemctl daemon-reload && systemctl enable --now hermeven-bridge`. Watch
|
||||
`journalctl -u hermeven-bridge -f` for `stt.ready` (the first start downloads the model).
|
||||
8. **TLS.** Put `deploy/Caddyfile.example` at `/etc/caddy/Caddyfile` with your hostname, reload
|
||||
Caddy, then check `curl https://bridge.example.com/healthz`.
|
||||
9. **App build.** On your own machine:
|
||||
`HERMEVEN_BRIDGE_ORIGIN=https://bridge.example.com npm run -w @hermeven/even-client pack`.
|
||||
10. **Pair.** On the droplet, as the service user with the same environment:
|
||||
```sh
|
||||
sudo -u hermeven HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env npm --prefix /opt/hermeven run bridge:cli -- pair
|
||||
```
|
||||
11. **Origin.** Open the phone page, read Diagnostics, "Page origin", put it in
|
||||
`HERMEVEN_ALLOWED_ORIGINS`, restart the service.
|
||||
|
||||
## Things to check on the droplet and write down
|
||||
|
||||
- Time from `stt.loading` to `stt.ready`, and memory of the service after a few questions.
|
||||
- `transcribe_ms` for a few real questions (the phone page shows it per question).
|
||||
- That `curl http://<droplet-ip>:8787/healthz` from outside **fails** (bridge not exposed).
|
||||
- That the unit's hardening options do not stop the model loading. `ProtectSystem=strict` and
|
||||
`MemoryMax` in particular are untested with ONNX Runtime.
|
||||
|
||||
## Not covered yet
|
||||
|
||||
Backups of `/var/lib/hermeven`, log rotation, upgrades, monitoring, and a compiled build that
|
||||
would remove the need for dev dependencies on the droplet.
|
||||
+10
-6
@@ -99,10 +99,15 @@ a suspended stream. The microphone is never reopened without a new tap.
|
||||
|---|---|---|
|
||||
| The public SDK has no speech-to-text API. | **unsupported** | No ASR in `sdk:` types, docs or skills. The official `asr` template says "The STT client itself is a blank stub... You pick your own provider". |
|
||||
|
||||
Decision: one server-side adapter for any service that implements the OpenAI
|
||||
`POST /audio/transcriptions` contract (hosted or self-hosted Whisper). It is exercised only
|
||||
against a test fake so far. **No real STT provider has been run**; none was available on the
|
||||
development machine and choosing a paid one is Dan's decision (see "Decisions needed").
|
||||
Decision (updated after Dan asked for speech-to-text to be built in and to run on a droplet):
|
||||
the bridge runs OpenAI's Whisper model itself, on the CPU, through ONNX Runtime
|
||||
(`@huggingface/transformers` 4.3.2, model `onnx-community/whisper-base`, 8-bit weights). No
|
||||
provider account, and recordings never leave the bridge host. An adapter for any external
|
||||
OpenAI-compatible transcription endpoint remains as an alternative.
|
||||
|
||||
Status: **tested with a real speech recording** (an 11 s archive clip, transcribed correctly in
|
||||
about 1.6 s on the development desktop; see `docs/test-evidence.md`). **Not tested** with audio
|
||||
from a G2 microphone, with background noise, with other languages or accents, or on a droplet.
|
||||
|
||||
### 4. Input events
|
||||
|
||||
@@ -267,8 +272,7 @@ permissions and approval policy are unverified.
|
||||
|
||||
1. **Device access.** Nothing here is device-tested. The checklist is `docs/device-test-plan.md`.
|
||||
Lock-screen capture comes first because it can invalidate the product's first outcome.
|
||||
2. **STT provider.** Hosted (per-minute cost, audio leaves your network) or self-hosted Whisper
|
||||
(free, needs a machine). The adapter is the same either way.
|
||||
2. ~~STT provider.~~ Decided 2026-11-18: built into the bridge.
|
||||
3. **Target Hermes.** Which deployment and profile the bridge should point at, and a safe
|
||||
read-only test profile for the first real run.
|
||||
4. **Distribution model**, given the per-build network whitelist: one build per deployment, or a
|
||||
|
||||
@@ -13,13 +13,25 @@ should be read as Cody's assessment. The author's own checks are listed as such.
|
||||
| Repository | `git@git.xylo.gg:Xylo-Digital/hermeven.git` |
|
||||
| Base | None. The remote had no refs when work began (empty repository), so there is no base SHA. |
|
||||
| Branch | `feat/vertical-slice-1`, local only |
|
||||
| Head under review | `4687cc01147e2167997aa6a252343933070fbebd` |
|
||||
| Pushed | No. Nothing has been pushed; there is no PR. Pushing and merging are Dan's. |
|
||||
| Follow-up commit | The commit that adds this file and `docs/test-evidence.md` changes documentation only. |
|
||||
| First slice | `4687cc01147e2167997aa6a252343933070fbebd` |
|
||||
| Head under review | The tip of the remote branch `cody/slice-1-review`: the first slice plus built-in speech-to-text and droplet deployment files (see "Added after the first slice"). |
|
||||
| Pushed | To `cody/slice-1-review` only, at Dan's request on 2026-11-18. Dan works solo and has said no PR is needed. Nothing has been pushed to `main`. |
|
||||
|
||||
Repository instructions: there were none to follow (no `AGENTS.md`, `CLAUDE.md`, `README` or
|
||||
`CONTRIBUTING` existed). The kickoff specification was the only instruction source.
|
||||
|
||||
## Added after the first slice
|
||||
|
||||
Dan decided speech-to-text should be built into the software and that the bridge will run on a
|
||||
DigitalOcean droplet.
|
||||
|
||||
| Area | Paths |
|
||||
|---|---|
|
||||
| Built-in Whisper adapter, now the default `STT_PROVIDER` | `services/bridge/src/stt/builtinWhisper.ts`, `config.ts`, `app.ts`, `main.ts` |
|
||||
| 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`) |
|
||||
|
||||
## Changed files
|
||||
|
||||
Everything is new. 79 files at the head above.
|
||||
@@ -42,7 +54,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` | 122 passed, 0 failed (7 files) |
|
||||
| `npm test` | 130 passed, 0 failed (8 files) |
|
||||
| `npm run test:real-stt` | 4 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 |
|
||||
@@ -55,7 +68,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 | none |
|
||||
| Real STT | 4 scenarios: built-in Whisper on one clean archive recording |
|
||||
| Real model or tools | none |
|
||||
| Physical device | **none** |
|
||||
|
||||
@@ -93,15 +106,19 @@ Offered as places to look, not as findings.
|
||||
- The Hermes adapter does not yet check `/v1/capabilities` for durable idempotency at startup.
|
||||
- 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).
|
||||
- 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.
|
||||
|
||||
## Blockers and open decisions
|
||||
|
||||
| # | Item | Owner |
|
||||
|---|---|---|
|
||||
| 1 | Run `docs/device-test-plan.md`, starting with A13 (locked phone, pocket). | Dan |
|
||||
| 2 | Choose an STT provider or a self-hosted endpoint. | Dan |
|
||||
| 2 | ~~Choose an STT provider.~~ Decided: built in. Remaining: measure it on the droplet. | Dan |
|
||||
| 3 | Name the target Hermes deployment and a safe test profile. | Dan |
|
||||
| 4 | Decide whether to push this branch and open a PR. | Dan |
|
||||
| 4 | ~~Push and PR.~~ Decided: no PR; pushed to `cody/slice-1-review`. When to put it on `main` is still open. | Dan |
|
||||
| 5 | Independent architecture and security review of the head above. | Cody |
|
||||
| 6 | Distribution model given Even's per-build network whitelist. | Dan, later |
|
||||
|
||||
|
||||
+9
-2
@@ -50,8 +50,15 @@ Stated so they are not mistaken for protections.
|
||||
with developer access to the app's storage, can use it until it is revoked.
|
||||
2. **Renewal needs only the current token.** A thief who renews before the owner notices keeps
|
||||
access until revoked or until the 90-day pairing lifetime ends.
|
||||
3. **Audio leaves the device and, with a hosted STT provider, leaves your network.** A
|
||||
self-hosted Whisper endpoint avoids this. The provider's own retention is outside our control.
|
||||
3. **Audio leaves the phone for the bridge host.** With the default built-in speech model it
|
||||
goes no further. With `STT_PROVIDER=openai-compatible` it is sent to that provider, whose
|
||||
retention is outside our control.
|
||||
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.
|
||||
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.
|
||||
|
||||
+4
-2
@@ -1,7 +1,8 @@
|
||||
# Setup
|
||||
|
||||
Requirements: Node.js 22.13 or later, a Hermes install with the API server enabled, and (for
|
||||
voice) an OpenAI-compatible transcription endpoint.
|
||||
Requirements: Node.js 22.13 or later and a Hermes install with the API server enabled. Speech
|
||||
recognition is built into the bridge (Whisper on the CPU, about 0.8 GB of memory); the first
|
||||
start downloads about 80 MB of model files into `data/models`.
|
||||
|
||||
```sh
|
||||
npm ci
|
||||
@@ -98,4 +99,5 @@ npm run typecheck
|
||||
npm test # unit + integration, fakes only
|
||||
npm run test:simulator # needs a desktop session; opens the simulator window
|
||||
npm run test:real-hermes # needs the hermes CLI; uses a throwaway HERMES_HOME and a stub model
|
||||
npm run test:real-stt # runs the built-in Whisper model; first run downloads it
|
||||
```
|
||||
|
||||
+54
-4
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user