Files
CatoandClaude 8452fb12ab VoiceMode: talking with a chat, and a microphone that cannot be opened twice (0.30.0) (#89)
Cat Bot has to be a complete equivalent of Grok Bot, which has a voice mode.
The chat could take dictation and read an answer aloud, but not hold a
spoken conversation.

- VoiceMode (the screen), useVoiceMode (the loop), voiceModeReducer (the
  rules, pure): listening -> thinking -> speaking -> listening. One big
  button ends the person's turn (a pause ends it by itself where the
  browser's recogniser runs) and cuts in while the answer is read. The app
  passes onTurn(text) => Promise<answer> and, if it has one, a studio
  speaker.
- The microphone and the voice follow the phase and nothing else
  (voiceModeWants): never both open, neither open when the call is off. Two
  empty takes, a failed transcription or an answer that never comes each end
  the call in words, with "Talk again".
- Fix, useDictation: a second start() before the browser had handed the
  microphone over opened a second microphone and orphaned the first, whose
  track stayed live with nothing left to stop it. One request at a time now,
  and a take cancelled while the microphone was still opening closes it
  where it arrives. Found by this change's browser test.
- Its styles are their own section and styles/voice.css, so the embedded
  chat sheet stays inside its 11 KB budget.

test/voice-mode.test.js (8) and test/browser-voice.mjs (a real browser, a
fake-device microphone, every opened track counted). pnpm run verify passes.


Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 08:18:12 +01:00
..