expo-speech-recognition 0.2.15 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/build/ExpoSpeechRecognitionModule.d.ts +40 -2
- package/build/ExpoSpeechRecognitionModule.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.js +16 -2
- package/build/ExpoSpeechRecognitionModule.js.map +1 -1
- package/ios/ExpoSpeechRecognizer.swift +4 -2
- package/package.json +1 -1
- package/src/ExpoSpeechRecognitionModule.ts +24 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🎙️ expo-speech-recognition
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
expo-speech-recognition implements the iOS [`SFSpeechRecognizer`](https://developer.apple.com/documentation/speech/sfspeechrecognizer), Android [`SpeechRecognizer`](https://developer.android.com/reference/android/speech/SpeechRecognizer) and Web [`SpeechRecognition`](https://wicg.github.io/speech-api/) for React Native projects with the goal of code reuse across web and mobile.
|
|
6
6
|
|
|
@@ -37,7 +37,7 @@ expo-speech-recognition implements the iOS [`SFSpeechRecognizer`](https://develo
|
|
|
37
37
|
- [getSpeechRecognitionServices()](#getspeechrecognitionservices-string-android-only)
|
|
38
38
|
- [getDefaultRecognitionService()](#getdefaultrecognitionservice--packagename-string--android-only)
|
|
39
39
|
- [getAssistantService()](#getassistantservice--packagename-string--android-only)
|
|
40
|
-
- [supportsOnDeviceRecognition()](#supportsondevicerecognition-boolean
|
|
40
|
+
- [supportsOnDeviceRecognition()](#supportsondevicerecognition-boolean)
|
|
41
41
|
- [supportsRecording()](#supportsrecording-boolean-android-only)
|
|
42
42
|
- [androidTriggerOfflineModelDownload()](#androidtriggerofflinemodeldownload-locale-string--promise-status-opened_dialog--download_success--download_canceled-message-string-)
|
|
43
43
|
- [setCategoryIOS()](#setcategoryios-void-ios-only)
|
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
import { EventEmitter } from "expo-modules-core";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare const ExpoSpeechRecognitionModule: {
|
|
3
|
+
stop: () => void;
|
|
4
|
+
abort: () => void;
|
|
5
|
+
requestPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
|
|
6
|
+
getPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
|
|
7
|
+
getStateAsync: () => Promise<"inactive" | "starting" | "recognizing" | "stopping">;
|
|
8
|
+
getAssistantService: () => {
|
|
9
|
+
packageName: string;
|
|
10
|
+
};
|
|
11
|
+
getDefaultRecognitionService: () => {
|
|
12
|
+
packageName: string;
|
|
13
|
+
};
|
|
14
|
+
getSpeechRecognitionServices: () => string[];
|
|
15
|
+
supportsOnDeviceRecognition: () => boolean;
|
|
16
|
+
supportsRecording: () => boolean;
|
|
17
|
+
start(options: import("./ExpoSpeechRecognitionModule.types").ExpoSpeechRecognitionOptions): void;
|
|
18
|
+
getSupportedLocales(options: {
|
|
19
|
+
androidRecognitionServicePackage?: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
locales: string[];
|
|
22
|
+
installedLocales: string[];
|
|
23
|
+
}>;
|
|
24
|
+
androidTriggerOfflineModelDownload(options: {
|
|
25
|
+
locale: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
status: "download_success" | "opened_dialog" | "download_canceled";
|
|
28
|
+
message: string;
|
|
29
|
+
}>;
|
|
30
|
+
setCategoryIOS(options: import("./ExpoSpeechRecognitionModule.types").SetCategoryOptions): void;
|
|
31
|
+
getAudioSessionCategoryAndOptionsIOS(): {
|
|
32
|
+
category: import("./ExpoSpeechRecognitionModule.types").AVAudioSessionCategoryValue;
|
|
33
|
+
categoryOptions: import("./ExpoSpeechRecognitionModule.types").AVAudioSessionCategoryOptionsValue[];
|
|
34
|
+
mode: import("./ExpoSpeechRecognitionModule.types").AVAudioSessionModeValue;
|
|
35
|
+
};
|
|
36
|
+
setAudioSessionActiveIOS(value: boolean, options?: {
|
|
37
|
+
notifyOthersOnDeactivation: boolean;
|
|
38
|
+
}): void;
|
|
39
|
+
addListener: (eventType: string) => void;
|
|
40
|
+
removeListeners: (count: number) => void;
|
|
41
|
+
};
|
|
4
42
|
export declare const ExpoSpeechRecognitionModuleEmitter: EventEmitter;
|
|
5
43
|
//# sourceMappingURL=ExpoSpeechRecognitionModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAS3B,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;wCAyB0wqB,CAAC;;;;;;;;;;;;;;;;;;;;;;CALlzqB,CAAC;AAEF,eAAO,MAAM,kCAAkC,cAE9C,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { EventEmitter, NativeModulesProxy, requireNativeModule, } from "expo-modules-core";
|
|
2
2
|
// It loads the native module object from the JSI or falls back to
|
|
3
3
|
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
4
|
-
|
|
5
|
-
export const
|
|
4
|
+
const ExpoSpeechRecognitionNativeModule = requireNativeModule("ExpoSpeechRecognition");
|
|
5
|
+
export const ExpoSpeechRecognitionModule = {
|
|
6
|
+
...ExpoSpeechRecognitionNativeModule,
|
|
7
|
+
// Avoid any function bindings when calling the native module
|
|
8
|
+
stop: () => ExpoSpeechRecognitionNativeModule.stop(),
|
|
9
|
+
abort: () => ExpoSpeechRecognitionNativeModule.abort(),
|
|
10
|
+
requestPermissionsAsync: () => ExpoSpeechRecognitionNativeModule.requestPermissionsAsync(),
|
|
11
|
+
getPermissionsAsync: () => ExpoSpeechRecognitionNativeModule.getPermissionsAsync(),
|
|
12
|
+
getStateAsync: () => ExpoSpeechRecognitionNativeModule.getStateAsync(),
|
|
13
|
+
getAssistantService: () => ExpoSpeechRecognitionNativeModule.getAssistantService(),
|
|
14
|
+
getDefaultRecognitionService: () => ExpoSpeechRecognitionNativeModule.getDefaultRecognitionService(),
|
|
15
|
+
getSpeechRecognitionServices: () => ExpoSpeechRecognitionNativeModule.getSpeechRecognitionServices(),
|
|
16
|
+
supportsOnDeviceRecognition: () => ExpoSpeechRecognitionNativeModule.supportsOnDeviceRecognition(),
|
|
17
|
+
supportsRecording: () => ExpoSpeechRecognitionNativeModule.supportsRecording(),
|
|
18
|
+
};
|
|
19
|
+
export const ExpoSpeechRecognitionModuleEmitter = new EventEmitter(ExpoSpeechRecognitionNativeModule ?? NativeModulesProxy.ExpoSpeechRecognition);
|
|
6
20
|
//# sourceMappingURL=ExpoSpeechRecognitionModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAI3B,kEAAkE;AAClE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAI3B,kEAAkE;AAClE,4EAA4E;AAC5E,MAAM,iCAAiC,GACrC,mBAAmB,CAAkC,uBAAuB,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,GAAG,iCAAiC;IACpC,6DAA6D;IAC7D,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAiC,CAAC,IAAI,EAAE;IACpD,KAAK,EAAE,GAAG,EAAE,CAAC,iCAAiC,CAAC,KAAK,EAAE;IACtD,uBAAuB,EAAE,GAAG,EAAE,CAC5B,iCAAiC,CAAC,uBAAuB,EAAE;IAC7D,mBAAmB,EAAE,GAAG,EAAE,CACxB,iCAAiC,CAAC,mBAAmB,EAAE;IACzD,aAAa,EAAE,GAAG,EAAE,CAAC,iCAAiC,CAAC,aAAa,EAAE;IACtE,mBAAmB,EAAE,GAAG,EAAE,CACxB,iCAAiC,CAAC,mBAAmB,EAAE;IACzD,4BAA4B,EAAE,GAAG,EAAE,CACjC,iCAAiC,CAAC,4BAA4B,EAAE;IAClE,4BAA4B,EAAE,GAAG,EAAE,CACjC,iCAAiC,CAAC,4BAA4B,EAAE;IAClE,2BAA2B,EAAE,GAAG,EAAE,CAChC,iCAAiC,CAAC,2BAA2B,EAAE;IACjE,iBAAiB,EAAE,GAAG,EAAE,CACtB,iCAAiC,CAAC,iBAAiB,EAAE;CACxD,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,YAAY,CAChE,iCAAiC,IAAI,kBAAkB,CAAC,qBAAqB,CAC9E,CAAC","sourcesContent":["import {\n EventEmitter,\n NativeModulesProxy,\n requireNativeModule,\n} from \"expo-modules-core\";\n\nimport type { ExpoSpeechRecognitionModuleType } from \"./ExpoSpeechRecognitionModule.types\";\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nconst ExpoSpeechRecognitionNativeModule =\n requireNativeModule<ExpoSpeechRecognitionModuleType>(\"ExpoSpeechRecognition\");\n\nexport const ExpoSpeechRecognitionModule = {\n ...ExpoSpeechRecognitionNativeModule,\n // Avoid any function bindings when calling the native module\n stop: () => ExpoSpeechRecognitionNativeModule.stop(),\n abort: () => ExpoSpeechRecognitionNativeModule.abort(),\n requestPermissionsAsync: () =>\n ExpoSpeechRecognitionNativeModule.requestPermissionsAsync(),\n getPermissionsAsync: () =>\n ExpoSpeechRecognitionNativeModule.getPermissionsAsync(),\n getStateAsync: () => ExpoSpeechRecognitionNativeModule.getStateAsync(),\n getAssistantService: () =>\n ExpoSpeechRecognitionNativeModule.getAssistantService(),\n getDefaultRecognitionService: () =>\n ExpoSpeechRecognitionNativeModule.getDefaultRecognitionService(),\n getSpeechRecognitionServices: () =>\n ExpoSpeechRecognitionNativeModule.getSpeechRecognitionServices(),\n supportsOnDeviceRecognition: () =>\n ExpoSpeechRecognitionNativeModule.supportsOnDeviceRecognition(),\n supportsRecording: () =>\n ExpoSpeechRecognitionNativeModule.supportsRecording(),\n};\n\nexport const ExpoSpeechRecognitionModuleEmitter = new EventEmitter(\n ExpoSpeechRecognitionNativeModule ?? NativeModulesProxy.ExpoSpeechRecognition,\n);\n"]}
|
|
@@ -632,7 +632,10 @@ actor ExpoSpeechRecognizer: ObservableObject {
|
|
|
632
632
|
if let error: Error {
|
|
633
633
|
// TODO: don't emit no-speech if there were already interim results
|
|
634
634
|
Task { @MainActor in
|
|
635
|
-
|
|
635
|
+
if await task != nil {
|
|
636
|
+
// Don't emit any errors after the task has finished
|
|
637
|
+
errorHandler(error)
|
|
638
|
+
}
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
641
|
|
|
@@ -676,7 +679,6 @@ actor ExpoSpeechRecognizer: ObservableObject {
|
|
|
676
679
|
// Stop listening when the timer fires
|
|
677
680
|
// This will finish the current task and emit the final result (or a no-speech event)
|
|
678
681
|
await self?.stopListening()
|
|
679
|
-
|
|
680
682
|
}
|
|
681
683
|
}
|
|
682
684
|
}
|
package/package.json
CHANGED
|
@@ -8,9 +8,31 @@ import type { ExpoSpeechRecognitionModuleType } from "./ExpoSpeechRecognitionMod
|
|
|
8
8
|
|
|
9
9
|
// It loads the native module object from the JSI or falls back to
|
|
10
10
|
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
11
|
-
|
|
11
|
+
const ExpoSpeechRecognitionNativeModule =
|
|
12
12
|
requireNativeModule<ExpoSpeechRecognitionModuleType>("ExpoSpeechRecognition");
|
|
13
13
|
|
|
14
|
+
export const ExpoSpeechRecognitionModule = {
|
|
15
|
+
...ExpoSpeechRecognitionNativeModule,
|
|
16
|
+
// Avoid any function bindings when calling the native module
|
|
17
|
+
stop: () => ExpoSpeechRecognitionNativeModule.stop(),
|
|
18
|
+
abort: () => ExpoSpeechRecognitionNativeModule.abort(),
|
|
19
|
+
requestPermissionsAsync: () =>
|
|
20
|
+
ExpoSpeechRecognitionNativeModule.requestPermissionsAsync(),
|
|
21
|
+
getPermissionsAsync: () =>
|
|
22
|
+
ExpoSpeechRecognitionNativeModule.getPermissionsAsync(),
|
|
23
|
+
getStateAsync: () => ExpoSpeechRecognitionNativeModule.getStateAsync(),
|
|
24
|
+
getAssistantService: () =>
|
|
25
|
+
ExpoSpeechRecognitionNativeModule.getAssistantService(),
|
|
26
|
+
getDefaultRecognitionService: () =>
|
|
27
|
+
ExpoSpeechRecognitionNativeModule.getDefaultRecognitionService(),
|
|
28
|
+
getSpeechRecognitionServices: () =>
|
|
29
|
+
ExpoSpeechRecognitionNativeModule.getSpeechRecognitionServices(),
|
|
30
|
+
supportsOnDeviceRecognition: () =>
|
|
31
|
+
ExpoSpeechRecognitionNativeModule.supportsOnDeviceRecognition(),
|
|
32
|
+
supportsRecording: () =>
|
|
33
|
+
ExpoSpeechRecognitionNativeModule.supportsRecording(),
|
|
34
|
+
};
|
|
35
|
+
|
|
14
36
|
export const ExpoSpeechRecognitionModuleEmitter = new EventEmitter(
|
|
15
|
-
|
|
37
|
+
ExpoSpeechRecognitionNativeModule ?? NativeModulesProxy.ExpoSpeechRecognition,
|
|
16
38
|
);
|