Repository navigation
Component Speech Input
Speech input code exists as a browser Web Speech hook, microphone availability helpers, a hold-to-talk button, and a disclosure dialog. As of the code read on 2026-09-26, Component-Frontend-App renders only TextInput; MicButton, SpeechDisclosure, and useSpeech are not wired into App.tsx.
-
packages/frontend/src/hooks/useSpeech.tswraps the browserSpeechRecognition/webkitSpeechRecognitionAPI. -
packages/frontend/src/services/micDetection.tsprobes microphone support and subscribes to device changes. -
packages/frontend/src/components/MicButton.tsxrenders a pointer-held mic button. -
packages/frontend/src/components/SpeechDisclosure.tsxrenders a provider disclosure dialog. -
packages/frontend/src/components/TextInput.tsxrenders the currently active text entry field. -
packages/frontend/src/App.tsximports and rendersTextInputonly.
interface UseSpeechReturn { isListening: boolean; transcript: string; error: string | null; start: () => void; stop: () => string; }getSpeechProvider(): stringuseSpeech(): UseSpeechReturnprobeMic(): Promise<boolean>isMicAvailable(): booleanonMicChange(callback: () => void): () => voidMicButton({ onStart, onStop, disabled }: MicButtonProps)SpeechDisclosure({ provider, visible, onDismiss }: SpeechDisclosureProps)interface TextInputProps { onSubmit: (text: string) => void; disabled?: boolean; maxLength?: number; }TextInput = forwardRef<HTMLInputElement, TextInputProps>(...)
useSpeech.start():
- Locates
window.SpeechRecognitionorwindow.webkitSpeechRecognition. - Sets
continuous = true,interimResults = true, andlang = 'en-US'. - Clears transcript and error state.
- Appends only final transcript fragments in
onresult. - Sets
errorfromonerrorand clearsisListening. - Clears
isListeningononend.
useSpeech.stop() calls recognition.stop(), clears isListening, and returns the hook's current transcript state.
getSpeechProvider() reports Google for user agents containing Chrome, Apple for Safari user agents without Chrome, otherwise your browser.
micDetection:
-
probeMic()callsnavigator.mediaDevices.getUserMedia({ audio: true }), immediately stops tracks, and returns false for unsupported or failed probes. -
isMicAvailable()is a synchronous capability check. -
onMicChange()attaches adevicechangelistener whennavigator.mediaDevicesexists.
MicButton starts on pointer down, stops on pointer up or pointer leave, and renders an ON AIR indicator while held.
TextInput submits trimmed text on Enter, clears after submit, defaults maxLength to 2000, and shows Talk to Max... unless disabled.
Text input connects to Component-WebSocket-Transport through App.handleSend(), which sends a user_message with inputMethod: 'text'. The speech hook's output would need a caller to send inputMethod: 'voice'; that caller is not present in App.tsx today. Voice UI styling lives in the shared app CSS described by Component-CRT-Presentation.
- Speech recognition is implemented but not composed into the visible app shell.
-
stop()returns React state captured by the current render; if final recognition results arrive very near stop time, a caller may need to account for state update timing. -
probeMic()requests real microphone permission as part of availability probing, then stops tracks immediately.
- Concept-Cloud-Only-Inference
- Concept-Budget-Ceiling
- Concept-Personality-Gate
- Concept-IP-And-Legal-Posture
- Concept-Supply-Chain-Discipline
- Concept-Graceful-Degradation
- Concept-Observability
- Concept-Testing-And-TDD
- Concept-Credential-Hygiene
Editing in the browser? Wiki edits are live and bypass wiki:lint. Read
Guide-Wiki-Contributing first.