← back to Dear Bubbe Nextjs
types/speech.d.ts
25 lines
// Minimal Web Speech API typings. lib.dom doesn't ship the webkit-prefixed
// constructor, and it's the reason both chat components fell back to
// `(window as any)`. A distinct type name (WebSpeechRecognition) avoids
// clobbering any lib.dom `SpeechRecognition` declaration; the Window fields
// are additive (interface merge).
interface WebSpeechRecognition extends EventTarget {
lang: string
continuous: boolean
interimResults: boolean
maxAlternatives: number
start(): void
stop(): void
abort(): void
onresult: ((e: { resultIndex: number; results: { length: number; [i: number]: { isFinal: boolean; [i: number]: { transcript: string } } } }) => void) | null
onerror: ((e: { error: string; message?: string }) => void) | null
onend: (() => void) | null
onstart: (() => void) | null
}
interface Window {
webkitSpeechRecognition?: { new (): WebSpeechRecognition }
SpeechRecognition?: { new (): WebSpeechRecognition }
}