Words on the glasses while recording, and "Heard:" for spoken questions (0.4.0)
While a recording is being made the app sends the recording so far to a new bridge route, POST /v1/transcribe, about every half second of new audio and one request at a time, and draws the words under "... is listening…", newest words kept in view. No new service: it is the Whisper already in the bridge. A preview is only ever drawn. The question is transcribed again by its own turn, so a preview can never be what the agent receives. After sending, the last preview stays under "Transcribing…", then "Heard:" shows the transcript the bridge gave the agent, now for every spoken question (it was hands free only). The reducer tracks `spoken` explicitly and treats an accepted, not yet transcribed recording as transcribing. Bridge: /v1/transcribe needs a device credential, shares the audio checks with /v1/wake, runs one at a time per device within HERMEVEN_PREVIEWS_PER_MINUTE (60), creates nothing and logs no text. An older bridge answers 404 and the client stops asking. Simulator: a scenario that launches the app as shipped (menu, hands free) as Round 18 required. A diagnostics note marks when listening for a name starts and stops. Also records the 0.3.0 deployment, upload and Dan's device report (docs/evidence/device/2026-11-28.md), and decision 0005. Not reviewed, not deployed, not uploaded, not device-tested. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -525,3 +525,148 @@ describe('glasses: the opening menu', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('bridge: POST /v1/transcribe', () => {
|
||||
const clip = (token: string | undefined, said: string) => {
|
||||
h.stt.next({ text: said });
|
||||
return h.api('POST', `/v1/transcribe?${wakeQuery()}`, { token, body: syntheticPcm(1) });
|
||||
};
|
||||
|
||||
it('returns the words, creates nothing, and logs none of them', async () => {
|
||||
await harness();
|
||||
const { token } = await h.pair();
|
||||
const res = await clip(token, ' what is on my calendar ');
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body).toEqual({ schema_version: SCHEMA_VERSION, text: 'what is on my calendar' });
|
||||
expect(h.hermes.requests.filter((r) => r.method === 'POST')).toEqual([]);
|
||||
expect(h.logs.join('\n')).not.toContain('calendar');
|
||||
});
|
||||
|
||||
it('needs a credential and well-formed audio; a failed transcription is an empty preview; no speech-to-text is not_found', async () => {
|
||||
await harness();
|
||||
const { token } = await h.pair();
|
||||
expect((await h.api('POST', `/v1/transcribe?${wakeQuery()}`, { body: syntheticPcm(1) })).status).toBe(401);
|
||||
expect((await h.api('POST', `/v1/transcribe?${wakeQuery({ channels: '2' })}`, { token, body: syntheticPcm(1) })).status).toBe(400);
|
||||
expect((await h.api('POST', `/v1/transcribe?${wakeQuery()}`, { token, body: Buffer.alloc(5) })).status).toBe(400);
|
||||
h.stt.next({ status: 500 });
|
||||
expect((await h.api('POST', `/v1/transcribe?${wakeQuery()}`, { token, body: syntheticPcm(1) })).body).toEqual({ schema_version: SCHEMA_VERSION, text: '' });
|
||||
await h.close();
|
||||
await harness(AGENT_ENV, { stt: false });
|
||||
expect((await h.api('POST', `/v1/transcribe?${wakeQuery()}`, { token: (await h.pair()).token, body: syntheticPcm(1) })).status).toBe(404);
|
||||
});
|
||||
|
||||
it('one at a time per device, with its own per-minute budget', async () => {
|
||||
await harness({ ...AGENT_ENV, HERMEVEN_PREVIEWS_PER_MINUTE: '2' });
|
||||
const { token } = await h.pair();
|
||||
h.stt.next({ text: 'a', delayMs: 150 });
|
||||
const first = h.api('POST', `/v1/transcribe?${wakeQuery()}`, { token, body: syntheticPcm(1) });
|
||||
await new Promise((r) => setTimeout(r, 40));
|
||||
expect((await clip(token, 'b')).status).toBe(429);
|
||||
expect((await first).status).toBe(200);
|
||||
expect((await clip(token, 'c')).status).toBe(200);
|
||||
expect((await clip(token, 'd')).status).toBe(429);
|
||||
expect((await wake(token, 'Wendy, still fine')).status).toBe(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('glasses: words shown while recording', () => {
|
||||
beforeEach(async () => {
|
||||
sent = [];
|
||||
wakeRoute = 'real';
|
||||
extras = { wake: null, idleExit: null, livePreview: { firstMs: 300, stepMs: 300, pauseMs: 200 } };
|
||||
await harness();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await controller?.stop();
|
||||
});
|
||||
|
||||
it('the words appear as the recording grows, and what the agent is sent is the final transcript, not a preview', async () => {
|
||||
await paired();
|
||||
h.stt.next({ text: 'what is' }, { text: 'what is on my calender' }, { text: 'What is on my calendar?' });
|
||||
h.hermes.next({ kind: 'complete', afterMs: 250 });
|
||||
device.tap();
|
||||
await until('recording', () => phase() === 'listening' && device.micOpen);
|
||||
expect(device.frame.body).toContain('Recording stops by itself');
|
||||
device.speak(0.5);
|
||||
await until('first words', () => device.frame.body === 'Pepper is listening…\n\nwhat is');
|
||||
expect(device.frame.status).toContain('● REC');
|
||||
device.speak(0.5);
|
||||
await until('more words', () => device.frame.body === 'Pepper is listening…\n\nwhat is on my calender');
|
||||
device.tap();
|
||||
// The last preview stays up while the real transcription runs...
|
||||
expect(device.frame.body).toBe('Transcribing…\n\nwhat is on my calender');
|
||||
// ...and is replaced by what the bridge actually sent to the agent.
|
||||
await until('thinking', () => device.frame.body === 'Pepper is thinking…\n\nHeard: What is on my calendar?');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
expect(snapshot.lastTurn?.input_text).toBe('What is on my calendar?');
|
||||
expect(posts('/v1/transcribe')).toBe(2);
|
||||
expect(posts('/v1/turns')).toBe(1);
|
||||
expect(h.hermes.executions).toBe(1);
|
||||
});
|
||||
|
||||
it('a long recording shows its newest words, within the screen', async () => {
|
||||
await paired();
|
||||
const long = Array.from({ length: 150 }, (_, i) => `word${i}`).join(' ');
|
||||
h.stt.next({ text: long });
|
||||
device.tap();
|
||||
await until('recording', () => phase() === 'listening' && device.micOpen);
|
||||
device.speak(0.5);
|
||||
await until('preview', () => snapshot.state.preview !== null);
|
||||
const body = device.frame.body;
|
||||
expect(body.startsWith('Pepper is listening…\n\n… ')).toBe(true);
|
||||
expect(body.endsWith('word149')).toBe(true);
|
||||
expect(measureTextWrap(body, 568).lineCount).toBeLessThanOrEqual(9);
|
||||
device.doubleTap();
|
||||
});
|
||||
|
||||
it('a preview that comes back after cancel, or for an earlier recording, is not drawn', async () => {
|
||||
await paired();
|
||||
h.stt.next({ text: 'late words', delayMs: 200 });
|
||||
device.tap();
|
||||
await until('recording', () => phase() === 'listening' && device.micOpen);
|
||||
device.speak(0.5);
|
||||
await until('preview requested', () => posts('/v1/transcribe') === 1);
|
||||
device.doubleTap();
|
||||
expect(phase()).toBe('cancelled');
|
||||
device.tap();
|
||||
await until('recording again', () => phase() === 'listening' && device.micOpen);
|
||||
await pause(300);
|
||||
expect(snapshot.state.preview).toBeNull();
|
||||
expect(device.frame.body).not.toContain('late words');
|
||||
device.doubleTap();
|
||||
});
|
||||
|
||||
it('a bridge without previews just records as before; typed questions never say "Heard"', async () => {
|
||||
await controller?.stop();
|
||||
await h.close();
|
||||
await harness(AGENT_ENV, { stt: false });
|
||||
await paired();
|
||||
device.tap();
|
||||
await until('recording', () => phase() === 'listening' && device.micOpen);
|
||||
device.speak(1);
|
||||
await pause(80);
|
||||
expect(posts('/v1/transcribe')).toBe(0);
|
||||
device.doubleTap();
|
||||
h.hermes.next({ kind: 'complete', afterMs: 200 });
|
||||
controller.askText('typed');
|
||||
await until('thinking', () => phase() === 'thinking');
|
||||
await pause(80);
|
||||
expect(device.frame.body).toBe('Pepper is thinking…');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
});
|
||||
|
||||
it('works in hands free too, for the question that follows a name', async () => {
|
||||
// One preview only, so the scripted recogniser's replies line up.
|
||||
extras = { livePreview: { firstMs: 300, stepMs: 60_000, pauseMs: 200 } };
|
||||
await paired();
|
||||
await listening();
|
||||
h.stt.next({ text: 'Wendy' }, { text: 'are you' }, { text: 'are you there' });
|
||||
say(0.5);
|
||||
await until('recording for Wendy', () => phase() === 'listening');
|
||||
device.speak(0.6);
|
||||
await until('words', () => device.frame.body === 'Wendy is listening…\n\nare you');
|
||||
device.silence(1.4);
|
||||
await until('answer', () => phase() === 'answer');
|
||||
expect(h.hermes.executedBy).toEqual(['wendy']);
|
||||
expect(snapshot.lastTurn?.input_text).toBe('are you there');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -149,14 +149,15 @@ function litInBand(shot: { rows: Buffer[]; width: number }, fromY: number, toY:
|
||||
let pageOriginForRelaunch = '';
|
||||
|
||||
/** Start a simulator on the page. `idleExit` is the development-only switch read by main.ts. */
|
||||
async function launchSimulator(idleExit: 'off' | 'fast', code: string): Promise<void> {
|
||||
async function launchSimulator(idleExit: 'off' | 'fast', code: string, legacy = true): Promise<void> {
|
||||
const pageOrigin = pageOriginForRelaunch;
|
||||
const automationPort = await freePort();
|
||||
automation = `http://127.0.0.1:${automationPort}`;
|
||||
const bin = require.resolve('@evenrealities/sim-linux-x64/bin/evenhub-simulator');
|
||||
// idleExit=off: this suite drives the app for longer than the idle timeout between steps.
|
||||
// wake=off, menu=off: this suite covers the tap path and idle exit from Ready, as before the menu.
|
||||
const url = `${pageOrigin}/?idleExit=${idleExit}&wake=off&menu=off&bridge=${encodeURIComponent(h.url)}&pair=${encodeURIComponent(code)}`;
|
||||
// `legacy = false` launches the app as it ships: opening menu, hands free and live preview on.
|
||||
const url = `${pageOrigin}/?idleExit=${idleExit}${legacy ? '&wake=off&menu=off&preview=off' : ''}&bridge=${encodeURIComponent(h.url)}&pair=${encodeURIComponent(code)}`;
|
||||
// alsa:null yields silence: the simulator never opens a real microphone in this test.
|
||||
sim = spawn(bin, [url, '--automation-port', String(automationPort), '--no-glow', '--aid', 'alsa:null'], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
@@ -373,4 +374,68 @@ describe('Even Hub simulator 0.9.5', () => {
|
||||
const problems = after.filter((l) => /\[uncaught\]|\[unhandledrejection\]/.test(l));
|
||||
expect(problems).toEqual([]);
|
||||
}, 120_000);
|
||||
|
||||
it('as shipped: opens on the menu; a tap starts hands free with the microphone open; double tap returns to the menu and closes it; Agents does not listen', async () => {
|
||||
// A third simulator, with nothing switched off. The microphone is alsa:null (silence), so
|
||||
// this shows the menu, the gestures and the microphone opening and closing through the
|
||||
// real SDK bridge. It shows nothing about hearing a name: no speech exists here.
|
||||
sim.kill('SIGTERM');
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
if (sim.exitCode === null) sim.kill('SIGKILL');
|
||||
await pumpConsole().catch(() => undefined);
|
||||
const from = consoleLines.length;
|
||||
lastConsoleId = 0;
|
||||
const sttBefore = h.stt.calls;
|
||||
const runsBefore = h.hermes.executions;
|
||||
await launchSimulator('off', h.bridge.devices.createPairingCode().code, false);
|
||||
await waitConsole('hud: HUD page created', 30_000, from);
|
||||
await waitConsole('-> menu', 20_000, from);
|
||||
await new Promise((r) => setTimeout(r, 800));
|
||||
const menu = await screenshot('10-menu');
|
||||
expect(litInBand(menu, 0, 120)).toBeGreaterThan(200);
|
||||
expect(litInBand(menu, 251, 288)).toBeGreaterThan(100);
|
||||
// Nothing listens on the menu.
|
||||
expect(consoleLines.slice(from).some((l) => l.includes('wake: listening for a name'))).toBe(false);
|
||||
|
||||
// Swiping moves the marker: the picture changes, and changes back.
|
||||
await input('down');
|
||||
await new Promise((r) => setTimeout(r, 600));
|
||||
const second = await screenshot('11-menu-agents-selected');
|
||||
expect(second.png.equals(menu.png)).toBe(false);
|
||||
await input('up');
|
||||
await new Promise((r) => setTimeout(r, 600));
|
||||
expect((await screenshot('12-menu-again')).png.equals(menu.png)).toBe(true);
|
||||
|
||||
// First entry: hands free.
|
||||
await input('click');
|
||||
await waitConsole('state: menu -> ready', 10_000, from);
|
||||
await waitConsole('wake: listening for a name', 10_000, from);
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
const handsFree = await screenshot('13-hands-free');
|
||||
expect(litInBand(handsFree, 251, 288)).toBeGreaterThan(100);
|
||||
await pumpConsole();
|
||||
// Silence is never sent anywhere.
|
||||
expect(h.stt.calls).toBe(sttBefore);
|
||||
|
||||
// Back to the menu: the microphone closes.
|
||||
let mark = consoleLines.length;
|
||||
await input('double_click');
|
||||
await waitConsole('state: ready -> menu', 10_000, mark);
|
||||
await waitConsole('wake: stopped listening', 10_000, mark);
|
||||
|
||||
// Second entry: Agents. No listening.
|
||||
mark = consoleLines.length;
|
||||
await input('down');
|
||||
await input('click');
|
||||
await waitConsole('state: menu -> ready', 10_000, mark);
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
await pumpConsole();
|
||||
expect(consoleLines.slice(mark).some((l) => l.includes('wake: listening for a name'))).toBe(false);
|
||||
await screenshot('14-agents-ready');
|
||||
|
||||
expect(h.stt.calls).toBe(sttBefore);
|
||||
expect(h.hermes.executions).toBe(runsBefore);
|
||||
const problems = consoleLines.slice(from).filter((l) => /\[uncaught\]|\[unhandledrejection\]|\[fetch\]/.test(l));
|
||||
expect(problems).toEqual([]);
|
||||
}, 120_000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user