forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
49 lines (42 loc) · 1.51 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Type definitions for react-speech-recognition 3.9
// Project: https://github.com/JamesBrill/react-speech-recognition#readme
// Definitions by: OleksandrYehorov <https://github.com/OleksandrYehorov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Command {
command: string | string[] | RegExp;
callback: (...args: any[]) => unknown;
isFuzzyMatch?: boolean | undefined;
matchInterim?: boolean | undefined;
fuzzyMatchingThreshold?: number | undefined;
bestMatchOnly?: boolean | undefined;
}
export interface ListeningOptions {
continuous?: boolean | undefined;
language?: string | undefined;
}
interface SpeechRecognition {
getRecognition(): SpeechRecognition | null;
startListening(options?: ListeningOptions): Promise<void>;
stopListening(): void;
abortListening(): void;
browserSupportsSpeechRecognition(): boolean;
applyPolyfill(speechRecognitionPolyfill: any): void;
}
export interface SpeechRecognitionOptions {
transcribing?: boolean | undefined;
clearTranscriptOnListen?: boolean | undefined;
commands?: ReadonlyArray<Command> | undefined;
}
export function useSpeechRecognition(
options?: SpeechRecognitionOptions,
): {
transcript: string;
interimTranscript: string;
finalTranscript: string;
listening: boolean;
resetTranscript: () => void;
browserSupportsSpeechRecognition: boolean;
isMicrophoneAvailable: boolean;
};
declare const SpeechRecognition: SpeechRecognition;
export default SpeechRecognition;