Files
gods-eye-view/src/voice/earcon.js
T
Bilawal Sidhu a19897ad15 feat(voice): voice core — honest layer reach, spoken summary with on-screen card, narration, point-and-ask
- Voice layer manifest (src/voice/layerManifest.js) generates the layer enums,
  aliases and analyst field hints; a test fails when a catalog layer has no entry.
- analyst_query validates fields, operators, units, values and scopes, counts up
  to 250,000 loaded records per layer, reports complete/partial/unanswered, tells
  LAYER_OFF / NOT_READY / FEED_UNAVAILABLE apart from zero, refuses mismatched
  follow-ups and never lets a superseded query replace follow-up memory. Seven
  more layers expose analyst records.
- Tool results carry a code-built say line and a display card; the voice card in
  the mic control shows captions, plan steps and the result
  (src/voice/resultDisplay.js is the one adapter). Slow tools narrate their
  current step out of band; holding Space while the assistant talks cuts it off.
  Turn spans go to the debug log; caption transcription is metered; the log
  omits what was said unless GEV_VOICE_LOG_CONTENT=1.
- Point and ask: the Space-down pointer snapshot resolves "this", "that one" and
  "around here" through 'pointer' targets, and "the second one" through
  referent:n from the last numbered list.
- Prompt states each policy once (instructions + tools 48.5k -> 46.7k chars).
- Voice benchmark harness (scripts/qa-voice-bench.mjs, scripts/voice-bench/)
  shares its phrase table and grading with scripts/qa-voice-routing.mjs.
2026-09-28 21:19:23 -05:00

67 lines
2.0 KiB
JavaScript

/** Seconds between the two soft "working" ticks. */
const TICK_INTERVAL_S = 1.1;
const TICK_GAIN = 0.035;
/**
* A quiet, repeating two-note tick that says "still working" when nothing
* else is audible. It is the floor under spoken progress, never a substitute
* for it.
*
* `available()` gates it on the microphone being muted (push-to-talk after
* release): with an open microphone a local sound could be heard as user
* speech and end the turn, so an open-mic session relies on the voice card's
* visual progress instead.
* @param {{ isMicrophoneMuted: () => boolean, createContext?: () => AudioContext|null }} options
*/
export function createEarcon({
isMicrophoneMuted,
createContext = () => {
const Context = globalThis.AudioContext || globalThis.webkitAudioContext;
return Context ? new Context() : null;
},
} = {}) {
let context = null;
let timer = null;
function tick() {
if (!context) return;
const start = context.currentTime + 0.01;
for (const [offset, frequency] of [
[0, 880],
[0.09, 1320],
]) {
const oscillator = context.createOscillator();
const gain = context.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = frequency;
gain.gain.setValueAtTime(0, start + offset);
gain.gain.linearRampToValueAtTime(TICK_GAIN, start + offset + 0.012);
gain.gain.exponentialRampToValueAtTime(0.0001, start + offset + 0.09);
oscillator.connect(gain).connect(context.destination);
oscillator.start(start + offset);
oscillator.stop(start + offset + 0.1);
}
}
return {
available: () => Boolean(isMicrophoneMuted?.()),
start() {
if (timer) return;
context ||= createContext();
if (!context) return;
context.resume?.().catch?.(() => {});
tick();
timer = setInterval(tick, TICK_INTERVAL_S * 1000);
},
stop() {
if (timer) clearInterval(timer);
timer = null;
},
dispose() {
this.stop();
context?.close?.().catch?.(() => {});
context = null;
},
};
}