Answers read aloud: Voice on the menu, ElevenLabs voices per agent via the bridge (0.5.0)

- bridge: GET /v1/speech (which agents have a voice) and GET /v1/turns/{id}/speech (MP3 of the
  caller's own finished answer, markup removed, first 900 characters). ElevenLabs adapter; key
  and voice ids from the environment; per-device budget; last three clips kept in memory.
  speech.done / speech.failed log ids, lengths and durations only.
- bridge: forceCloseConnections. A request the client had abandoned kept shutdown waiting for
  ever (also true of /v1/transcribe as deployed). Regression test for both routes.
- client: 'Voice: off/on' on the opening menu when the bridge offers it and the page can play
  sound; off at every launch. With it on, a finished answer is fetched and played; it stops
  when the answer leaves the screen; the app does not leave the glasses while it plays.
- tests: fake provider, fake loudspeaker (tests/integration/voice.test.ts).
- docs: 0006, security 3g-3i, device plan E, 0.4.1 rollout and Dan's sound check report.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-29 12:11:38 -08:00
co-authored by Claude Fable 5.2
parent d65beeab77
commit 9874e1bb5b
25 changed files with 1199 additions and 17 deletions
+4
View File
@@ -23,6 +23,8 @@ Every error has the shape:
| `POST /v1/turns` | Create one turn (text or audio). | 202, or 200 for a duplicate |
| `POST /v1/wake` | One stretch of speech heard while the app was open (raw audio body, same format as an audio turn; query: `schema_version`, `locale`, `encoding`, `sample_rate`, `channels`). Transcribed in memory and dropped. Answers `{matched, agent_id, text, near_miss}`: whether it **began** with an agent's name, which agent, and what was said after the name (empty for the name alone). When not matched `text` is always empty; `near_miss` is the first word if it was close to a name. Creates no turn and sends nothing to any agent. 404 `not_found` when speech-to-text is off or no agent has a usable name (also what an older bridge answers); 429 `rate_limited` over `HERMEVEN_WAKE_CHECKS_PER_MINUTE` (default 30) or while this device's previous check is still running. A failed transcription is answered as not matched. | 200 |
| `POST /v1/transcribe` | The words in a recording that is still being made, for showing while the user speaks. Same body and query as `/v1/wake`. Answers `{text}` (empty if nothing was recognised or transcription failed). Transcribed in memory and dropped; creates no turn, sends nothing to any agent, logs no text. 404 `not_found` when speech-to-text is off (also what an older bridge answers); 429 `rate_limited` over `HERMEVEN_PREVIEWS_PER_MINUTE` (default 60) or while this device's previous preview is still running. | 200 |
| `GET /v1/speech` | Whether answers can be read aloud: `{available, agent_ids, max_chars}`. `available` is false (and the list empty) unless the bridge has a speech provider key and at least one agent has a voice. Added in 0.5.0: an older bridge answers 404 `not_found`, which a client must treat as "not available". | 200 |
| `GET /v1/turns/{request_id}/speech` | The answer of one of this device's own finished turns (`succeeded` or `incomplete`), read aloud in its agent's voice. **The response is `audio/mpeg`, not JSON.** The text is the answer with markup, code blocks and web addresses removed, cut to `HERMEVEN_SPEECH_MAX_CHARS` (default 900) at the end of a sentence where one is near; it is sent to the speech provider (ElevenLabs). Neither text nor audio is stored or logged; the last three are kept in memory so a repeat is not paid for twice. There is no way to have other text spoken. 404 `not_found` for an unknown, foreign or unfinished turn, an answer with nothing to read, an agent without a voice, or speech not configured (all indistinguishable); 429 `rate_limited` over `HERMEVEN_SPEECH_PER_MINUTE` (default 6) new syntheses per device; 500 `internal` "Speech could not be generated." when the provider fails (its message is never passed on). | 200 |
| `GET /v1/turns/{request_id}` | Current state and result. | 200 |
| `POST /v1/turns/{request_id}/cancel` | Request cancellation. Idempotent. | 200 |
@@ -151,6 +153,8 @@ Defaults, all configurable. These are limits, not measured performance.
| Agent deadline | 120 s, paused while an approval is pending |
| Approval wait | 300 s |
| Grace period to confirm a stop | 30 s |
| Speech provider deadline | 20 s |
| Answer read aloud | first 900 characters, 6 answers a minute per device |
No latency percentiles are published because none have been measured against a real STT
provider, a real model or a real device.