mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 04:27:22 +01:00
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>
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import type { DictationProblem } from "../dictation.js";
|
|
import type { VoiceModeEnd } from "../voice-mode.js";
|
|
import { type UseVoiceModeOptions } from "./use-voice-mode.js";
|
|
export type VoiceModeLabels = {
|
|
title: string;
|
|
/** Under the button, per phase: what is happening and what a press does. */
|
|
listening: string;
|
|
thinking: string;
|
|
speaking: string;
|
|
/** The big button's name for a screen reader, per phase. */
|
|
pressListening: string;
|
|
pressSpeaking: string;
|
|
pressThinking: string;
|
|
end: string;
|
|
again: string;
|
|
/** Why the call is over. */
|
|
ended: Record<Exclude<VoiceModeEnd, "ended">, string>;
|
|
dictation: Record<DictationProblem, string>;
|
|
};
|
|
export declare const DEFAULT_VOICE_MODE_LABELS: VoiceModeLabels;
|
|
export type VoiceModeProps = UseVoiceModeOptions & {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
/** Who is being talked to, shown above the button. */
|
|
name?: string;
|
|
labels?: Partial<VoiceModeLabels>;
|
|
};
|
|
/**
|
|
* A spoken conversation, full screen: one big button, what was heard, what is
|
|
* being said back, and End. Open it from a tap (browsers open a microphone
|
|
* and a voice only inside one); closing it shuts both.
|
|
*
|
|
* The loop and its rules are `useVoiceMode` and `voiceModeReducer`. This is
|
|
* only the screen, so every chat that offers voice looks and behaves the same.
|
|
*/
|
|
export declare function VoiceMode({ open, onClose, name, labels: given, ...opts }: VoiceModeProps): import("react").JSX.Element;
|
|
//# sourceMappingURL=VoiceMode.d.ts.map
|