57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
// Web Speech API TypeScript declarations
|
|
interface SpeechRecognition extends EventTarget {
|
|
continuous: boolean
|
|
interimResults: boolean
|
|
lang: string
|
|
start(): void
|
|
stop(): void
|
|
abort(): void
|
|
onstart: ((this: SpeechRecognition, ev: Event) => any) | null
|
|
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null
|
|
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null
|
|
onend: ((this: SpeechRecognition, ev: Event) => any) | null
|
|
}
|
|
|
|
interface SpeechRecognitionEvent extends Event {
|
|
resultIndex: number
|
|
results: SpeechRecognitionResultList
|
|
}
|
|
|
|
interface SpeechRecognitionErrorEvent extends Event {
|
|
error: string
|
|
message: string
|
|
}
|
|
|
|
interface SpeechRecognitionResultList {
|
|
length: number
|
|
item(index: number): SpeechRecognitionResult
|
|
[index: number]: SpeechRecognitionResult
|
|
}
|
|
|
|
interface SpeechRecognitionResult {
|
|
length: number
|
|
item(index: number): SpeechRecognitionAlternative
|
|
[index: number]: SpeechRecognitionAlternative
|
|
isFinal: boolean
|
|
}
|
|
|
|
interface SpeechRecognitionAlternative {
|
|
transcript: string
|
|
confidence: number
|
|
}
|
|
|
|
declare var SpeechRecognition: {
|
|
prototype: SpeechRecognition
|
|
new(): SpeechRecognition
|
|
}
|
|
|
|
declare var webkitSpeechRecognition: {
|
|
prototype: SpeechRecognition
|
|
new(): SpeechRecognition
|
|
}
|
|
|
|
interface Window {
|
|
SpeechRecognition: typeof SpeechRecognition
|
|
webkitSpeechRecognition: typeof webkitSpeechRecognition
|
|
}
|