From 3fb9b4c056ec23577292e90ed628b0812bf3c84b Mon Sep 17 00:00:00 2001 From: samit Date: Sat, 21 Feb 2026 01:00:08 -0800 Subject: [PATCH] added SpeechRecognition declarations and missing type packages --- .../src/features/chat/shared-composer.tsx | 2 - studio/frontend/src/speech-recognition.d.ts | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 studio/frontend/src/speech-recognition.d.ts diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx index 5ddcb3947f..855b83ee09 100644 --- a/studio/frontend/src/features/chat/shared-composer.tsx +++ b/studio/frontend/src/features/chat/shared-composer.tsx @@ -38,7 +38,6 @@ function fileToBase64DataURL(file: File): Promise { } function useDictation( - textareaRef: React.RefObject, setText: (value: string | ((prev: string) => string)) => void, ) { const [isDictating, setIsDictating] = useState(false); @@ -188,7 +187,6 @@ export function SharedComposer({ const fileInputRef = useRef(null); const { isDictating, start: startDictation, stop: stopDictation, supported: dictationSupported } = useDictation( - textareaRef, setText, ); diff --git a/studio/frontend/src/speech-recognition.d.ts b/studio/frontend/src/speech-recognition.d.ts new file mode 100644 index 0000000000..c583b200a6 --- /dev/null +++ b/studio/frontend/src/speech-recognition.d.ts @@ -0,0 +1,49 @@ +/** + * Minimal Web Speech API (Speech Recognition) types for browsers that support it. + * Full types: @types/dom-speech-recognition + */ +interface SpeechRecognitionResultList { + readonly length: number; + item(index: number): SpeechRecognitionResult; + [index: number]: SpeechRecognitionResult; +} + +interface SpeechRecognitionResult { + readonly length: number; + readonly isFinal: boolean; + item(index: number): SpeechRecognitionAlternative; + [index: number]: SpeechRecognitionAlternative; +} + +interface SpeechRecognitionAlternative { + readonly transcript: string; + readonly confidence: number; +} + +interface SpeechRecognitionEvent extends Event { + readonly resultIndex: number; + readonly results: SpeechRecognitionResultList; +} + +interface SpeechRecognition extends EventTarget { + continuous: boolean; + interimResults: boolean; + lang: string; + onresult: ((event: SpeechRecognitionEvent) => void) | null; + onerror: ((event: Event) => void) | null; + onend: (() => void) | null; + start(): void; + stop(): void; + abort(): void; +} + +interface SpeechRecognitionConstructor { + new (): SpeechRecognition; +} + +interface Window { + SpeechRecognition?: SpeechRecognitionConstructor; + webkitSpeechRecognition?: SpeechRecognitionConstructor; +} + +declare var SpeechRecognition: SpeechRecognitionConstructor | undefined;