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:
@@ -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.
|
||||
Reference in New Issue
Block a user