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.
+70
View File
@@ -0,0 +1,70 @@
# 0006: Spoken answers through the page, switched on by hand
Date: 2026-11-29. Status: built for trial (0.5.0), not reviewed, not on the device.
## What Dan asked for
> "Pivot time - I'd like to get the voice thing going for the ability to get spoken replies back
> in my galaxy pro ear buds when they're connected. Part of the scope in
> https://git.xylo.gg/Xylo-Digital/hermeven/issues/1"
Earlier (2026-11-28) he had described the eventual shape: the phone or app detecting Android
Auto or a Bluetooth headset "so that the agents can use their elevenlab voices and return their
responses into a speaker as well as on screen."
## What the sound check showed (0.4.1, Dan's phone, 2026-11-29)
Reported by Dan from the Sound check section, earbuds connected; full text in
`docs/evidence/device/2026-11-29.md`.
| Question | Result |
|---|---|
| Can the page play sound, and where is it heard? | Yes; in the earbuds |
| Without a touch on the phone? | "allowed" |
| 20 s after a press? | Played |
| The phone's own voice (`speechSynthesis`)? | "not available in this page" |
| Which outputs can the page see? | "1. without names" |
So: the existing page can play sound and Android routes it; a voice has to be made somewhere
else; and the page cannot know whether earbuds are connected.
## Decision
1. **No native companion yet.** Issue #1 proposes one for route awareness. The page can already
do the playing, and Android's own routing satisfies the issue's rule of never forcing a
route. What the page cannot do is *know* the route, which is item 2.
2. **Voice is a switch on the opening menu, off at every launch.** Proposed to Dan as the
consequence of the last row above; his answer: "yes on the voice menu entry, cap it". It is
not saved, so a forgotten setting cannot speak from the loudspeaker next time.
3. **ElevenLabs, called by the bridge.** Dan named it. The key stays on the server; the app
receives audio only. One voice id per agent (`HERMEVEN_AGENT_<ID>_VOICE`); an agent without
one is not read.
4. **Capped.** Asked "speak the whole thing, or cap it (say the first 60 seconds)", Dan: "cap
it". Implemented as characters, not seconds: 900 by default, cut at a sentence end. 900
characters is roughly a minute at an ordinary speaking rate; **that equivalence is an
estimate and has not been measured with any voice.**
5. **Speech is of a turn, not of text.** `GET /v1/turns/{id}/speech` reads only the caller's
own finished answer. There is no endpoint that speaks arbitrary text, so a device credential
cannot be used as a general speech account.
6. **Stopping.** Reading stops when the answer leaves the screen (double tap, a new question by
tap, name or typing) or Voice is switched off. Turning the page does not stop it. The app
does not leave the glasses while it is reading.
## Not done, on purpose
- Detecting earbuds, the car, or "worn". Not possible from the page; issue #1 remains open for it.
- Audio focus (pausing music, ducking), Android Auto behaviour, phone calls. Untested.
- Streaming the audio as it is generated. The whole clip is fetched, then played.
- A marker on the glasses that Voice is on outside the menu.
- Reading questions back, or any speech not tied to an answer.
## Risks to judge
- **Answers now go to a third party** when Voice is on (security 3g).
- **The loudspeaker case** (security 3h).
- **Cost** is per character at ElevenLabs. Bounded per device by the cap and six syntheses a
minute; not bounded per day.
- **MP3 decoding and playback in the Even app's WebView is untested.** The sound check played a
generated tone, not a decoded file.
- **The provider's API** was written from its documentation as read on 2026-11-29 and has never
been called by this code. The tests use a fake that imitates the documented request.
+20
View File
@@ -94,6 +94,26 @@ If A13 fails, stop and report it. It is a product-level blocker, not a bug to wo
| D9 | In Agents, tap and speak a long sentence slowly. | Do words appear while speaking? How far behind? Do they jump or flicker? | Live preview on a real G2 and the real server. |
| D10 | After sending, watch the screen. | Does "Heard: ..." show what you said? Seconds from tap to "thinking" compared with 0.3.0. | Whether a running preview delays the real transcription noticeably. |
## E. Spoken answers (0.5.0; nothing here has been run)
Needs an ElevenLabs key and a voice per agent in `/etc/hermeven/bridge.env`. Record the phone,
Android version, Even app version, earbud model, and for every row which outputs were
**connected**, which was **selected** in Android, and whether anything was **worn**: the app
cannot tell these apart and neither can this plan unless they are written down.
| # | Do | Record | Answers |
|---|---|---|---|
| E0 | Open the app with the bridge configured. | Does the menu show a third entry, "Voice: off"? Does a tap change it to "Voice: on" and stay on the menu? | The menu entry on a real G2. |
| E1 | Voice on, earbuds in and selected. Agents, ask a short question. | Is the answer heard, in the earbuds, in the right voice? Seconds from the answer appearing to the voice starting. | MP3 playback in the Even app; routing; latency. |
| E2 | Ask each agent. | Right voice for each? An agent without a voice stays silent? | Per-agent voices. |
| E3 | While it is speaking: swipe; then double tap; then (next answer) tap. | Does a swipe leave it speaking, and the others stop it at once? | Stopping. |
| E4 | Ask for something long. | Does the voice stop at a sentence after roughly a minute while the text continues on the glasses? | The cap. |
| E5 | Voice on, hands free, phone locked in a pocket. "Wendy, ...". | Is it spoken? Does a second "Wendy, ..." during the speech work, and does the speech stop? | Unattended playback; the microphone while speaking. |
| E6 | Voice on, earbuds out. Ask. | Where is it heard? | 3h above: the loudspeaker case. |
| E7 | Earbuds in, a call or music playing. Ask. | What happens to the music? Is the answer audible? | Audio focus (not handled by the app). |
| E8 | Close and reopen the app. | Is Voice off again? | Not remembered. |
| E9 | In Agents with Voice on, ask and do nothing. | Does the app stay on the glasses until the voice ends, then leave after the usual wait? | Idle exit while speaking. |
## Reporting
Anything that fails in A13, A14, A15 or C1 is a blocker or a stated limitation of the product, to
+44
View File
@@ -0,0 +1,44 @@
# 0.4.1 on the server and the phone: the sound check, 2026-11-29
**Whose evidence this is.** Server facts are the implementer's (Claude's) own commands and the
bridge's replies. What happened on the phone is Dan's report, quoted. Nothing on the device was
seen or heard by the implementer.
## Deployment and upload
Cody, Round 23: SHIP / SHIP FOR TRIAL on `d65beeab77288049b801e4969ac9b68821833b23`. Told what a
"go" would do (deploy the bridge, then build, upload and promote 0.4.1), Dan: "go".
| Step | Result |
|---|---|
| `git archive d65beea` to `/root/hermeven-src`, `deploy/install.sh --bridge-url https://hermeven.xylo.gg` | All seven steps. `DEPLOYED_SHA` is `d65beeab77288049b801e4969ac9b68821833b23` (was `e4c102a`). |
| `systemctl restart hermeven-bridge`, 19:50 UTC | active; `stt.ready` in 2.4 s; healthz ok at `https://hermeven.xylo.gg`. No turn had been accepted in the 90 s before. Hermes was not restarted. `/etc/hermeven/bridge.env` was not changed. |
| Smoke test with a temporary device (`smoke-0.4.1`, revoked afterwards; 401 after revocation) | The repository's 11 s archive speech clip to `/v1/wake` (200, 1.79 s) and `/v1/transcribe` (200, 2.74 s). The log gained one `wake.checked` (`audio_ms` 11001, `check_ms` 1522, `matched` false, `near_miss` false) and one `preview.done` (`audio_ms` 11001, `preview_ms` 2543, `empty` false). No word of the transcript in the log. |
| Package | `hermeven.ehpk`, 106,593 bytes, SHA-256 `8e231e8c215cdd76f956204dd6abb39ca6094f8b33d061866b901d8a3ec1c33a`, built twice from `d65beea` with a clean tree: the hash Cody recorded. |
| Even account | `evenhub upload` 0.4.1, `evenhub promote 0.4.1 --to beta`. `evenhub ls`: 0.4.1 Private, beta; 0.4.0 no longer on a channel. |
## What Dan reported
Asked to press the four buttons with the earbuds in and connected, to lock the phone after the
second, and to say what the lines read. His whole reply:
> "1. yes, in buds, 2. yes, in 20s, 3. nothing happened with this button, 4. without touching
> phone: allowed, outpush this page can see 1. without names, test sound at 11:51, dleayed sound
> 11:52, phone voice: not available in this page"
| Establishes | |
|---|---|
| A page in the Even app can play Web Audio, and it was heard in the earbuds | Yes (item 1). |
| Without a touch | The page reported "allowed": the sound engine was running when the page opened. |
| 20 s after a press | Played (item 2). **Whether the phone was locked at the time was not said.** |
| `speechSynthesis` | Not available in that WebView. |
| Output devices visible to the page | One, unnamed. The page cannot tell earbuds from the loudspeaker. |
Not established: the phone model, Android version, Even app version, the earbud model beyond
Dan's earlier "galaxy pro ear buds", whether the earbuds were worn, what was selected in Android,
behaviour with the phone locked or the Even app in the background, behaviour with no earbuds,
with the car, or with other audio playing, and whether a decoded MP3 plays as the tone did.
The single recording in Agents that was also asked for (to see whether the glasses request live
words) had not been made when the log was read at 19:54 UTC: no request from the glasses had
arrived since the restart.
+16
View File
@@ -94,6 +94,22 @@ Stated so they are not mistaken for protections.
touch) and asks the browser which media devices exist; output names, if the browser gives
them, are shown on the page only. It plays a tone or the phone's own voice only when a button
on the page is pressed. It sends nothing to the bridge and records nothing.
3g. **With Voice switched on (0.5.0), answers leave your infrastructure.** Until now nothing
but the agent's own model calls did. When the bridge has an ElevenLabs key and the user has
switched "Voice" on (a menu entry on the glasses, off at every launch), the app asks the
bridge for the speech of each answer and the bridge sends that answer's text, with markup
removed and cut to 900 characters, to ElevenLabs, which returns audio. What ElevenLabs keeps
is governed by its terms and the account's settings, not by this code. Questions are not
sent; only answers. The key is in `/etc/hermeven/bridge.env` and is never sent to the app.
A client can only obtain speech for its own finished turns, at most six new ones a minute,
so a stolen device credential cannot use the account to speak arbitrary text.
3h. **Where the sound comes out is not known to the app.** A page in the Even app cannot tell
which output Android is using (measured on Dan's phone, 2026-11-29: one output, no name). With
Voice on and no earbuds connected, the answer is spoken from the phone's loudspeaker, to
whoever is nearby. Voice is therefore never on by default and is not remembered.
3i. **Shutdown now closes every connection** (`forceCloseConnections`). Before, a request the
app had given up on could keep the bridge from stopping until systemd killed it after 20 s.
A request cut off by a shutdown is retried by the app as after any other network failure.
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.