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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user