-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathExpoSpeechRecognitionModule.ts
40 lines (36 loc) · 1.73 KB
/
ExpoSpeechRecognitionModule.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
import {
EventEmitter,
NativeModulesProxy,
requireNativeModule,
} from "expo-modules-core";
import type { ExpoSpeechRecognitionModuleType } from "./ExpoSpeechRecognitionModule.types";
// It loads the native module object from the JSI or falls back to
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
const ExpoSpeechRecognitionNativeModule =
requireNativeModule<ExpoSpeechRecognitionModuleType>("ExpoSpeechRecognition");
export const ExpoSpeechRecognitionModule: ExpoSpeechRecognitionModuleType = {
...ExpoSpeechRecognitionNativeModule,
// Avoid any function bindings when calling the native module
stop: () => ExpoSpeechRecognitionNativeModule.stop(),
abort: () => ExpoSpeechRecognitionNativeModule.abort(),
requestPermissionsAsync: () =>
ExpoSpeechRecognitionNativeModule.requestPermissionsAsync(),
getPermissionsAsync: () =>
ExpoSpeechRecognitionNativeModule.getPermissionsAsync(),
getStateAsync: () => ExpoSpeechRecognitionNativeModule.getStateAsync(),
getAssistantService: () =>
ExpoSpeechRecognitionNativeModule.getAssistantService(),
getDefaultRecognitionService: () =>
ExpoSpeechRecognitionNativeModule.getDefaultRecognitionService(),
getSpeechRecognitionServices: () =>
ExpoSpeechRecognitionNativeModule.getSpeechRecognitionServices(),
supportsOnDeviceRecognition: () =>
ExpoSpeechRecognitionNativeModule.supportsOnDeviceRecognition(),
supportsRecording: () =>
ExpoSpeechRecognitionNativeModule.supportsRecording(),
isRecognitionAvailable: () =>
ExpoSpeechRecognitionNativeModule.isRecognitionAvailable(),
};
export const ExpoSpeechRecognitionModuleEmitter = new EventEmitter(
ExpoSpeechRecognitionNativeModule ?? NativeModulesProxy.ExpoSpeechRecognition,
);