Sound check on the phone page (probe for issue #1); timing logs for name checks and previews; 0.4.1

- apps/even-client: a collapsed "Sound check" on the phone page. Finds out whether the page
  may play sound in the Even app, without a touch, in the background, and which outputs it can
  see. Plays only on a button press; sends nothing to the bridge.
- services/bridge: wake.checked (every name check) and preview.done log the clip length and the
  duration, never the words.
- tests: hands free after a recording in Agents with menu, wake and preview all on; the log
  lines carry only the fields above.
- docs: 0.4.0 rollout and Dan's device report; security 3c, 3e, 3f; 0005 records that the
  Round 20 reading of "agent sub-app" was wrong (not changed here).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-29 11:24:16 -08:00
co-authored by Claude Fable 5.2
parent e4c102a539
commit b57505406b
9 changed files with 365 additions and 5 deletions
+4 -3
View File
@@ -17,9 +17,9 @@ the implementer read from the server's log, and what Cody reproduced independent
| Path | State | | Path | State |
|---|---| |---|---|
| **What is where today** | Server (bridge and static page): `44ea1148c34a271f4fdc565ef71a145adf459b42`. Even account, beta channel: client 0.3.0, built from that commit. This repository's client is **0.4.0, a candidate: not deployed, not uploaded, not on the device.** | | **What is where today** | Server (bridge and static page): `e4c102a5391464cec6f540f5a41f5557a3f61e0b`, since 2026-11-28 21:44 UTC. Even account, beta channel: client 0.4.0, built from that commit. This repository's client is **0.4.1, a candidate: not deployed, not uploaded, not on the device.** |
| Client, bridge and contract | Implemented. | | Client, bridge and contract | Implemented. |
| Automated tests with fakes (349) | Passing. | | Automated tests with fakes (351) | Passing. |
| Client in Even's official simulator | 9 scenarios, run by the implementer, simulator only. Eight run with the menu, hands free and live preview switched off (the tap path and idle exit); the ninth launches the app as shipped and covers the menu and the microphone opening and closing for hands free, with a silent microphone, so no name is ever heard. Live preview is not exercised in the simulator. One unexplained failure of the idle-exit scenario in the Round 19 runs; see `docs/test-evidence.md`. | | Client in Even's official simulator | 9 scenarios, run by the implementer, simulator only. Eight run with the menu, hands free and live preview switched off (the tap path and idle exit); the ninth launches the app as shipped and covers the menu and the microphone opening and closing for hands free, with a silent microphone, so no name is ever heard. Live preview is not exercised in the simulator. One unexplained failure of the idle-exit scenario in the Round 19 runs; see `docs/test-evidence.md`. |
| Bridge against a real Hermes gateway | Passing (9 scenarios) with a **stub model**. | | Bridge against a real Hermes gateway | Passing (9 scenarios) with a **stub model**. |
| Built-in speech-to-text (Whisper, in the bridge) | Passing (11 scenarios) on a real speech recording, including with no network. Not yet on audio from the glasses. | | Built-in speech-to-text (Whisper, in the bridge) | Passing (11 scenarios) on a real speech recording, including with no network. Not yet on audio from the glasses. |
@@ -32,7 +32,8 @@ the implementer read from the server's log, and what Cody reproduced independent
| Leaving the glasses when idle | 0.1.1 on the device (2026-11-21, Dan's report): after one gesture the app left by itself and Telegram notifications returned to the lenses; after a voice launch with nothing touched it did **not** leave. 0.1.2 starts the countdown however the app was opened; tested with fakes and the simulator, **not installed on the device.** | | Leaving the glasses when idle | 0.1.1 on the device (2026-11-21, Dan's report): after one gesture the app left by itself and Telegram notifications returned to the lenses; after a voice launch with nothing touched it did **not** leave. 0.1.2 starts the countdown however the app was opened; tested with fakes and the simulator, **not installed on the device.** |
| More than one agent (swipe at Ready to choose) | 0.2.0. Deployed on 2026-11-22 with three agents; a question sent through the bridge was answered by a second Hermes profile (`docs/evidence/droplet/2026-11-21.md`). Installed on the device and tried by Dan, who reported "All tests check out" without detail (`docs/evidence/device/2026-11-21.md`, sixth session). The agent screens have not been run in the simulator. | | More than one agent (swipe at Ready to choose) | 0.2.0. Deployed on 2026-11-22 with three agents; a question sent through the bridge was answered by a second Hermes profile (`docs/evidence/droplet/2026-11-21.md`). Installed on the device and tried by Dan, who reported "All tests check out" without detail (`docs/evidence/device/2026-11-21.md`, sixth session). The agent screens have not been run in the simulator. |
| Opening menu (Hands free, Agents); hands-free mode: calling an agent by name ("Wendy, ...") | 0.3.0, which is what is deployed and on beta (`44ea114`). Fakes: passing. Simulator: menu and microphone open/close only (scenario 9). Device: tried by Dan on 2026-11-28, "pretty cool"; a name reached an agent and a different name switched agent. No item-by-item report; section D of the device plan has not been run. `docs/decisions/0004-always-listening.md`, `docs/evidence/device/2026-11-28.md`. | | Opening menu (Hands free, Agents); hands-free mode: calling an agent by name ("Wendy, ...") | 0.3.0, which is what is deployed and on beta (`44ea114`). Fakes: passing. Simulator: menu and microphone open/close only (scenario 9). Device: tried by Dan on 2026-11-28, "pretty cool"; a name reached an agent and a different name switched agent. No item-by-item report; section D of the device plan has not been run. `docs/decisions/0004-always-listening.md`, `docs/evidence/device/2026-11-28.md`. |
| Words shown while recording (Agents only); "Heard: ..." while the agent works | 0.4.0 candidate. Fakes only. **Not in the simulator, not deployed, not uploaded, not on the device.** `docs/decisions/0005-live-preview.md`. | | Words shown while recording (Agents only); "Heard: ..." while the agent works | 0.4.0, deployed and on beta (`e4c102a`). Fakes: passing. Not in the simulator. Device, Dan, 2026-11-28: "Heard" appears; **live words did not appear**, cause unknown; and Dan wants them in hands free, not Agents (open, not built). `docs/decisions/0005-live-preview.md`, `docs/evidence/device/2026-11-28.md`. |
| Sound check on the phone page (can the page play sound, untouched, in the background; which outputs it sees) | 0.4.1 candidate. A probe for issue #1 (spoken answers), not a feature. Typechecked and built only: **no automated test, not in the simulator, not on the device.** |
| Real tools and approval flow | One tool use seen (a Telegram message, reported by Dan). The approval path has **not** been exercised against a real agent. | | Real tools and approval flow | One tool use seen (a Telegram message, reported by Dan). The approval path has **not** been exercised against a real agent. |
| Sustained load, backups, monitoring, upgrades on the server | **Not verified.** | | Sustained load, backups, monitoring, upgrades on the server | **Not verified.** |
| Clean-host install (`deploy/install.sh`) | Proven on a disposable Ubuntu 24.04 container with systemd (`tests/deploy/runbook-proof.sh`), not on a second real server. | | Clean-host install (`deploy/install.sh`) | Proven on a disposable Ubuntu 24.04 container with systemd (`tests/deploy/runbook-proof.sh`), not on a second real server. |
+1 -1
View File
@@ -2,7 +2,7 @@
"package_id": "xylo.hermeven", "package_id": "xylo.hermeven",
"edition": "202601", "edition": "202601",
"name": "Pepper", "name": "Pepper",
"version": "0.4.0", "version": "0.4.1",
"min_sdk_version": "0.0.16", "min_sdk_version": "0.0.16",
"entrypoint": "index.html", "entrypoint": "index.html",
"permissions": [ "permissions": [
+2 -1
View File
@@ -1,5 +1,6 @@
import type { Controller, Snapshot } from '../core/controller.ts'; import type { Controller, Snapshot } from '../core/controller.ts';
import { BridgeApiError, BridgeNetworkError, normalizeBridgeUrl } from '../net/bridgeClient.ts'; import { BridgeApiError, BridgeNetworkError, normalizeBridgeUrl } from '../net/bridgeClient.ts';
import { mountSoundCheck } from './soundCheck.ts';
/** /**
* Phone-side page: pairing, status, diagnostics, typed input and disconnect. * Phone-side page: pairing, status, diagnostics, typed input and disconnect.
@@ -141,7 +142,7 @@ export function mountPhoneUi(root: HTMLElement, controller: Controller, defaults
logView, logView,
]); ]);
root.append(el('h1', { textContent: 'Hermeven' }), message, pairing, status, conversation, diagnostics); root.append(el('h1', { textContent: 'Hermeven' }), message, pairing, status, conversation, mountSoundCheck(document, window), diagnostics);
const rows = (list: HTMLElement, entries: Array<[string, string]>) => { const rows = (list: HTMLElement, entries: Array<[string, string]>) => {
list.replaceChildren(...entries.flatMap(([k, v]) => [el('dt', { textContent: k }), el('dd', { textContent: v })])); list.replaceChildren(...entries.flatMap(([k, v]) => [el('dt', { textContent: k }), el('dd', { textContent: v })]));
+187
View File
@@ -0,0 +1,187 @@
/**
* Sound check: finds out what this page is allowed to do with sound inside the Even app, before
* spoken answers are designed around it (issue #1). It answers four questions on a real phone:
*
* 1. Can the page make sound at all, and does Android send it to the earbuds or the car?
* 2. Can it make sound without anyone touching the phone (a question asked from the glasses)?
* 3. Does sound still play a while later, with the phone locked or the Even app in the background?
* 4. Can the page tell which sound outputs are connected (so it stays quiet on a bare phone)?
*
* Nothing here talks to the bridge or to any agent, nothing is recorded, and nothing plays
* unless a button on this page is pressed. Results are only shown on this page.
*
* NOT device-tested: this exists to be run on the device.
*/
type AudioContextCtor = typeof AudioContext;
function contextCtor(win: Window): AudioContextCtor | null {
const w = win as unknown as { AudioContext?: AudioContextCtor; webkitAudioContext?: AudioContextCtor };
return w.AudioContext ?? w.webkitAudioContext ?? null;
}
function node<K extends keyof HTMLElementTagNameMap>(doc: Document, tag: K, text = '', className = ''): HTMLElementTagNameMap[K] {
const n = doc.createElement(tag);
if (text) n.textContent = text;
if (className) n.className = className;
return n;
}
const DELAY_SECONDS = 20;
export function mountSoundCheck(doc: Document, win: Window): HTMLElement {
const results = new Map<string, string>();
const list = node(doc, 'dl');
const show = (key: string, value: string) => {
results.set(key, value);
list.replaceChildren(...[...results].flatMap(([k, v]) => [node(doc, 'dt', k), node(doc, 'dd', v)]));
};
const reason = (err: unknown) => (err instanceof Error ? `${err.name}: ${err.message}`.slice(0, 120) : 'unknown error');
const Ctor = contextCtor(win);
let context: AudioContext | null = null;
const getContext = (): AudioContext | null => {
if (!Ctor) return null;
try {
context ??= new Ctor();
} catch (err) {
show('Sound engine', `could not start (${reason(err)})`);
return null;
}
return context;
};
/** Two short notes. Resolves with whether the sound engine was actually running. */
async function tone(): Promise<string> {
const ctx = getContext();
if (!ctx) return 'no sound engine in this page';
try {
await Promise.race([ctx.resume(), new Promise((r) => win.setTimeout(r, 800))]);
} catch (err) {
return `blocked (${reason(err)})`;
}
if (ctx.state !== 'running') return `blocked (sound engine is ${ctx.state})`;
const gain = ctx.createGain();
gain.gain.value = 0.2;
gain.connect(ctx.destination);
[660, 880].forEach((frequency, i) => {
const osc = ctx.createOscillator();
osc.frequency.value = frequency;
osc.connect(gain);
osc.start(ctx.currentTime + i * 0.45);
osc.stop(ctx.currentTime + i * 0.45 + 0.35);
});
return 'played';
}
const stamp = () => new Date().toLocaleTimeString();
// 2. Without a touch: asked once when the page opens. Silent; it only reads the engine's state.
void (async () => {
const ctx = getContext();
if (!ctx) {
show('Without touching the phone', 'no sound engine in this page');
return;
}
try {
await Promise.race([ctx.resume(), new Promise((r) => win.setTimeout(r, 800))]);
} catch {
// The state below says what happened.
}
show('Without touching the phone', ctx.state === 'running' ? 'allowed' : `not allowed until a button here is pressed (${ctx.state})`);
})();
// 1. A sound now.
const playButton = node(doc, 'button', 'Play test sound', 'secondary');
playButton.type = 'button';
playButton.addEventListener('click', () => {
void tone().then((outcome) => show('Test sound', `${outcome} at ${stamp()}`));
});
// 3. A sound later, with nobody touching anything at that moment.
const laterButton = node(doc, 'button', `Play again in ${DELAY_SECONDS} s`, 'secondary');
laterButton.type = 'button';
laterButton.addEventListener('click', () => {
laterButton.disabled = true;
show('Delayed sound', `waiting since ${stamp()}; lock the phone or leave the app now`);
const due = Date.now() + DELAY_SECONDS * 1000;
win.setTimeout(() => {
const lateMs = Date.now() - due;
void tone().then((outcome) => {
show('Delayed sound', `${outcome} at ${stamp()}${lateMs > 1500 ? `, ${Math.round(lateMs / 1000)} s late` : ''}`);
laterButton.disabled = false;
});
}, DELAY_SECONDS * 1000);
});
// The phone's own voice, as a free fallback to a paid one.
const speakButton = node(doc, 'button', 'Speak with the phone’s voice', 'secondary');
speakButton.type = 'button';
speakButton.addEventListener('click', () => {
const synth = win.speechSynthesis;
const Utterance = (win as unknown as { SpeechSynthesisUtterance?: typeof SpeechSynthesisUtterance }).SpeechSynthesisUtterance;
if (!synth || !Utterance) {
show('Phone voice', 'not available in this page');
return;
}
try {
const utterance = new Utterance('This is the Hermeven sound check.');
utterance.onend = () => show('Phone voice', `spoke at ${stamp()} (${synth.getVoices().length} voices)`);
utterance.onerror = (event) => show('Phone voice', `failed (${event.error})`);
show('Phone voice', 'asked to speak…');
synth.speak(utterance);
} catch (err) {
show('Phone voice', `failed (${reason(err)})`);
}
});
// 4. What the page can see of the sound outputs.
async function outputs(): Promise<void> {
const media = win.navigator.mediaDevices;
if (!media?.enumerateDevices) {
show('Outputs this page can see', 'none: the page is not told about sound devices');
return;
}
try {
const devices = await media.enumerateDevices();
const out = devices.filter((d) => d.kind === 'audiooutput');
const named = out.map((d) => d.label).filter(Boolean);
show(
'Outputs this page can see',
out.length === 0
? `none (of ${devices.length} devices listed)`
: named.length
? `${out.length}: ${named.join(' · ').slice(0, 300)}`
: `${out.length}, without names`,
);
} catch (err) {
show('Outputs this page can see', `could not ask (${reason(err)})`);
}
}
const outputsButton = node(doc, 'button', 'List outputs', 'secondary');
outputsButton.type = 'button';
outputsButton.addEventListener('click', () => void outputs());
try {
win.navigator.mediaDevices?.addEventListener?.('devicechange', () => {
show('Output change noticed', stamp());
void outputs();
});
} catch {
// Not supported here: the button still works.
}
void outputs();
const row = node(doc, 'div', '', 'row');
row.append(playButton, laterButton, speakButton, outputsButton);
const details = node(doc, 'details');
details.append(
node(doc, 'summary', 'Sound check'),
node(
doc,
'p',
'For finding out whether answers can be spoken through your earbuds or car. Nothing is recorded or sent anywhere, and nothing plays unless you press a button here.',
'hint',
),
row,
list,
);
return details;
}
+15
View File
@@ -52,3 +52,18 @@ sub-app only ("I'd only invoke the live transcription when in agent sub-app"). T
ruled out sending the hands-free listener's audio to a paid service. So if a paid recogniser is ruled out sending the hands-free listener's audio to a paid service. So if a paid recogniser is
adopted it serves the Agents preview (and possibly the final transcript there); hands free stays adopted it serves the Agents preview (and possibly the final transcript there); hands free stays
on the bridge's own Whisper. on the bridge's own Whisper.
## 2026-11-28, after 0.4.0 reached the glasses: the Round 20 reading was wrong
Dan, asked whether recordings he starts in hands free should also show live words:
> "That's honestly the only exact way it was supposed to work... LOL. That was literally the
> only time i wanted to see live words."
So "agent sub-app" meant talking to an agent in hands free, and "the main menu listener" meant
the background listening for a name. 0.4.0 does the reverse of what he wanted: previews in the
Agents entry, none in hands free. **Not changed yet**: Dan also reported that live words did not
appear in Agents on the device, and that has to be understood first, since the same code would
be used. Open design point: "Wendy, what is on my calendar" in one breath is a single utterance
checked for a name only when it ends, so there is no recording in progress to preview; showing
words there means checking the speech so far for a name while it is being said.
+62
View File
@@ -37,3 +37,65 @@ Not reported: which agents, how many attempts or misses, any near miss in Diagno
itself, the name-alone flow, the delay, false triggers, noise, battery, the locked phone, itself, the name-alone flow, the delay, false triggers, noise, battery, the locked phone,
notifications while open, or Agents mode. Section D of `docs/device-test-plan.md` has not been notifications while open, or Agents mode. Section D of `docs/device-test-plan.md` has not been
run as a checklist. run as a checklist.
# 0.4.0 on the server and the glasses, 2026-11-28 (later the same day)
Same rule: server facts are the implementer's own commands and the bridge's log; what happened
on the glasses is Dan's report, quoted. Nothing on the device was seen by the implementer.
## Deployment and upload
Cody, Round 20: SHIP / SHIP FOR TRIAL on `e4c102a5391464cec6f540f5a41f5557a3f61e0b`. Told that a
"go" would deploy the bridge and then build, upload and promote 0.4.0, Dan: "deploy". The
implementer took that as covering both steps and said so in the report afterwards; Dan did not
object.
| Step | Result |
|---|---|
| `git archive e4c102a` to `/root/hermeven-src`, `deploy/install.sh --bridge-url https://hermeven.xylo.gg` | Completed. `DEPLOYED_SHA` is `e4c102a5391464cec6f540f5a41f5557a3f61e0b` (was `44ea114`). |
| `systemctl restart hermeven-bridge`, 21:44:53 UTC | active; `stt.ready` in 2.1 s; healthz ok at `https://hermeven.xylo.gg`. Hermes was not restarted. `/etc/hermeven/bridge.env` was not changed. |
| Smoke test with a temporary device (`smoke-0.4.0`, revoked afterwards; 401 after revocation) | `POST /v1/transcribe` with the repository's 11 s archive speech clip: 200, the correct sentence, 2.16 s. Without a credential: 401. `POST /v1/wake` with the same clip: 200, `matched: false`. No word of the transcript in the bridge log. A first attempt failed in the implementer's own script (it could not parse the pairing code, which it then printed; that code was never claimed and was voided by the next one). |
| Package | `hermeven.ehpk`, 105,155 bytes, SHA-256 `311078550ed1a176b9a1530cced0c81a322b40e83ecdc9b21402fb08b1ebe58d`, built twice from `e4c102a` with a clean tree; the hash recorded in Round 20. |
| Even account | `evenhub upload` 0.4.0, `evenhub promote 0.4.0 --to beta`. `evenhub ls`: 0.4.0 Private, beta; 0.3.0 no longer on a channel. |
## What Dan reported, in order, and what the bridge log shows
1. "Looks like we broken the listener in hands-free mode. when i say "pepper" or "wendy" or
anything, nothing happens." Then: "responses are much slower now too when I use the ring touch
to record and send a message." Then: "it works when i'm in the agent session, but at the
start, it didn't seem to." Then: "it was the hands-free ready screen - Where it says ,
"Listing. Say a name... etc..." Oh, it's incredibliy slow now is all..." Asked whether there
was more background sound than in the afternoon: "yeah, could very well be the background
music playing... Yeah, that was it."
2. "So, whisper isn't putting live text up really at all., I just randomly talked for 10
secdonds, and it flashes "heard" with the text after, but nothing live." Told that live words
are for Agents only and how to reach them: "live words don't work as you suggested." And, on
whether recordings in hands free should show live words: "That's honestly the only exact way it
was supposed to work... LOL. That was literally the only time i wanted to see live words."
Bridge log, 21:48 to 22:02 UTC (states and timings only; the deployed bridge does not log name
checks that do not match, or previews):
| | |
|---|---|
| Name checks that matched | 21:50:32, 21:52:20, 21:53:46, 21:56:41, 21:58:38 (Pepper), 21:55:50 (Cody). Each was answered 1.9 to 3.0 s after the match. |
| Recorded (tapped) questions | Seven. Transcription 0.9 to 2.3 s. Agent time 1.9 to 8.4 s, except the first two, 39.9 s and 24.0 s. |
| Warnings or errors | None. |
| Establishes | |
|---|---|
| Hands free still works on 0.4.0 | Yes: six matches. |
| Background music delays the name listener | Dan's report and his own explanation. Consistent with the design (an utterance ends on 0.7 s below the level learned while nobody speaks, or at 30 s). **How long the waits were is not known**: nothing recorded it. |
| "Heard: ..." for a tapped recording | Seen by Dan. |
| Live words on the device | **Not seen**, in hands free (by design in 0.4.0) or, by Dan's last report, in Agents. **Cause unknown.** Whether the glasses requested any preview is not known: the implementer watched the bridge's loopback port for four minutes (22:02:30 to 22:06:55 UTC; request line and status only) but Dan made no recording in that time. |
| What Dan meant by "agent sub-app" in Round 20 | Talking to an agent in hands free, not the Agents menu entry. Round 20 implemented the opposite reading. Not changed in this round. |
Not established: the cause of the two slow answers (agent time, so not transcription; not
investigated), and anything in section D or D9/D10 of the device plan as a checklist.
Read-only inspection of the server made by the implementer for this, beyond `journalctl`:
`tcpdump -i lo -s 96` on port 8787, filtered to packets starting `POST` or `HTTP`, piped to a
filter that printed only the time, `POST /v1/<path>` and the status code; once for 240 s and once
for 8 s (to prove it worked, with the implementer's own unauthenticated request, which showed
`POST /v1/transcribe` then `401`). Nothing was written to disk on the server; 96 bytes per packet
do not reach the headers.
+9
View File
@@ -76,6 +76,9 @@ Stated so they are not mistaken for protections.
transcription call and is not logged. That is a promise about this code, not a technical transcription call and is not logged. That is a promise about this code, not a technical
barrier: whoever controls the bridge host could record it. People near the wearer are not barrier: whoever controls the bridge host could record it. People near the wearer are not
told. The HUD marks the open microphone with `●`; nothing outside the lenses does. told. The HUD marks the open microphone with `●`; nothing outside the lenses does.
From 0.4.1 the bridge logs, for every check, the clip's length, how long the check took and
whether it matched or nearly matched (`wake.checked`); never the words. So the log shows
when and for how long someone spoke near the glasses in hands-free mode.
3d. **In hands-free mode an agent can be started without a button.** Speech that begins with an agent's name is sent 3d. **In hands-free mode an agent can be started without a button.** Speech that begins with an agent's name is sent
to that agent with whatever tools its Hermes profile allows, with no confirmation. A name is to that agent with whatever tools its Hermes profile allows, with no confirmation. A name is
matched exactly and only as the first word, and what was heard is shown while the agent matched exactly and only as the first word, and what was heard is shown while the agent
@@ -85,6 +88,12 @@ Stated so they are not mistaken for protections.
so far, about twice a second) so its words can be shown. This is audio the user chose to so far, about twice a second) so its words can be shown. This is audio the user chose to
record, going where the finished recording goes anyway; the text is returned to the app and record, going where the finished recording goes anyway; the text is returned to the app and
not logged. A cancelled recording has therefore already reached the bridge, in memory only. not logged. A cancelled recording has therefore already reached the bridge, in memory only.
From 0.4.1 each preview's length and duration are logged (`preview.done`), not its words.
3f. **The phone page has a "Sound check" (0.4.1)**, a probe for spoken answers. It creates a
Web Audio context when the page opens (silently, to see whether sound is allowed without a
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.
4. **In the simulator, raw audio frames are echoed to the WebView console.** Whether the phone 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 does the same is unknown and is on the device checklist. If it does, recordings would be
visible to whoever can read that console. visible to whoever can read that console.
+23
View File
@@ -346,9 +346,25 @@ export async function buildServer(deps: ServerDeps): Promise<FastifyInstance> {
wakeBusy.add(device.id); wakeBusy.add(device.id);
const abort = new AbortController(); const abort = new AbortController();
const timer = setTimeout(() => abort.abort(), config.limits.transcribeDeadlineSeconds * 1000); const timer = setTimeout(() => abort.abort(), config.limits.transcribeDeadlineSeconds * 1000);
const startedAt = Date.now();
// How long the clip was and how long it took, for every check, matched or not. Never what
// was said: without this a slow or silent hands-free session cannot be told apart from a
// microphone that hears nothing.
const checked = (matched: boolean, nearMiss: boolean) =>
req.log.info(
{
device_id: device.id,
audio_ms: Math.round((pcm.length / AUDIO_FORMAT.bytesPerSecond) * 1000),
check_ms: Date.now() - startedAt,
matched,
near_miss: nearMiss,
},
'wake.checked',
);
try { try {
const transcript = await deps.stt.transcribe({ pcm, locale, signal: abort.signal }); const transcript = await deps.stt.transcribe({ pcm, locale, signal: abort.signal });
const match = matchWake(transcript, config.agents); const match = matchWake(transcript, config.agents);
checked(match.matched, !match.matched && match.nearMiss !== null);
if (!match.matched) return { ...none, near_miss: match.nearMiss }; if (!match.matched) return { ...none, near_miss: match.nearMiss };
req.log.info({ device_id: device.id, agent_id: match.agentId, name_only: match.text === '' }, 'wake.matched'); req.log.info({ device_id: device.id, agent_id: match.agentId, name_only: match.text === '' }, 'wake.matched');
return { ...none, matched: true, agent_id: match.agentId, text: match.text.slice(0, config.limits.textMaxChars) }; return { ...none, matched: true, agent_id: match.agentId, text: match.text.slice(0, config.limits.textMaxChars) };
@@ -383,7 +399,14 @@ export async function buildServer(deps: ServerDeps): Promise<FastifyInstance> {
if (!reply.raw.writableEnded) abort.abort(); if (!reply.raw.writableEnded) abort.abort();
}); });
try { try {
const startedAt = Date.now();
const text = await deps.stt.transcribe({ pcm, locale, signal: abort.signal }); const text = await deps.stt.transcribe({ pcm, locale, signal: abort.signal });
// Length and duration only, never the words: this is how the delay a preview can add to
// the real transcription gets measured.
req.log.info(
{ device_id: device.id, audio_ms: Math.round((pcm.length / AUDIO_FORMAT.bytesPerSecond) * 1000), preview_ms: Date.now() - startedAt, empty: text.trim() === '' },
'preview.done',
);
return { schema_version: SCHEMA_VERSION, text: text.trim().slice(0, config.limits.textMaxChars) }; return { schema_version: SCHEMA_VERSION, text: text.trim().slice(0, config.limits.textMaxChars) };
} catch (err) { } catch (err) {
// No preview this time. The recording itself is unaffected. // No preview this time. The recording itself is unaffected.
+62
View File
@@ -68,6 +68,14 @@ describe('bridge: POST /v1/wake', () => {
const logs = h.logs.join('\n'); const logs = h.logs.join('\n');
for (const fragment of ['card number', 'four one one', 'wendi', 'Wendi']) expect(logs).not.toContain(fragment); for (const fragment of ['card number', 'four one one', 'wendi', 'Wendi']) expect(logs).not.toContain(fragment);
expect(logs).toContain('wake.matched'); expect(logs).toContain('wake.matched');
// Every check leaves its length and duration, and nothing else.
const checks = h.logs.filter((l) => l.includes('wake.checked')).map((l) => JSON.parse(l));
expect(checks.map((c) => [c.matched, c.near_miss])).toEqual([[false, false], [false, false], [false, true], [true, false]]);
for (const c of checks) {
expect(typeof c.audio_ms).toBe('number');
expect(typeof c.check_ms).toBe('number');
expect(Object.keys(c).filter((k) => !['level', 'time', 'pid', 'hostname', 'reqId', 'msg', 'device_id', 'audio_ms', 'check_ms', 'matched', 'near_miss'].includes(k))).toEqual([]);
}
}); });
it('needs a device credential and a well-formed request', async () => { it('needs a device credential and a well-formed request', async () => {
@@ -680,3 +688,57 @@ describe('glasses: words shown while recording', () => {
expect(h.stt.calls).toBe(3); expect(h.stt.calls).toBe(3);
}); });
}); });
describe('glasses: hands free after using Agents (as shipped: menu, wake and live preview together)', () => {
beforeEach(async () => {
sent = [];
wakeRoute = 'real';
extras = { menu: true, idleExit: null, livePreview: { firstMs: 300, stepMs: 300, pauseMs: 200 } };
await harness();
});
afterEach(async () => {
await controller?.stop();
});
it('a recording in Agents, then back to the menu and into Hands free: a name is still heard', async () => {
device = new FakeDevice();
controller = makeController(device);
await controller.start();
await controller.pair(h.url, h.bridge.devices.createPairingCode().code, 'fake-g2');
expect(phase()).toBe('menu');
device.swipeDown();
device.tap(); // Agents
expect(phase()).toBe('ready');
h.stt.next({ text: 'a tapped' }, { text: 'A tapped question.' });
device.tap();
await until('recording', () => phase() === 'listening' && device.micOpen);
device.speak(0.5);
await until('preview', () => device.frame.body.includes('a tapped'));
device.tap();
await until('answer', () => phase() === 'answer');
await until('microphone closed', () => !device.micOpen);
device.doubleTap(); // answer -> Ready
device.doubleTap(); // Ready -> menu
expect(phase()).toBe('menu');
device.swipeUp();
device.tap(); // Hands free
expect(phase()).toBe('ready');
await listening();
h.stt.next({ text: 'Wendy, hello' });
say();
await until('answer', () => phase() === 'answer');
expect(h.hermes.executedBy).toEqual([null, 'wendy']);
});
it('straight into Hands free: a name is heard', async () => {
device = new FakeDevice();
controller = makeController(device);
await controller.start();
await controller.pair(h.url, h.bridge.devices.createPairingCode().code, 'fake-g2');
device.tap();
await listening();
h.stt.next({ text: 'Pepper, hello' });
say();
await until('answer', () => phase() === 'answer');
});
});