@charisma-ai/sdk
Version:
Charisma.ai SDK for Javascript (browser)
68 lines (67 loc) • 3.13 kB
TypeScript
export type SpeechRecognitionErrorCode = "aborted" | "audio-capture" | "bad-grammar" | "language-not-supported" | "network" | "no-speech" | "not-allowed" | "service-not-allowed";
export interface SpeechRecognitionErrorEventInit extends EventInit {
error: SpeechRecognitionErrorCode;
message?: string;
}
export interface SpeechRecognitionEventInit extends EventInit {
resultIndex?: number;
results: SpeechRecognitionResultList;
}
export interface SpeechGrammar {
src: string;
weight: number;
}
export interface SpeechGrammarList {
readonly length: number;
addFromString(string: string, weight?: number): void;
addFromURI(src: string, weight?: number): void;
item(index: number): SpeechGrammar;
[index: number]: SpeechGrammar;
}
export interface SpeechRecognitionErrorEvent extends Event {
readonly error: SpeechRecognitionErrorCode;
readonly message: string;
}
export interface SpeechRecognitionEvent extends Event {
readonly resultIndex: number;
readonly results: SpeechRecognitionResultList;
}
interface SpeechRecognitionEventMap {
audioend: Event;
audiostart: Event;
end: Event;
error: SpeechRecognitionErrorEvent;
nomatch: SpeechRecognitionEvent;
result: SpeechRecognitionEvent;
soundend: Event;
soundstart: Event;
speechend: Event;
speechstart: Event;
start: Event;
}
export interface SpeechRecognition extends EventTarget {
continuous: boolean;
grammars: SpeechGrammarList;
interimResults: boolean;
lang: string;
maxAlternatives: number;
onaudioend: ((this: SpeechRecognition, ev: Event) => any) | null;
onaudiostart: ((this: SpeechRecognition, ev: Event) => any) | null;
onend: ((this: SpeechRecognition, ev: Event) => any) | null;
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null;
onspeechend: ((this: SpeechRecognition, ev: Event) => any) | null;
onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null;
onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
abort(): void;
start(): void;
stop(): void;
addEventListener<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
export {};