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:
@@ -83,8 +83,15 @@ export interface AppState {
|
||||
* from what the microphone actually did, so the HUD's indicator is never a guess.
|
||||
*/
|
||||
wakeListening: boolean;
|
||||
/** The question as it was heard, when it was spoken after a name. Shown while the agent works. */
|
||||
/** The request in flight was spoken (recorded), not typed. */
|
||||
spoken: boolean;
|
||||
/** The spoken question as the bridge transcribed it. Shown while the agent works. */
|
||||
heard: string | null;
|
||||
/**
|
||||
* The words of the recording in progress, as far as they have been transcribed. Already cut
|
||||
* by the controller to what fits the screen. A preview only: it is never what is sent.
|
||||
*/
|
||||
preview: string | null;
|
||||
pages: string[];
|
||||
pageIndex: number;
|
||||
/** The answer is a partial one (agent stopped short). Shown on the HUD. */
|
||||
@@ -119,7 +126,9 @@ export const initialState: AppState = {
|
||||
captureMaxSeconds: 30,
|
||||
captureAuto: false,
|
||||
wakeListening: false,
|
||||
spoken: false,
|
||||
heard: null,
|
||||
preview: null,
|
||||
pages: [],
|
||||
pageIndex: 0,
|
||||
partial: false,
|
||||
@@ -174,6 +183,8 @@ export type AppEvent =
|
||||
| { type: 'cancel' }
|
||||
| { type: 'submit_text'; freshId: string; text: string }
|
||||
| { type: 'capture_started'; generation: number; at: number }
|
||||
/** The words so far in the recording being made (already fitted to the screen). */
|
||||
| { type: 'capture_preview'; generation: number; text: string }
|
||||
| { type: 'capture_failed'; generation: number; reason: 'mic_refused' | 'mic_stalled' | 'empty' }
|
||||
| { type: 'capture_limit'; generation: number }
|
||||
| { type: 'conversation_created'; epoch: number; conversationId: string }
|
||||
@@ -224,7 +235,9 @@ function clearTurn(state: AppState): AppState {
|
||||
requestId: null,
|
||||
captureStartedAt: null,
|
||||
captureAuto: false,
|
||||
spoken: false,
|
||||
heard: null,
|
||||
preview: null,
|
||||
pages: [],
|
||||
pageIndex: 0,
|
||||
partial: false,
|
||||
@@ -402,7 +415,7 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
}
|
||||
if (state.phase === 'listening' && state.requestId) {
|
||||
return {
|
||||
state: { ...state, phase: 'transcribing', captureStartedAt: null },
|
||||
state: { ...state, phase: 'transcribing', captureStartedAt: null, spoken: true },
|
||||
effects: [{ type: 'stop_capture_and_submit', generation: state.generation, requestId: state.requestId }],
|
||||
};
|
||||
}
|
||||
@@ -419,7 +432,7 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
case 'capture_limit': {
|
||||
if (event.generation !== state.generation || state.phase !== 'listening' || !state.requestId) return same(state);
|
||||
return {
|
||||
state: { ...state, phase: 'transcribing', captureStartedAt: null },
|
||||
state: { ...state, phase: 'transcribing', captureStartedAt: null, spoken: true },
|
||||
effects: [{ type: 'stop_capture_and_submit', generation: state.generation, requestId: state.requestId }],
|
||||
};
|
||||
}
|
||||
@@ -502,6 +515,11 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
return same({ ...state, captureStartedAt: event.at });
|
||||
}
|
||||
|
||||
case 'capture_preview': {
|
||||
if (event.generation !== state.generation || state.phase !== 'listening') return same(state);
|
||||
return same(event.text === state.preview ? state : { ...state, preview: event.text || null });
|
||||
}
|
||||
|
||||
case 'capture_failed': {
|
||||
if (event.generation !== state.generation) return same(state);
|
||||
if (state.phase !== 'listening' && state.phase !== 'transcribing') return same(state);
|
||||
@@ -522,9 +540,13 @@ export function reduce(state: AppState, event: AppEvent): Step {
|
||||
if (!IN_FLIGHT.has(state.phase) && state.phase !== 'disconnected') return same(state);
|
||||
const result = event.result;
|
||||
if (!result.terminal) {
|
||||
const phase: Phase =
|
||||
result.state === 'transcribing' ? 'transcribing' : result.state === 'approval_required' ? 'approval' : 'thinking';
|
||||
return same({ ...state, phase, disconnectedFrom: null, canResend: false });
|
||||
// A recording the bridge has accepted but not yet started on is still being transcribed.
|
||||
const waiting = result.state === 'transcribing' || (result.state === 'accepted' && state.spoken && !result.input_text);
|
||||
const phase: Phase = waiting ? 'transcribing' : result.state === 'approval_required' ? 'approval' : 'thinking';
|
||||
// Once the bridge has the transcript of a spoken question, that is what the agent is
|
||||
// being sent, and it is shown in place of the preview.
|
||||
const heard = state.heard ?? (state.spoken && !waiting ? (result.input_text ?? null) : null);
|
||||
return same({ ...state, phase, heard, preview: waiting ? state.preview : null, disconnectedFrom: null, canResend: false });
|
||||
}
|
||||
const settled = { ...clearTurn(state), requestId: state.requestId };
|
||||
switch (result.outcome) {
|
||||
|
||||
Reference in New Issue
Block a user