expo-speech-recognition 0.2.20 → 0.2.22
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/LICENSE +21 -0
- package/README.md +123 -47
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechRecognitionModule.kt +4 -0
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechService.kt +11 -2
- package/app.plugin.js +18 -12
- package/build/ExpoSpeechRecognitionModule.d.ts +2 -40
- package/build/ExpoSpeechRecognitionModule.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.js +1 -0
- package/build/ExpoSpeechRecognitionModule.js.map +1 -1
- package/build/ExpoSpeechRecognitionModule.types.d.ts +65 -43
- package/build/ExpoSpeechRecognitionModule.types.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.types.js.map +1 -1
- package/build/ExpoSpeechRecognitionModule.web.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.web.js +5 -4
- package/build/ExpoSpeechRecognitionModule.web.js.map +1 -1
- package/build/ExpoWebSpeechRecognition.d.ts +1 -1
- package/build/ExpoWebSpeechRecognition.d.ts.map +1 -1
- package/build/ExpoWebSpeechRecognition.js +2 -2
- package/build/ExpoWebSpeechRecognition.js.map +1 -1
- package/build/index.d.ts +14 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/useSpeechRecognitionEvent.d.ts +1 -1
- package/build/useSpeechRecognitionEvent.d.ts.map +1 -1
- package/build/useSpeechRecognitionEvent.js +1 -1
- package/build/useSpeechRecognitionEvent.js.map +1 -1
- package/ios/ExpoSpeechRecognitionModule.swift +6 -2
- package/ios/ExpoSpeechRecognizer.swift +0 -1
- package/package.json +1 -1
- package/src/ExpoSpeechRecognitionModule.ts +3 -1
- package/src/ExpoSpeechRecognitionModule.types.ts +76 -45
- package/src/ExpoSpeechRecognitionModule.web.ts +8 -12
- package/src/ExpoWebSpeechRecognition.ts +6 -9
- package/src/index.ts +16 -0
- package/src/useSpeechRecognitionEvent.ts +2 -2
|
@@ -2,6 +2,45 @@ import type { PermissionResponse } from "expo-modules-core";
|
|
|
2
2
|
import type { NativeModule } from "react-native";
|
|
3
3
|
import type { AudioEncodingAndroid, AVAudioSessionCategory, AVAudioSessionCategoryOptions, AVAudioSessionMode, RecognizerIntentEnableLanguageSwitch, RecognizerIntentExtraLanguageModel, TaskHintIOS } from "./constants";
|
|
4
4
|
export type AVAudioSessionCategoryValue = (typeof AVAudioSessionCategory)[keyof typeof AVAudioSessionCategory];
|
|
5
|
+
export type ExpoSpeechRecognitionResult = {
|
|
6
|
+
transcript: string;
|
|
7
|
+
/**
|
|
8
|
+
* Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating transcript confidence.
|
|
9
|
+
*/
|
|
10
|
+
confidence: number;
|
|
11
|
+
/**
|
|
12
|
+
* An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
|
|
13
|
+
*
|
|
14
|
+
* Notes for Android:
|
|
15
|
+
*
|
|
16
|
+
* - This is only available for SDK 34+ (Android 14+)
|
|
17
|
+
* - This is only verified to work with the `com.google.android.as` service (using on device speech recognition)
|
|
18
|
+
* - Segments are only available during the final result
|
|
19
|
+
* - The segment parts are split up by words.
|
|
20
|
+
* - The segments are only available for the first transcript
|
|
21
|
+
* - Segment confidences currently return as -1 (unavailable)
|
|
22
|
+
*
|
|
23
|
+
* Notes for iOS:
|
|
24
|
+
*
|
|
25
|
+
* - The confidence value will be 0 on partial results
|
|
26
|
+
*/
|
|
27
|
+
segments: ExpoSpeechRecognitionResultSegment[];
|
|
28
|
+
};
|
|
29
|
+
export type ExpoSpeechRecognitionResultSegment = {
|
|
30
|
+
/** The start timestamp of the utterance, e.g. 1000 */
|
|
31
|
+
startTimeMillis: number;
|
|
32
|
+
/** The end timestamp of the utterance, e.g. 1500 */
|
|
33
|
+
endTimeMillis: number;
|
|
34
|
+
/** The text portion of the transcript, e.g. "Hello world" */
|
|
35
|
+
segment: string;
|
|
36
|
+
/** Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating the confidence of the specific segment */
|
|
37
|
+
confidence: number;
|
|
38
|
+
};
|
|
39
|
+
/** Fired when there's a speech result. The result may be partial or final */
|
|
40
|
+
export type ExpoSpeechRecognitionResultEvent = {
|
|
41
|
+
isFinal: boolean;
|
|
42
|
+
results: ExpoSpeechRecognitionResult[];
|
|
43
|
+
};
|
|
5
44
|
export type ExpoSpeechRecognitionErrorCode =
|
|
6
45
|
/** The user called `ExpoSpeechRecognitionModule.abort()`. */
|
|
7
46
|
"aborted"
|
|
@@ -22,52 +61,21 @@ export type ExpoSpeechRecognitionErrorCode =
|
|
|
22
61
|
/** The recognizer is busy and cannot accept any new recognition requests. */
|
|
23
62
|
| "busy"
|
|
24
63
|
/** (Android only) An unknown client-side error occurred. */
|
|
25
|
-
| "client"
|
|
64
|
+
| "client"
|
|
65
|
+
/** (Android) No speech input. */
|
|
66
|
+
| "speech-timeout"
|
|
67
|
+
/** (Android) Unknown error */
|
|
68
|
+
| "unknown";
|
|
69
|
+
export type ExpoSpeechRecognitionErrorEvent = {
|
|
70
|
+
error: ExpoSpeechRecognitionErrorCode;
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
26
73
|
/**
|
|
27
74
|
* Events that are dispatched from the native side
|
|
28
75
|
*/
|
|
29
76
|
export type ExpoSpeechRecognitionNativeEventMap = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
isFinal: boolean;
|
|
33
|
-
results: {
|
|
34
|
-
transcript: string;
|
|
35
|
-
/**
|
|
36
|
-
* Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating transcript confidence.
|
|
37
|
-
*/
|
|
38
|
-
confidence: number;
|
|
39
|
-
/**
|
|
40
|
-
* An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.
|
|
41
|
-
*
|
|
42
|
-
* Notes for Android:
|
|
43
|
-
*
|
|
44
|
-
* - This is only available for SDK 34+ (Android 14+)
|
|
45
|
-
* - This is only verified to work with the `com.google.android.as` service (using on device speech recognition)
|
|
46
|
-
* - Segments are only available during the final result
|
|
47
|
-
* - The segment parts are split up by words.
|
|
48
|
-
* - The segments are only available for the first transcript
|
|
49
|
-
* - Segment confidences currently return as -1 (unavailable)
|
|
50
|
-
*
|
|
51
|
-
* Notes for iOS:
|
|
52
|
-
*
|
|
53
|
-
* - The confidence value will be 0 on partial results
|
|
54
|
-
*/
|
|
55
|
-
segments: {
|
|
56
|
-
/** The start timestamp of the utterance, e.g. 1000 */
|
|
57
|
-
startTimeMillis: number;
|
|
58
|
-
/** The end timestamp of the utterance, e.g. 1500 */
|
|
59
|
-
endTimeMillis: number;
|
|
60
|
-
/** The text portion of the transcript, e.g. "Hello world" */
|
|
61
|
-
segment: string;
|
|
62
|
-
/** Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating the confidence of the specific segment */
|
|
63
|
-
confidence: number;
|
|
64
|
-
}[];
|
|
65
|
-
}[];
|
|
66
|
-
};
|
|
67
|
-
error: {
|
|
68
|
-
error: ExpoSpeechRecognitionErrorCode;
|
|
69
|
-
message: string;
|
|
70
|
-
};
|
|
77
|
+
result: ExpoSpeechRecognitionResultEvent;
|
|
78
|
+
error: ExpoSpeechRecognitionErrorEvent;
|
|
71
79
|
start: null;
|
|
72
80
|
speechstart: null;
|
|
73
81
|
speechend: null;
|
|
@@ -117,7 +125,13 @@ export type ExpoSpeechRecognitionOptions = {
|
|
|
117
125
|
* On iOS, this configures [`SFSpeechRecognitionRequest.contextualStrings`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/1649391-contextualstrings).
|
|
118
126
|
*/
|
|
119
127
|
contextualStrings?: string[];
|
|
120
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* [Default: false] Continuous recognition.
|
|
130
|
+
*
|
|
131
|
+
* Not supported on Android 12 and below.
|
|
132
|
+
*
|
|
133
|
+
* If false on iOS, recognition will run until no speech is detected for 3 seconds.
|
|
134
|
+
*/
|
|
121
135
|
continuous?: boolean;
|
|
122
136
|
/** [Default: false] Prevent device from sending audio over the network. Only enabled if the device supports it.
|
|
123
137
|
*
|
|
@@ -493,6 +507,7 @@ export interface ExpoSpeechRecognitionModuleType extends NativeModule {
|
|
|
493
507
|
* @returns empty string if no service is found, or not Android
|
|
494
508
|
*/
|
|
495
509
|
getDefaultRecognitionService(): {
|
|
510
|
+
/** e.g. "com.google.android.tts" or "com.google.android.googlequicksearchbox" */
|
|
496
511
|
packageName: string;
|
|
497
512
|
};
|
|
498
513
|
/**
|
|
@@ -503,6 +518,7 @@ export interface ExpoSpeechRecognitionModuleType extends NativeModule {
|
|
|
503
518
|
* @returns empty string if no service is found, or not Android
|
|
504
519
|
*/
|
|
505
520
|
getAssistantService(): {
|
|
521
|
+
/** e.g. "com.google.android.googlequicksearchbox" or "com.samsung.android.bixby.agent" */
|
|
506
522
|
packageName: string;
|
|
507
523
|
};
|
|
508
524
|
/**
|
|
@@ -515,6 +531,12 @@ export interface ExpoSpeechRecognitionModuleType extends NativeModule {
|
|
|
515
531
|
* This mostly applies to Android devices, to check if it's greater than Android 13.
|
|
516
532
|
*/
|
|
517
533
|
supportsRecording(): boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Whether on-device speech recognition is available.
|
|
536
|
+
*
|
|
537
|
+
* If this method returns false, `start()` will fail and emit an error event with the code `service-not-allowed` or `language-not-supported`.
|
|
538
|
+
*/
|
|
539
|
+
isRecognitionAvailable(): boolean;
|
|
518
540
|
/**
|
|
519
541
|
* Downloads the offline model for the specified locale.
|
|
520
542
|
* Note: this is only supported on Android 13 and above.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.types.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,oCAAoC,EACpC,kCAAkC,EAClC,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE,MAAM,MAAM,8BAA8B;AACxC,6DAA6D;AAC3D,SAAS;AACX,6BAA6B;GAC3B,eAAe;AACjB,kJAAkJ;GAChJ,aAAa;AACf,wDAAwD;GACtD,wBAAwB;AAC1B,4EAA4E;GAC1E,SAAS;AACX,oCAAoC;GAClC,WAAW;AACb,0EAA0E;GACxE,aAAa;AACf,iCAAiC;GAC/B,qBAAqB;AAEvB,6EAA6E;GAC3E,MAAM;AACR,4DAA4D;GAC1D,QAAQ
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.types.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,oCAAoC,EACpC,kCAAkC,EAClC,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAEvE,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,EAAE,kCAAkC,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;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,kCAAkC,GAC5C,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,OAAO,6BAA6B,CAAC,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.types.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type { NativeModule } from \"react-native\";\n\nimport type {\n AudioEncodingAndroid,\n AVAudioSessionCategory,\n AVAudioSessionCategoryOptions,\n AVAudioSessionMode,\n RecognizerIntentEnableLanguageSwitch,\n RecognizerIntentExtraLanguageModel,\n TaskHintIOS,\n} from \"./constants\";\n\nexport type AVAudioSessionCategoryValue =\n (typeof AVAudioSessionCategory)[keyof typeof AVAudioSessionCategory];\n\nexport type ExpoSpeechRecognitionErrorCode =\n /** The user called `ExpoSpeechRecognitionModule.abort()`. */\n | \"aborted\"\n /** Audio recording error. */\n | \"audio-capture\"\n /** There was an error in the speech recognition grammar or semantic tags, or the chosen grammar format or semantic tag format was unsupported. */\n | \"bad-grammar\"\n /** Locale is not supported by the speech recognizer. */\n | \"language-not-supported\"\n /** Network communication required for completing the recognition failed. */\n | \"network\"\n /** No final speech was detected. */\n | \"no-speech\"\n /** Permission to use speech recognition or microphone was not granted. */\n | \"not-allowed\"\n /** Recognizer is unavailable. */\n | \"service-not-allowed\"\n // Extra codes (not part of the spec)\n /** The recognizer is busy and cannot accept any new recognition requests. */\n | \"busy\"\n /** (Android only) An unknown client-side error occurred. */\n | \"client\";\n\n/**\n * Events that are dispatched from the native side\n */\nexport type ExpoSpeechRecognitionNativeEventMap = {\n /** Fired when there's a speech result. The result may be partial or final */\n result: {\n isFinal: boolean;\n results: {\n transcript: string;\n /**\n * Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating transcript confidence.\n */\n confidence: number;\n /**\n * An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.\n *\n * Notes for Android:\n *\n * - This is only available for SDK 34+ (Android 14+)\n * - This is only verified to work with the `com.google.android.as` service (using on device speech recognition)\n * - Segments are only available during the final result\n * - The segment parts are split up by words.\n * - The segments are only available for the first transcript\n * - Segment confidences currently return as -1 (unavailable)\n *\n * Notes for iOS:\n *\n * - The confidence value will be 0 on partial results\n */\n segments: {\n /** The start timestamp of the utterance, e.g. 1000 */\n startTimeMillis: number;\n /** The end timestamp of the utterance, e.g. 1500 */\n endTimeMillis: number;\n /** The text portion of the transcript, e.g. \"Hello world\" */\n segment: string;\n /** Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating the confidence of the specific segment */\n confidence: number;\n }[];\n }[];\n };\n error: {\n error: ExpoSpeechRecognitionErrorCode;\n message: string;\n };\n start: null;\n speechstart: null;\n speechend: null;\n /** A final result is returned with no significant recognition */\n nomatch: null;\n /** Audio capturing had started */\n audiostart: {\n /**\n * The uri is set when `recordingOptions.persist` is enabled.\n * Do not attempt to use this file until the `audioend` event is emitted.\n *\n * Example URIs:\n *\n * - Android: `file:///data/user/0/expo.modules.speechrecognition.example/cache/recording_1720678500903.wav`\n * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.caf`\n */\n uri: string | null;\n };\n /** Audio capturing had ended */\n audioend: {\n /**\n * The uri is set when `recordingOptions.persist` is enabled.\n *\n * Example URIs:\n *\n * - Android: `file:///data/user/0/expo.modules.speechrecognition.example/cache/recording_1720678500903.wav`\n * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.caf`\n */\n uri: string | null;\n };\n end: null;\n soundstart: null;\n soundend: null;\n};\n\nexport type ExpoSpeechRecognitionOptions = {\n /** [Default: \"en-US\"] The language of the speech recognition */\n lang?: string;\n /** [Default: false] Note for iOS: final results are only available after speech recognition has stopped */\n interimResults?: boolean;\n /** [Default: 5] The maximum number of alternative transcriptions to return. */\n maxAlternatives?: number;\n /**\n * An array of strings that will be used to provide context to the speech recognition engine.\n *\n * On Android, this configures [`EXTRA_BIASING_STRINGS`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_BIASING_STRINGS) in the recognizer intent (API level 33+).\n *\n * On iOS, this configures [`SFSpeechRecognitionRequest.contextualStrings`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/1649391-contextualstrings).\n */\n contextualStrings?: string[];\n /** [Default: false] Continuous recognition. Note: if false on iOS, recognition will run until no speech is detected for 3 seconds */\n continuous?: boolean;\n /** [Default: false] Prevent device from sending audio over the network. Only enabled if the device supports it.\n *\n * Use `getSupportedLocales()` to verify if the locale is installed on the device prior to enabling this option.\n */\n requiresOnDeviceRecognition?: boolean;\n /**\n * [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.\n *\n * On Android, this configures [`EXTRA_ENABLE_FORMATTING`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING) in the recognizer intent (API level 33+).\n *\n * On iOS, this configures [`SFSpeechRecognitionRequest.addsPunctuation`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation).\n */\n addsPunctuation?: boolean;\n /**\n * The package name of the speech recognition service to use.\n * If not provided, the default service will be used.\n *\n * Obtain the supported packages by running `ExpoSpeechRecognitionModule.getSpeechRecognitionServices()`\n *\n * e.g. \"com.google.android.as\" or \"com.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage?: string;\n /**\n * Extra options to provide to the Android Recognition intent.\n *\n * For a full list of options, see https://developer.android.com/reference/android/speech/RecognizerIntent\n */\n androidIntentOptions?: Partial<AndroidIntentOptions>;\n /**\n * Audio source options to pass to the recognizer.\n *\n * This option can be used to recognize audio from a local or remote file URI.\n */\n audioSource?: AudioSourceOptions;\n /**\n * Audio recording options for persisting the audio to a local file path.\n */\n recordingOptions?: RecordingOptions;\n /**\n * Default: `\"android.speech.action.RECOGNIZE_SPEECH\"`\n *\n * The kind of intent action\n *\n * Intents:\n *\n * - [`android.speech.action.RECOGNIZE_SPEECH`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_RECOGNIZE_SPEECH) which performs speech recognition (default)\n * - [`android.speech.action.VOICE_SEARCH_HANDS_FREE`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_VOICE_SEARCH_HANDS_FREE) - prompts the user for speech without requiring the user's visual attention or touch input\n * - [`android.speech.action.WEB_SEARCH`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_WEB_SEARCH) - displays a web search result or trigger another type of action based on the user's speech.\n */\n androidIntent?:\n | \"android.speech.action.RECOGNIZE_SPEECH\"\n | \"android.speech.action.VOICE_SEARCH_HANDS_FREE\"\n | \"android.speech.action.WEB_SEARCH\";\n\n /**\n * The hint for the speech recognition task.\n *\n * Default: `\"unspecified\"`\n *\n * Docs: https://developer.apple.com/documentation/speech/sfspeechrecognitiontaskhint\n */\n iosTaskHint?: IOSTaskHintValue;\n\n /**\n * The audio category for the speech recognition task.\n *\n * Use this option to configure the default audio session category and mode prior to starting speech recognition.\n *\n * **Caution:** confirm that the category, options and mode are compatible with the audio source.\n *\n * By default, the audio session category and mode are set to:\n *\n * - category: `playAndRecord`\n * - options: `defaultToSpeaker` and `allowBluetooth`\n * - mode: `measurement`\n *\n * Docs: https://developer.apple.com/documentation/avfaudio/avaudiosession/category\n */\n iosCategory?: SetCategoryOptions;\n};\n\nexport type IOSTaskHintValue = (typeof TaskHintIOS)[keyof typeof TaskHintIOS];\n\nexport type RecordingOptions = {\n /**\n * Whether to persist the audio to a local file path.\n *\n * Default: false\n */\n persist: boolean;\n /**\n * Default: `FileSystem.CacheDirectory`. This changes the default storage location for the audio file.\n */\n outputDirectory?: string;\n /**\n * Default: `\"recording_${timestamp|uuid}.[wav|caf]\"`. This changes the file name for the audio file.\n */\n outputFileName?: string;\n /**\n * Default: undefined. The sample rate of the output audio file.\n *\n * Only supported on iOS\n *\n * Default sample rate is: 16000 on Android, 44100/48000 on iOS\n */\n outputSampleRate?: number;\n /**\n * Default: undefined. The encoding of the output audio file.\n *\n * Only supported on iOS\n */\n outputEncoding?:\n | \"pcmFormatFloat32\"\n | \"pcmFormatFloat64\"\n | \"pcmFormatInt16\"\n | \"pcmFormatInt32\";\n};\n\nexport type AudioSourceOptions = {\n /**\n * Local audio source URI.\n *\n * e.g. `\"file:///storage/emulated/0/Download/audio.wav\"`\n */\n uri: string;\n /**\n * [Android only] The number of channels in the source audio.\n *\n * Default: 1\n */\n audioChannels?: number;\n /**\n * [Android only] A value from [AudioFormat](https://developer.android.com/reference/android/media/AudioFormat).\n *\n * Use the `AudioEncodingAndroid` enum to get the correct value.\n */\n audioEncoding?: AudioEncodingAndroidValue;\n /**\n * [Android only] Audio sampling rate in Hz.\n *\n * Default: 16000\n */\n sampleRate?: number;\n /**\n * [Android only] The delay for a 4KiB chunk of audio to stream to the speech recognition service.\n *\n * Use this setting to avoid being rate-limited when using network-based recognition.\n *\n * If you're using on-device recognition, you may want to increase this value to avoid unprocessed audio chunks.\n *\n * Default: 50ms for network-based recognition, 15ms for on-device recognition\n */\n chunkDelayMillis?: number;\n};\n\nexport type AudioEncodingAndroidValue =\n (typeof AudioEncodingAndroid)[keyof typeof AudioEncodingAndroid];\n\nexport type AndroidIntentOptions = {\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_CALLING_PACKAGE\n *\n * The extra key used in an intent to the speech recognizer for voice search. Not generally to be used by developers. The system search dialog uses this, for example, to set a calling package for identification by a voice search API. If this extra is set by anyone but the system process, it should be overridden by the voice search implementation.\n */\n EXTRA_CALLING_PACKAGE: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_BIASING_DEVICE_CONTEXT\n *\n * Optional boolean to enable biasing towards device context. The recognizer will use the device context to tune the recognition results.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_ENABLE_BIASING_DEVICE_CONTEXT: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_DETECTION\n *\n * Optional boolean indicating whether to enable language detection. When enabled, the recognizer will consistently identify the language of the current spoken utterance and provide that info via RecognitionListener#onLanguageDetection(Bundle).\n */\n EXTRA_ENABLE_LANGUAGE_DETECTION: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_SWITCH\n *\n * Optional string to enable automatic switching to the language being spoken with the desired sensitivity level, instead of being restricted to a single language. The corresponding language models must be downloaded to support the switch. Otherwise, the recognizer will report an error on a switch failure. The recognizer provides the switch results via RecognitionListener#onLanguageDetection(Bundle).\n *\n * Since detection is a necessary requirement for the language switching, setting this value implicitly enables EXTRA_ENABLE_LANGUAGE_DETECTION.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_ENABLE_LANGUAGE_SWITCH: (typeof RecognizerIntentEnableLanguageSwitch)[keyof typeof RecognizerIntentEnableLanguageSwitch];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION\n *\n * [API level 33] Optional boolean, to be used with EXTRA_ENABLE_FORMATTING, to prevent the recognizer adding punctuation after the last word of the partial results. The default is false.\n */\n EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION: boolean;\n /**\n * Optional list of IETF language tags (as defined by BCP 47, e.g. \"en-US\", \"de-DE\").\n *\n * [API level 34] This extra is to be used with EXTRA_ENABLE_LANGUAGE_DETECTION. If set, the recognizer will constrain the language detection output to this list of languages, potentially improving detection accuracy.\n */\n EXTRA_LANGUAGE_DETECTION_ALLOWED_LANGUAGES: string[];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_MODEL\n *\n * [Default: free_form] The language model to use for speech recognition.\n *\n * Informs the recognizer which speech model to prefer when performing ACTION_RECOGNIZE_SPEECH.\n * The recognizer uses this information to fine tune the results.\n * This extra is required. Activities implementing ACTION_RECOGNIZE_SPEECH may interpret the values as they see fit.\n */\n EXTRA_LANGUAGE_MODEL: (typeof RecognizerIntentExtraLanguageModel)[keyof typeof RecognizerIntentExtraLanguageModel];\n\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_ALLOWED_LANGUAGES\n *\n * [API level 34] Optional list of IETF language tags (as defined by BCP 47, e.g. \"en-US\", \"de-DE\").\n * This extra is to be used with EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the recognizer will apply the auto switch only to these languages, even if the speech models of other languages also exist.\n * The corresponding language models must be downloaded to support the switch. Otherwise, the recognizer will report an error on a switch failure.\n */\n EXTRA_LANGUAGE_SWITCH_ALLOWED_LANGUAGES: string[];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS\n *\n * [API level 35] Optional integer to use for EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the language switch will only be activated for this value of ms of audio since the START_OF_SPEECH. This could provide a more stable recognition result when the language switch is only required in the beginning of the session.\n */\n EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_MAX_SWITCHES\n *\n * [API level 35] Optional integer to use for EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the language switch will be deactivated when LANGUAGE_SWITCH_MAX_SWITCHES reached.\n *\n * Depending on the recognizer implementation, this flag may have no effect.\n */\n EXTRA_LANGUAGE_SWITCH_MAX_SWITCHES: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_MASK_OFFENSIVE_WORDS\n *\n * [API level 33] Optional boolean indicating whether the recognizer should mask the offensive words in recognition results. The Default is true.\n *\n * Constant Value: \"android.speech.extra.MASK_OFFENSIVE_WORDS\"\n */\n EXTRA_MASK_OFFENSIVE_WORDS: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ORIGIN\n *\n * Optional value which can be used to indicate the referer url of a page in which speech was requested. For example, a web browser may choose to provide this for uses of speech on a given page.\n */\n EXTRA_ORIGIN: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_PREFER_OFFLINE\n *\n * Optional boolean, to be used with ACTION_RECOGNIZE_SPEECH, ACTION_VOICE_SEARCH_HANDS_FREE, ACTION_WEB_SEARCH to indicate whether to only use an offline speech recognition engine. The default is false, meaning that either network or offline recognition engines may be used.\n *\n * Depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_PREFER_OFFLINE: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_PROMPT\n *\n * Optional text prompt to show to the user when asking them to speak.\n */\n EXTRA_PROMPT: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_CONFIDENCE\n *\n * [API level 34] Optional boolean indicating whether the recognizer should return the confidence level of each word in the final recognition results.\n */\n EXTRA_REQUEST_WORD_CONFIDENCE: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_TIMING\n *\n * [API level 34] Optional boolean indicating whether the recognizer should return the timestamp of each word in the final recognition results.\n */\n EXTRA_REQUEST_WORD_TIMING: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SECURE\n *\n * Optional boolean to indicate that a \"hands free\" voice search was performed while the device was in a secure mode. An example of secure mode is when the device's screen lock is active, and it requires some form of authentication to be unlocked. When the device is securely locked, the voice search activity should either restrict the set of voice actions that are permitted, or require some form of secure authentication before proceeding.\n */\n EXTRA_SECURE: boolean;\n /**\n * Optional string to enable segmented session mode of the specified type,\n * which can be `EXTRA_AUDIO_SOURCE`, `EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS` or `EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS`.\n * When segmented session mode is supported by the recognizer implementation and this extra is set,\n * it will return the recognition results in segments via [RecognitionListener#onSegmentResults(Bundle)](https://developer.android.com/reference/android/speech/RecognitionListener#onSegmentResults(android.os.Bundle))\n * and terminate the session with [RecognitionListener#onEndOfSegmentedSession()](https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSegmentedSession()).\n *\n * When setting this extra, make sure the extra used as the string value here is also set in the same intent with proper value.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_SEGMENTED_SESSION:\n | \"android.speech.extra.AUDIO_SOURCE\"\n | \"android.speech.extras.SPEECH_INPUT_MINIMUM_LENGTH_MILLIS\"\n | \"android.speech.extras.SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS\";\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS\n *\n * The amount of time that it should take after the recognizer stops hearing speech to consider the input complete hence end the recognition session.\n *\n * Note that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!\n *\n * Depending on the recognizer implementation, these values may have no effect.\n *\n */\n EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS\n *\n * Optional integer to indicate the minimum length of the recognition session. The recognizer will not stop recognizing speech before this amount of time.\n *\n * Note that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!\n *\n * Depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS\n *\n * The amount of time that it should take after we stop hearing speech to consider the input possibly complete.\n * This is used to prevent the endpointer cutting off during very short mid-speech pauses.\n * Note that it is extremely rare you'd want to specify this value in an intent.\n * If you don't have a very good reason to change these, you should leave them as they are.\n * Note also that certain values may cause undesired or unexpected results - use judiciously!\n * Additionally, depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS: number;\n};\n\nexport interface ExpoSpeechRecognitionModuleType extends NativeModule {\n /**\n * Starts speech recognition.\n */\n start(options: ExpoSpeechRecognitionOptions): void;\n /**\n * Stops speech recognition and attempts to return a final result (through the `result` event).\n */\n stop(): void;\n /**\n * Cancels speech recognition immediately without returning a final result.\n */\n abort(): void;\n /**\n * Presents a dialog to the user to request permissions for using speech recognition and the microphone.\n *\n * For iOS, once a user has granted (or denied) location permissions by responding to the original permission request dialog,\n * the only way that the permissions can be changed is by the user themselves using the device settings app.\n */\n requestPermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns the current permission status for the microphone and speech recognition.\n */\n getPermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns an array of locales supported by the speech recognizer.\n *\n * Not supported on Android 12 and below (API level 31), this will return an empty array of locales.\n *\n * @throws {\"package_not_found\"} If the service package is not found.\n * @throws {\"error_[number]\"} If there was an error retrieving the supported locales.\n */\n getSupportedLocales(options: {\n /**\n * The package name of the speech recognition service to use.\n *\n * e.g. \"com.google.android.as\" or \"com.samsung.android.bixby.agent\"\n *\n * Warning: the service package (such as Bixby) may not be able to return any results.\n */\n androidRecognitionServicePackage?: string;\n }): Promise<{\n /**\n * All supported languages on the device. This includes both installed and supported languages.\n */\n locales: string[];\n /**\n * These languages are installed on to the device for offline use.\n *\n * This will likely be an empty array if the service package is not \"com.google.android.as\"\n */\n installedLocales: string[];\n }>;\n /**\n * [Android only] Returns an array of package names of speech recognition services that are available on the device.\n *\n * List of all available services as bundle identifiers, e.g. [\"com.google.android.as\", \"com.google.android.tts\"]\n */\n getSpeechRecognitionServices(): string[];\n /**\n * [Android only] Returns the default voice recognition service on the device.\n *\n * @returns empty string if no service is found, or not Android\n */\n getDefaultRecognitionService(): { packageName: string };\n /**\n * [Android only] Returns the default voice recognition service on the device.\n *\n * e.g. \"com.google.android.googlequicksearchbox\" or \"com.samsung.android.bixby.agent\"\n *\n * @returns empty string if no service is found, or not Android\n */\n getAssistantService(): { packageName: string };\n /**\n * Whether the on-device speech recognition is available on the device.\n */\n supportsOnDeviceRecognition(): boolean;\n /**\n * Whether the recording feature is available on the device.\n *\n * This mostly applies to Android devices, to check if it's greater than Android 13.\n */\n supportsRecording(): boolean;\n /**\n * Downloads the offline model for the specified locale.\n * Note: this is only supported on Android 13 and above.\n */\n androidTriggerOfflineModelDownload(options: {\n /** The locale to download the model for, e.g. \"en-US\" */\n locale: string;\n }): Promise<{\n /**\n * On Android 13, the status will be \"opened_dialog\" indicating that the model download dialog was opened.\n * On Android 14+, the status will be \"download_success\" indicating that the model download was successful.\n * On Android 14+, \"download_canceled\" will be returned if the download was canceled by a user interaction.\n */\n status: \"download_success\" | \"opened_dialog\" | \"download_canceled\";\n message: string;\n }>;\n /**\n * [iOS only] For advanced use cases, you may use this function to set the audio session category and mode.\n *\n * See: https://developer.apple.com/documentation/avfaudio/avaudiosession/1771734-setcategory\n */\n setCategoryIOS(options: SetCategoryOptions): void;\n\n /**\n * [iOS only] Returns the current audio session category and options.\n *\n * See:\n * - [AVAudioSession.Category](https://developer.apple.com/documentation/avfaudio/avaudiosession/category)\n * - [AVAudioSession.CategoryOptions](https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions)\n * - [AVAudioSession.Mode](https://developer.apple.com/documentation/avfaudio/avaudiosession/mode)\n */\n getAudioSessionCategoryAndOptionsIOS(): {\n category: AVAudioSessionCategoryValue;\n categoryOptions: AVAudioSessionCategoryOptionsValue[];\n mode: AVAudioSessionModeValue;\n };\n /**\n * [iOS only] Sets the shared audio session active state.\n *\n * Calls the following on iOS: `AVAudioSession.sharedInstance().setActive(value, options)`\n *\n * See: https://developer.apple.com/documentation/avfaudio/avaudiosession/1616627-setactive\n */\n setAudioSessionActiveIOS(\n value: boolean,\n options?: {\n /** [Default: true] Whether to notify other audio sessions when the active state changes. */\n notifyOthersOnDeactivation: boolean;\n },\n ): void;\n /**\n * Returns the current state of the speech recognizer.\n */\n getStateAsync(): Promise<SpeechRecognitionState>;\n}\n\nexport type SetCategoryOptions = {\n category: AVAudioSessionCategoryValue;\n categoryOptions: AVAudioSessionCategoryOptionsValue[];\n mode?: AVAudioSessionModeValue;\n};\n\ntype SpeechRecognitionState =\n | \"inactive\"\n | \"starting\"\n | \"recognizing\"\n | \"stopping\";\n\n/**\n * [iOS only] See: [AVAudioSession.CategoryOptions](https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions)\n *\n * Use the `AVAudioSessionCategoryOptions` enum to get the correct value.\n */\nexport type AVAudioSessionCategoryOptionsValue =\n (typeof AVAudioSessionCategoryOptions)[keyof typeof AVAudioSessionCategoryOptions];\n\n/**\n * [iOS only] See: [AVAudioSession.Mode](https://developer.apple.com/documentation/avfaudio/avaudiosession/mode)\n *\n * Use the `AVAudioSessionMode` enum to get the correct value.\n */\nexport type AVAudioSessionModeValue =\n (typeof AVAudioSessionMode)[keyof typeof AVAudioSessionMode];\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.types.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type { NativeModule } from \"react-native\";\n\nimport type {\n AudioEncodingAndroid,\n AVAudioSessionCategory,\n AVAudioSessionCategoryOptions,\n AVAudioSessionMode,\n RecognizerIntentEnableLanguageSwitch,\n RecognizerIntentExtraLanguageModel,\n TaskHintIOS,\n} from \"./constants\";\n\nexport type AVAudioSessionCategoryValue =\n (typeof AVAudioSessionCategory)[keyof typeof AVAudioSessionCategory];\n\nexport type ExpoSpeechRecognitionResult = {\n transcript: string;\n /**\n * Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating transcript confidence.\n */\n confidence: number;\n /**\n * An array of transcription segments that represent the parts of the transcription, as identified by the speech recognizer.\n *\n * Notes for Android:\n *\n * - This is only available for SDK 34+ (Android 14+)\n * - This is only verified to work with the `com.google.android.as` service (using on device speech recognition)\n * - Segments are only available during the final result\n * - The segment parts are split up by words.\n * - The segments are only available for the first transcript\n * - Segment confidences currently return as -1 (unavailable)\n *\n * Notes for iOS:\n *\n * - The confidence value will be 0 on partial results\n */\n segments: ExpoSpeechRecognitionResultSegment[];\n};\n\nexport type ExpoSpeechRecognitionResultSegment = {\n /** The start timestamp of the utterance, e.g. 1000 */\n startTimeMillis: number;\n /** The end timestamp of the utterance, e.g. 1500 */\n endTimeMillis: number;\n /** The text portion of the transcript, e.g. \"Hello world\" */\n segment: string;\n /** Value ranging between between 0.0, 1.0, and -1 (unavailable) indicating the confidence of the specific segment */\n confidence: number;\n};\n\n/** Fired when there's a speech result. The result may be partial or final */\nexport type ExpoSpeechRecognitionResultEvent = {\n isFinal: boolean;\n results: ExpoSpeechRecognitionResult[];\n};\n\nexport type ExpoSpeechRecognitionErrorCode =\n /** The user called `ExpoSpeechRecognitionModule.abort()`. */\n | \"aborted\"\n /** Audio recording error. */\n | \"audio-capture\"\n /** There was an error in the speech recognition grammar or semantic tags, or the chosen grammar format or semantic tag format was unsupported. */\n | \"bad-grammar\"\n /** Locale is not supported by the speech recognizer. */\n | \"language-not-supported\"\n /** Network communication required for completing the recognition failed. */\n | \"network\"\n /** No final speech was detected. */\n | \"no-speech\"\n /** Permission to use speech recognition or microphone was not granted. */\n | \"not-allowed\"\n /** Recognizer is unavailable. */\n | \"service-not-allowed\"\n // Extra codes (not part of the spec)\n /** The recognizer is busy and cannot accept any new recognition requests. */\n | \"busy\"\n /** (Android only) An unknown client-side error occurred. */\n | \"client\"\n /** (Android) No speech input. */\n | \"speech-timeout\"\n /** (Android) Unknown error */\n | \"unknown\";\n\nexport type ExpoSpeechRecognitionErrorEvent = {\n error: ExpoSpeechRecognitionErrorCode;\n message: string;\n};\n\n/**\n * Events that are dispatched from the native side\n */\nexport type ExpoSpeechRecognitionNativeEventMap = {\n result: ExpoSpeechRecognitionResultEvent;\n error: ExpoSpeechRecognitionErrorEvent;\n start: null;\n speechstart: null;\n speechend: null;\n /** A final result is returned with no significant recognition */\n nomatch: null;\n /** Audio capturing had started */\n audiostart: {\n /**\n * The uri is set when `recordingOptions.persist` is enabled.\n * Do not attempt to use this file until the `audioend` event is emitted.\n *\n * Example URIs:\n *\n * - Android: `file:///data/user/0/expo.modules.speechrecognition.example/cache/recording_1720678500903.wav`\n * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.caf`\n */\n uri: string | null;\n };\n /** Audio capturing had ended */\n audioend: {\n /**\n * The uri is set when `recordingOptions.persist` is enabled.\n *\n * Example URIs:\n *\n * - Android: `file:///data/user/0/expo.modules.speechrecognition.example/cache/recording_1720678500903.wav`\n * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.caf`\n */\n uri: string | null;\n };\n end: null;\n soundstart: null;\n soundend: null;\n};\n\nexport type ExpoSpeechRecognitionOptions = {\n /** [Default: \"en-US\"] The language of the speech recognition */\n lang?: string;\n /** [Default: false] Note for iOS: final results are only available after speech recognition has stopped */\n interimResults?: boolean;\n /** [Default: 5] The maximum number of alternative transcriptions to return. */\n maxAlternatives?: number;\n /**\n * An array of strings that will be used to provide context to the speech recognition engine.\n *\n * On Android, this configures [`EXTRA_BIASING_STRINGS`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_BIASING_STRINGS) in the recognizer intent (API level 33+).\n *\n * On iOS, this configures [`SFSpeechRecognitionRequest.contextualStrings`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/1649391-contextualstrings).\n */\n contextualStrings?: string[];\n /**\n * [Default: false] Continuous recognition.\n *\n * Not supported on Android 12 and below.\n *\n * If false on iOS, recognition will run until no speech is detected for 3 seconds.\n */\n continuous?: boolean;\n /** [Default: false] Prevent device from sending audio over the network. Only enabled if the device supports it.\n *\n * Use `getSupportedLocales()` to verify if the locale is installed on the device prior to enabling this option.\n */\n requiresOnDeviceRecognition?: boolean;\n /**\n * [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.\n *\n * On Android, this configures [`EXTRA_ENABLE_FORMATTING`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING) in the recognizer intent (API level 33+).\n *\n * On iOS, this configures [`SFSpeechRecognitionRequest.addsPunctuation`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation).\n */\n addsPunctuation?: boolean;\n /**\n * The package name of the speech recognition service to use.\n * If not provided, the default service will be used.\n *\n * Obtain the supported packages by running `ExpoSpeechRecognitionModule.getSpeechRecognitionServices()`\n *\n * e.g. \"com.google.android.as\" or \"com.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage?: string;\n /**\n * Extra options to provide to the Android Recognition intent.\n *\n * For a full list of options, see https://developer.android.com/reference/android/speech/RecognizerIntent\n */\n androidIntentOptions?: Partial<AndroidIntentOptions>;\n /**\n * Audio source options to pass to the recognizer.\n *\n * This option can be used to recognize audio from a local or remote file URI.\n */\n audioSource?: AudioSourceOptions;\n /**\n * Audio recording options for persisting the audio to a local file path.\n */\n recordingOptions?: RecordingOptions;\n /**\n * Default: `\"android.speech.action.RECOGNIZE_SPEECH\"`\n *\n * The kind of intent action\n *\n * Intents:\n *\n * - [`android.speech.action.RECOGNIZE_SPEECH`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_RECOGNIZE_SPEECH) which performs speech recognition (default)\n * - [`android.speech.action.VOICE_SEARCH_HANDS_FREE`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_VOICE_SEARCH_HANDS_FREE) - prompts the user for speech without requiring the user's visual attention or touch input\n * - [`android.speech.action.WEB_SEARCH`](https://developer.android.com/reference/android/speech/RecognizerIntent#ACTION_WEB_SEARCH) - displays a web search result or trigger another type of action based on the user's speech.\n */\n androidIntent?:\n | \"android.speech.action.RECOGNIZE_SPEECH\"\n | \"android.speech.action.VOICE_SEARCH_HANDS_FREE\"\n | \"android.speech.action.WEB_SEARCH\";\n\n /**\n * The hint for the speech recognition task.\n *\n * Default: `\"unspecified\"`\n *\n * Docs: https://developer.apple.com/documentation/speech/sfspeechrecognitiontaskhint\n */\n iosTaskHint?: IOSTaskHintValue;\n\n /**\n * The audio category for the speech recognition task.\n *\n * Use this option to configure the default audio session category and mode prior to starting speech recognition.\n *\n * **Caution:** confirm that the category, options and mode are compatible with the audio source.\n *\n * By default, the audio session category and mode are set to:\n *\n * - category: `playAndRecord`\n * - options: `defaultToSpeaker` and `allowBluetooth`\n * - mode: `measurement`\n *\n * Docs: https://developer.apple.com/documentation/avfaudio/avaudiosession/category\n */\n iosCategory?: SetCategoryOptions;\n};\n\nexport type IOSTaskHintValue = (typeof TaskHintIOS)[keyof typeof TaskHintIOS];\n\nexport type RecordingOptions = {\n /**\n * Whether to persist the audio to a local file path.\n *\n * Default: false\n */\n persist: boolean;\n /**\n * Default: `FileSystem.CacheDirectory`. This changes the default storage location for the audio file.\n */\n outputDirectory?: string;\n /**\n * Default: `\"recording_${timestamp|uuid}.[wav|caf]\"`. This changes the file name for the audio file.\n */\n outputFileName?: string;\n /**\n * Default: undefined. The sample rate of the output audio file.\n *\n * Only supported on iOS\n *\n * Default sample rate is: 16000 on Android, 44100/48000 on iOS\n */\n outputSampleRate?: number;\n /**\n * Default: undefined. The encoding of the output audio file.\n *\n * Only supported on iOS\n */\n outputEncoding?:\n | \"pcmFormatFloat32\"\n | \"pcmFormatFloat64\"\n | \"pcmFormatInt16\"\n | \"pcmFormatInt32\";\n};\n\nexport type AudioSourceOptions = {\n /**\n * Local audio source URI.\n *\n * e.g. `\"file:///storage/emulated/0/Download/audio.wav\"`\n */\n uri: string;\n /**\n * [Android only] The number of channels in the source audio.\n *\n * Default: 1\n */\n audioChannels?: number;\n /**\n * [Android only] A value from [AudioFormat](https://developer.android.com/reference/android/media/AudioFormat).\n *\n * Use the `AudioEncodingAndroid` enum to get the correct value.\n */\n audioEncoding?: AudioEncodingAndroidValue;\n /**\n * [Android only] Audio sampling rate in Hz.\n *\n * Default: 16000\n */\n sampleRate?: number;\n /**\n * [Android only] The delay for a 4KiB chunk of audio to stream to the speech recognition service.\n *\n * Use this setting to avoid being rate-limited when using network-based recognition.\n *\n * If you're using on-device recognition, you may want to increase this value to avoid unprocessed audio chunks.\n *\n * Default: 50ms for network-based recognition, 15ms for on-device recognition\n */\n chunkDelayMillis?: number;\n};\n\nexport type AudioEncodingAndroidValue =\n (typeof AudioEncodingAndroid)[keyof typeof AudioEncodingAndroid];\n\nexport type AndroidIntentOptions = {\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_CALLING_PACKAGE\n *\n * The extra key used in an intent to the speech recognizer for voice search. Not generally to be used by developers. The system search dialog uses this, for example, to set a calling package for identification by a voice search API. If this extra is set by anyone but the system process, it should be overridden by the voice search implementation.\n */\n EXTRA_CALLING_PACKAGE: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_BIASING_DEVICE_CONTEXT\n *\n * Optional boolean to enable biasing towards device context. The recognizer will use the device context to tune the recognition results.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_ENABLE_BIASING_DEVICE_CONTEXT: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_DETECTION\n *\n * Optional boolean indicating whether to enable language detection. When enabled, the recognizer will consistently identify the language of the current spoken utterance and provide that info via RecognitionListener#onLanguageDetection(Bundle).\n */\n EXTRA_ENABLE_LANGUAGE_DETECTION: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_SWITCH\n *\n * Optional string to enable automatic switching to the language being spoken with the desired sensitivity level, instead of being restricted to a single language. The corresponding language models must be downloaded to support the switch. Otherwise, the recognizer will report an error on a switch failure. The recognizer provides the switch results via RecognitionListener#onLanguageDetection(Bundle).\n *\n * Since detection is a necessary requirement for the language switching, setting this value implicitly enables EXTRA_ENABLE_LANGUAGE_DETECTION.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_ENABLE_LANGUAGE_SWITCH: (typeof RecognizerIntentEnableLanguageSwitch)[keyof typeof RecognizerIntentEnableLanguageSwitch];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION\n *\n * [API level 33] Optional boolean, to be used with EXTRA_ENABLE_FORMATTING, to prevent the recognizer adding punctuation after the last word of the partial results. The default is false.\n */\n EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION: boolean;\n /**\n * Optional list of IETF language tags (as defined by BCP 47, e.g. \"en-US\", \"de-DE\").\n *\n * [API level 34] This extra is to be used with EXTRA_ENABLE_LANGUAGE_DETECTION. If set, the recognizer will constrain the language detection output to this list of languages, potentially improving detection accuracy.\n */\n EXTRA_LANGUAGE_DETECTION_ALLOWED_LANGUAGES: string[];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_MODEL\n *\n * [Default: free_form] The language model to use for speech recognition.\n *\n * Informs the recognizer which speech model to prefer when performing ACTION_RECOGNIZE_SPEECH.\n * The recognizer uses this information to fine tune the results.\n * This extra is required. Activities implementing ACTION_RECOGNIZE_SPEECH may interpret the values as they see fit.\n */\n EXTRA_LANGUAGE_MODEL: (typeof RecognizerIntentExtraLanguageModel)[keyof typeof RecognizerIntentExtraLanguageModel];\n\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_ALLOWED_LANGUAGES\n *\n * [API level 34] Optional list of IETF language tags (as defined by BCP 47, e.g. \"en-US\", \"de-DE\").\n * This extra is to be used with EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the recognizer will apply the auto switch only to these languages, even if the speech models of other languages also exist.\n * The corresponding language models must be downloaded to support the switch. Otherwise, the recognizer will report an error on a switch failure.\n */\n EXTRA_LANGUAGE_SWITCH_ALLOWED_LANGUAGES: string[];\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS\n *\n * [API level 35] Optional integer to use for EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the language switch will only be activated for this value of ms of audio since the START_OF_SPEECH. This could provide a more stable recognition result when the language switch is only required in the beginning of the session.\n */\n EXTRA_LANGUAGE_SWITCH_INITIAL_ACTIVE_DURATION_TIME_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_LANGUAGE_SWITCH_MAX_SWITCHES\n *\n * [API level 35] Optional integer to use for EXTRA_ENABLE_LANGUAGE_SWITCH. If set, the language switch will be deactivated when LANGUAGE_SWITCH_MAX_SWITCHES reached.\n *\n * Depending on the recognizer implementation, this flag may have no effect.\n */\n EXTRA_LANGUAGE_SWITCH_MAX_SWITCHES: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_MASK_OFFENSIVE_WORDS\n *\n * [API level 33] Optional boolean indicating whether the recognizer should mask the offensive words in recognition results. The Default is true.\n *\n * Constant Value: \"android.speech.extra.MASK_OFFENSIVE_WORDS\"\n */\n EXTRA_MASK_OFFENSIVE_WORDS: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ORIGIN\n *\n * Optional value which can be used to indicate the referer url of a page in which speech was requested. For example, a web browser may choose to provide this for uses of speech on a given page.\n */\n EXTRA_ORIGIN: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_PREFER_OFFLINE\n *\n * Optional boolean, to be used with ACTION_RECOGNIZE_SPEECH, ACTION_VOICE_SEARCH_HANDS_FREE, ACTION_WEB_SEARCH to indicate whether to only use an offline speech recognition engine. The default is false, meaning that either network or offline recognition engines may be used.\n *\n * Depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_PREFER_OFFLINE: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_PROMPT\n *\n * Optional text prompt to show to the user when asking them to speak.\n */\n EXTRA_PROMPT: string;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_CONFIDENCE\n *\n * [API level 34] Optional boolean indicating whether the recognizer should return the confidence level of each word in the final recognition results.\n */\n EXTRA_REQUEST_WORD_CONFIDENCE: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_TIMING\n *\n * [API level 34] Optional boolean indicating whether the recognizer should return the timestamp of each word in the final recognition results.\n */\n EXTRA_REQUEST_WORD_TIMING: boolean;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SECURE\n *\n * Optional boolean to indicate that a \"hands free\" voice search was performed while the device was in a secure mode. An example of secure mode is when the device's screen lock is active, and it requires some form of authentication to be unlocked. When the device is securely locked, the voice search activity should either restrict the set of voice actions that are permitted, or require some form of secure authentication before proceeding.\n */\n EXTRA_SECURE: boolean;\n /**\n * Optional string to enable segmented session mode of the specified type,\n * which can be `EXTRA_AUDIO_SOURCE`, `EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS` or `EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS`.\n * When segmented session mode is supported by the recognizer implementation and this extra is set,\n * it will return the recognition results in segments via [RecognitionListener#onSegmentResults(Bundle)](https://developer.android.com/reference/android/speech/RecognitionListener#onSegmentResults(android.os.Bundle))\n * and terminate the session with [RecognitionListener#onEndOfSegmentedSession()](https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSegmentedSession()).\n *\n * When setting this extra, make sure the extra used as the string value here is also set in the same intent with proper value.\n *\n * Depending on the recognizer implementation, this value may have no effect.\n */\n EXTRA_SEGMENTED_SESSION:\n | \"android.speech.extra.AUDIO_SOURCE\"\n | \"android.speech.extras.SPEECH_INPUT_MINIMUM_LENGTH_MILLIS\"\n | \"android.speech.extras.SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS\";\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS\n *\n * The amount of time that it should take after the recognizer stops hearing speech to consider the input complete hence end the recognition session.\n *\n * Note that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!\n *\n * Depending on the recognizer implementation, these values may have no effect.\n *\n */\n EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS\n *\n * Optional integer to indicate the minimum length of the recognition session. The recognizer will not stop recognizing speech before this amount of time.\n *\n * Note that it is extremely rare you'd want to specify this value in an intent. Generally, it should be specified only when it is also used as the value for EXTRA_SEGMENTED_SESSION to enable segmented session mode. Note also that certain values may cause undesired or unexpected results - use judiciously!\n *\n * Depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS: number;\n /**\n * https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS\n *\n * The amount of time that it should take after we stop hearing speech to consider the input possibly complete.\n * This is used to prevent the endpointer cutting off during very short mid-speech pauses.\n * Note that it is extremely rare you'd want to specify this value in an intent.\n * If you don't have a very good reason to change these, you should leave them as they are.\n * Note also that certain values may cause undesired or unexpected results - use judiciously!\n * Additionally, depending on the recognizer implementation, these values may have no effect.\n */\n EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS: number;\n};\n\nexport interface ExpoSpeechRecognitionModuleType extends NativeModule {\n /**\n * Starts speech recognition.\n */\n start(options: ExpoSpeechRecognitionOptions): void;\n /**\n * Stops speech recognition and attempts to return a final result (through the `result` event).\n */\n stop(): void;\n /**\n * Cancels speech recognition immediately without returning a final result.\n */\n abort(): void;\n /**\n * Presents a dialog to the user to request permissions for using speech recognition and the microphone.\n *\n * For iOS, once a user has granted (or denied) location permissions by responding to the original permission request dialog,\n * the only way that the permissions can be changed is by the user themselves using the device settings app.\n */\n requestPermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns the current permission status for the microphone and speech recognition.\n */\n getPermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns an array of locales supported by the speech recognizer.\n *\n * Not supported on Android 12 and below (API level 31), this will return an empty array of locales.\n *\n * @throws {\"package_not_found\"} If the service package is not found.\n * @throws {\"error_[number]\"} If there was an error retrieving the supported locales.\n */\n getSupportedLocales(options: {\n /**\n * The package name of the speech recognition service to use.\n *\n * e.g. \"com.google.android.as\" or \"com.samsung.android.bixby.agent\"\n *\n * Warning: the service package (such as Bixby) may not be able to return any results.\n */\n androidRecognitionServicePackage?: string;\n }): Promise<{\n /**\n * All supported languages on the device. This includes both installed and supported languages.\n */\n locales: string[];\n /**\n * These languages are installed on to the device for offline use.\n *\n * This will likely be an empty array if the service package is not \"com.google.android.as\"\n */\n installedLocales: string[];\n }>;\n /**\n * [Android only] Returns an array of package names of speech recognition services that are available on the device.\n *\n * List of all available services as bundle identifiers, e.g. [\"com.google.android.as\", \"com.google.android.tts\"]\n */\n getSpeechRecognitionServices(): string[];\n /**\n * [Android only] Returns the default voice recognition service on the device.\n *\n * @returns empty string if no service is found, or not Android\n */\n getDefaultRecognitionService(): {\n /** e.g. \"com.google.android.tts\" or \"com.google.android.googlequicksearchbox\" */\n packageName: string;\n };\n /**\n * [Android only] Returns the default voice recognition service on the device.\n *\n * e.g. \"com.google.android.googlequicksearchbox\" or \"com.samsung.android.bixby.agent\"\n *\n * @returns empty string if no service is found, or not Android\n */\n getAssistantService(): {\n /** e.g. \"com.google.android.googlequicksearchbox\" or \"com.samsung.android.bixby.agent\" */\n packageName: string;\n };\n /**\n * Whether the on-device speech recognition is available on the device.\n */\n supportsOnDeviceRecognition(): boolean;\n /**\n * Whether the recording feature is available on the device.\n *\n * This mostly applies to Android devices, to check if it's greater than Android 13.\n */\n supportsRecording(): boolean;\n /**\n * Whether on-device speech recognition is available.\n *\n * If this method returns false, `start()` will fail and emit an error event with the code `service-not-allowed` or `language-not-supported`.\n */\n isRecognitionAvailable(): boolean;\n\n /**\n * Downloads the offline model for the specified locale.\n * Note: this is only supported on Android 13 and above.\n */\n androidTriggerOfflineModelDownload(options: {\n /** The locale to download the model for, e.g. \"en-US\" */\n locale: string;\n }): Promise<{\n /**\n * On Android 13, the status will be \"opened_dialog\" indicating that the model download dialog was opened.\n * On Android 14+, the status will be \"download_success\" indicating that the model download was successful.\n * On Android 14+, \"download_canceled\" will be returned if the download was canceled by a user interaction.\n */\n status: \"download_success\" | \"opened_dialog\" | \"download_canceled\";\n message: string;\n }>;\n /**\n * [iOS only] For advanced use cases, you may use this function to set the audio session category and mode.\n *\n * See: https://developer.apple.com/documentation/avfaudio/avaudiosession/1771734-setcategory\n */\n setCategoryIOS(options: SetCategoryOptions): void;\n\n /**\n * [iOS only] Returns the current audio session category and options.\n *\n * See:\n * - [AVAudioSession.Category](https://developer.apple.com/documentation/avfaudio/avaudiosession/category)\n * - [AVAudioSession.CategoryOptions](https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions)\n * - [AVAudioSession.Mode](https://developer.apple.com/documentation/avfaudio/avaudiosession/mode)\n */\n getAudioSessionCategoryAndOptionsIOS(): {\n category: AVAudioSessionCategoryValue;\n categoryOptions: AVAudioSessionCategoryOptionsValue[];\n mode: AVAudioSessionModeValue;\n };\n /**\n * [iOS only] Sets the shared audio session active state.\n *\n * Calls the following on iOS: `AVAudioSession.sharedInstance().setActive(value, options)`\n *\n * See: https://developer.apple.com/documentation/avfaudio/avaudiosession/1616627-setactive\n */\n setAudioSessionActiveIOS(\n value: boolean,\n options?: {\n /** [Default: true] Whether to notify other audio sessions when the active state changes. */\n notifyOthersOnDeactivation: boolean;\n },\n ): void;\n /**\n * Returns the current state of the speech recognizer.\n */\n getStateAsync(): Promise<SpeechRecognitionState>;\n}\n\nexport type SetCategoryOptions = {\n category: AVAudioSessionCategoryValue;\n categoryOptions: AVAudioSessionCategoryOptionsValue[];\n mode?: AVAudioSessionModeValue;\n};\n\ntype SpeechRecognitionState =\n | \"inactive\"\n | \"starting\"\n | \"recognizing\"\n | \"stopping\";\n\n/**\n * [iOS only] See: [AVAudioSession.CategoryOptions](https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions)\n *\n * Use the `AVAudioSessionCategoryOptions` enum to get the correct value.\n */\nexport type AVAudioSessionCategoryOptionsValue =\n (typeof AVAudioSessionCategoryOptions)[keyof typeof AVAudioSessionCategoryOptions];\n\n/**\n * [iOS only] See: [AVAudioSession.Mode](https://developer.apple.com/documentation/avfaudio/avaudiosession/mode)\n *\n * Use the `AVAudioSessionMode` enum to get the correct value.\n */\nexport type AVAudioSessionModeValue =\n (typeof AVAudioSessionMode)[keyof typeof AVAudioSessionMode];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mCAAmC,EACpC,MAAM,qCAAqC,CAAC;AAM7C,eAAO,MAAM,2BAA2B,EAAE,+
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mCAAmC,EACpC,MAAM,qCAAqC,CAAC;AAM7C,eAAO,MAAM,2BAA2B,EAAE,+BA4HzC,CAAC;AAwCF,eAAO,MAAM,kCAAkC;sBACd,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;sBACtC,GAAG,CAEhC,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,EAEpB,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CACrB;gBACW,CAAC,SAAS,MAAM,yBAAyB,aACxC,CAAC,YACF,CAAC,EAAE,EAAE,mCAAmC,CAAC,CAAC,CAAC,KAAK,IAAI;;;gCAoCpC,MAAM,YAAY,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI;oCAalC,MAAM;CA8BvC,CAAC"}
|
|
@@ -60,23 +60,19 @@ export const ExpoSpeechRecognitionModule = {
|
|
|
60
60
|
console.warn("removeListeners is not supported. Use ExpoSpeechRecognitionModuleEmitter.removeListener(eventName, listener) instead.");
|
|
61
61
|
},
|
|
62
62
|
getSpeechRecognitionServices: () => {
|
|
63
|
-
console.warn("getSpeechRecognitionServices is not supported on web. Returning an empty array.");
|
|
64
63
|
return [];
|
|
65
64
|
},
|
|
66
65
|
getDefaultRecognitionService: () => {
|
|
67
|
-
console.warn("getDefaultRecognitionService is not supported on web. Returning an empty object.");
|
|
68
66
|
return {
|
|
69
67
|
packageName: "",
|
|
70
68
|
};
|
|
71
69
|
},
|
|
72
70
|
getAssistantService: () => {
|
|
73
|
-
console.warn("getAssistantService is not supported on web. Returning an empty object.");
|
|
74
71
|
return {
|
|
75
72
|
packageName: "",
|
|
76
73
|
};
|
|
77
74
|
},
|
|
78
75
|
supportsOnDeviceRecognition: () => {
|
|
79
|
-
console.warn("supportsOnDeviceRecognition is not supported on web. Returning false.");
|
|
80
76
|
return false;
|
|
81
77
|
},
|
|
82
78
|
supportsRecording: () => {
|
|
@@ -103,6 +99,11 @@ export const ExpoSpeechRecognitionModule = {
|
|
|
103
99
|
setAudioSessionActiveIOS: () => {
|
|
104
100
|
console.warn("setAudioSessionActiveIOS is not supported on web.");
|
|
105
101
|
},
|
|
102
|
+
isRecognitionAvailable: () => {
|
|
103
|
+
const hasSpeechRecognitionAPI = typeof webkitSpeechRecognition !== "undefined" ||
|
|
104
|
+
typeof SpeechRecognition !== "undefined";
|
|
105
|
+
return hasSpeechRecognitionAPI;
|
|
106
|
+
},
|
|
106
107
|
};
|
|
107
108
|
/**
|
|
108
109
|
* Convert the web SpeechRecognitionEventMap to the native event map for compatibility
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSpeechRecognitionModule.web.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AAMA,IAAI,qBAAqB,GAA6B,IAAI,CAAC;AAE3D,kEAAkE;AAClE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,2BAA2B,GAAoC;IAC1E,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,sBAAsB,GAC1B,OAAO,uBAAuB,KAAK,WAAW;YAC5C,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,iBAAiB,CAAC;QACxB,qBAAqB,GAAG,IAAI,sBAAsB,EAAE,CAAC;QACrD,qBAAqB,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC;QACrD,qBAAqB,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC;QACvE,qBAAqB,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,CAAC,CAAC;QACrE,qBAAqB,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;QAE/D,oDAAoD;QACpD,oGAAoG;QACpG,kCAAkC,CAAC,g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H,CAAC;YAED,8BAA8B;YAC9B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACvC,kCAAkC,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACzE,CAAC;YAED,WAAW;YACX,kCAAkC,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type {\n ExpoSpeechRecognitionModuleType,\n ExpoSpeechRecognitionNativeEventMap,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nlet _speechRecognitionRef: SpeechRecognition | null = null;\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.\nexport const ExpoSpeechRecognitionModule: ExpoSpeechRecognitionModuleType = {\n start: (options) => {\n const SpeechRecognitionClass =\n typeof webkitSpeechRecognition !== \"undefined\"\n ? webkitSpeechRecognition\n : SpeechRecognition;\n _speechRecognitionRef = new SpeechRecognitionClass();\n _speechRecognitionRef.lang = options.lang ?? \"en-US\";\n _speechRecognitionRef.interimResults = options.interimResults ?? false;\n _speechRecognitionRef.maxAlternatives = options.maxAlternatives ?? 1;\n _speechRecognitionRef.continuous = options.continuous ?? false;\n\n // Re-subscribe to events so that we don't lose them\n // This covers the case where the user has already subscribed to an event prior to calling `start()`\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.forEach(\n (listeners, eventName) => {\n for (const listener of listeners) {\n // May already be subscribed\n _speechRecognitionRef?.removeEventListener(eventName, listener);\n _speechRecognitionRef?.addEventListener(eventName, listener);\n }\n },\n );\n\n // Start the speech recognition!\n _speechRecognitionRef.start();\n },\n getStateAsync: () => {\n console.warn(\n \"getStateAsync is not supported on web. Returning 'inactive'.\",\n );\n return Promise.resolve(\"inactive\");\n },\n stop: () => _speechRecognitionRef?.stop(),\n abort: () => _speechRecognitionRef?.abort(),\n requestPermissionsAsync: () => {\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n },\n getPermissionsAsync: () => {\n console.warn(\n \"getPermissionsAsync is not supported on web. Returning a denied permission response.\",\n );\n return Promise.resolve({\n granted: false,\n canAskAgain: false,\n expires: \"never\",\n status: \"denied\",\n } as PermissionResponse);\n },\n getSupportedLocales: async () => {\n console.warn(\n \"getSupportedLocales is not supported on web. Returning an empty array.\",\n );\n return {\n locales: [] as string[],\n installedLocales: [] as string[],\n };\n },\n addListener: () => {\n console.warn(\n \"addListener is not supported. Use ExpoSpeechRecognitionModuleEmitter(eventName, listener) instead.\",\n );\n },\n removeListeners: () => {\n console.warn(\n \"removeListeners is not supported. Use ExpoSpeechRecognitionModuleEmitter.removeListener(eventName, listener) instead.\",\n );\n },\n getSpeechRecognitionServices: () => {\n console.warn(\n \"getSpeechRecognitionServices is not supported on web. Returning an empty array.\",\n );\n return [] as string[];\n },\n getDefaultRecognitionService: () => {\n console.warn(\n \"getDefaultRecognitionService is not supported on web. Returning an empty object.\",\n );\n return {\n packageName: \"\",\n };\n },\n getAssistantService: () => {\n console.warn(\n \"getAssistantService is not supported on web. Returning an empty object.\",\n );\n return {\n packageName: \"\",\n };\n },\n supportsOnDeviceRecognition: () => {\n console.warn(\n \"supportsOnDeviceRecognition is not supported on web. Returning false.\",\n );\n return false;\n },\n supportsRecording: () => {\n return false;\n },\n androidTriggerOfflineModelDownload: () => {\n console.warn(\n \"androidTriggerOfflineModelDownload is not supported on web. Returning false.\",\n );\n return Promise.resolve({\n status: \"opened_dialog\",\n message: \"Offline model download is not supported on web.\",\n });\n },\n setCategoryIOS: () => {\n console.warn(\"setCategoryIOS is not supported on web.\");\n },\n getAudioSessionCategoryAndOptionsIOS: () => {\n console.warn(\n \"getAudioSessionCategoryAndOptionsIOS is not supported on web.\",\n );\n return {\n category: \"playAndRecord\",\n categoryOptions: [\"defaultToSpeaker\", \"allowBluetooth\"],\n mode: \"measurement\",\n };\n },\n setAudioSessionActiveIOS: () => {\n console.warn(\"setAudioSessionActiveIOS is not supported on web.\");\n },\n};\n\n/**\n * Convert the web SpeechRecognitionEventMap to the native event map for compatibility\n */\nconst webToNativeEventMap: {\n [K in keyof SpeechRecognitionEventMap]: (\n ev: SpeechRecognitionEventMap[K],\n ) => ExpoSpeechRecognitionNativeEventMap[K];\n} = {\n audioend: (ev) => ({ uri: null }),\n audiostart: (ev) => ({ uri: null }),\n end: (ev) => null,\n error: (ev) => ({ error: ev.error, message: ev.message }),\n nomatch: (ev) => null,\n result: (ev) => {\n const nativeResults: ExpoSpeechRecognitionNativeEventMap[\"result\"][\"results\"] =\n [];\n\n for (let i = 0; i < ev.results[ev.resultIndex].length; i++) {\n const result = ev.results[ev.resultIndex][i];\n nativeResults.push({\n transcript: result.transcript,\n confidence: result.confidence,\n segments: [],\n });\n }\n\n return {\n isFinal: Boolean(ev.results[ev.resultIndex]?.isFinal),\n results: nativeResults,\n };\n },\n soundstart: (ev) => null,\n speechend: (ev) => null,\n speechstart: (ev) => null,\n start: (ev) => null,\n soundend: (ev) => null,\n};\nexport const ExpoSpeechRecognitionModuleEmitter = {\n _nativeListeners: new Map() as Map<string, Set<(event: any) => void>>,\n _clientListeners: new Map() as Map<\n // Original listener\n (event: any) => void,\n // Native listener\n (event: any) => void\n >,\n addListener<T extends keyof SpeechRecognitionEventMap>(\n eventName: T,\n listener: (ev: ExpoSpeechRecognitionNativeEventMap[T]) => void,\n ) {\n // Convert the web event to the native event\n const nativeListener = (ev: SpeechRecognitionEventMap[T]) => {\n const eventPayload = webToNativeEventMap[eventName]?.(ev);\n listener(eventPayload);\n };\n\n _speechRecognitionRef?.addEventListener(eventName, nativeListener);\n if (!ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.set(\n eventName,\n new Set(),\n );\n }\n // Add the original listener to the enhanced listeners\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.add(nativeListener);\n\n // Map the original listener to the enhanced listener\n ExpoSpeechRecognitionModuleEmitter._clientListeners.set(\n listener,\n nativeListener,\n );\n\n return {\n remove: () => {\n _speechRecognitionRef?.removeEventListener(eventName, nativeListener);\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.delete(nativeListener);\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n },\n };\n },\n removeListener: (eventName: string, listener: (event: any) => void) => {\n const resolvedListener =\n ExpoSpeechRecognitionModuleEmitter._clientListeners.get(listener) ??\n listener;\n\n _speechRecognitionRef?.removeEventListener(eventName, resolvedListener);\n if (ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.delete(listener);\n }\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n },\n removeAllListeners: (eventName: string) => {\n // Go through _listeners and remove all listeners for this event\n if (ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n const nativeListeners =\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.get(eventName);\n if (!nativeListeners) {\n return;\n }\n\n // Remove the enhanced listeners\n for (const [\n listener,\n nativeListener,\n ] of ExpoSpeechRecognitionModuleEmitter._clientListeners) {\n // if nativeListener in listeners, remove it\n if (nativeListeners.has(nativeListener)) {\n // Remove the enhanced listener\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n }\n }\n\n // Remove the native listeners\n for (const listener of nativeListeners) {\n ExpoSpeechRecognitionModuleEmitter.removeListener(eventName, listener);\n }\n\n // Clean up\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.delete(eventName);\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoSpeechRecognitionModule.web.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AAMA,IAAI,qBAAqB,GAA6B,IAAI,CAAC;AAE3D,kEAAkE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AC;IACD,kBAAkB,EAAE,CAAC,SAAiB,EAAE,EAAE;QACxC,gEAAgE;QAChE,IAAI,kCAAkC,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACvE,MAAM,eAAe,GACnB,kCAAkC,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACrE,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrB,OAAO;YACT,CAAC;YAED,gCAAgC;YAChC,KAAK,MAAM,CACT,QAAQ,EACR,cAAc,EACf,IAAI,kCAAkC,CAAC,gBAAgB,EAAE,CAAC;gBACzD,4CAA4C;gBAC5C,IAAI,eAAe,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;oBACxC,+BAA+B;oBAC/B,kCAAkC,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;YAED,8BAA8B;YAC9B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACvC,kCAAkC,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACzE,CAAC;YAED,WAAW;YACX,kCAAkC,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;CACF,CAAC","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type {\n ExpoSpeechRecognitionModuleType,\n ExpoSpeechRecognitionNativeEventMap,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nlet _speechRecognitionRef: SpeechRecognition | null = null;\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.\nexport const ExpoSpeechRecognitionModule: ExpoSpeechRecognitionModuleType = {\n start: (options) => {\n const SpeechRecognitionClass =\n typeof webkitSpeechRecognition !== \"undefined\"\n ? webkitSpeechRecognition\n : SpeechRecognition;\n _speechRecognitionRef = new SpeechRecognitionClass();\n _speechRecognitionRef.lang = options.lang ?? \"en-US\";\n _speechRecognitionRef.interimResults = options.interimResults ?? false;\n _speechRecognitionRef.maxAlternatives = options.maxAlternatives ?? 1;\n _speechRecognitionRef.continuous = options.continuous ?? false;\n\n // Re-subscribe to events so that we don't lose them\n // This covers the case where the user has already subscribed to an event prior to calling `start()`\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.forEach(\n (listeners, eventName) => {\n for (const listener of listeners) {\n // May already be subscribed\n _speechRecognitionRef?.removeEventListener(eventName, listener);\n _speechRecognitionRef?.addEventListener(eventName, listener);\n }\n },\n );\n\n // Start the speech recognition!\n _speechRecognitionRef.start();\n },\n getStateAsync: () => {\n console.warn(\n \"getStateAsync is not supported on web. Returning 'inactive'.\",\n );\n return Promise.resolve(\"inactive\");\n },\n stop: () => _speechRecognitionRef?.stop(),\n abort: () => _speechRecognitionRef?.abort(),\n requestPermissionsAsync: () => {\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n },\n getPermissionsAsync: () => {\n console.warn(\n \"getPermissionsAsync is not supported on web. Returning a denied permission response.\",\n );\n return Promise.resolve({\n granted: false,\n canAskAgain: false,\n expires: \"never\",\n status: \"denied\",\n } as PermissionResponse);\n },\n getSupportedLocales: async () => {\n console.warn(\n \"getSupportedLocales is not supported on web. Returning an empty array.\",\n );\n return {\n locales: [] as string[],\n installedLocales: [] as string[],\n };\n },\n addListener: () => {\n console.warn(\n \"addListener is not supported. Use ExpoSpeechRecognitionModuleEmitter(eventName, listener) instead.\",\n );\n },\n removeListeners: () => {\n console.warn(\n \"removeListeners is not supported. Use ExpoSpeechRecognitionModuleEmitter.removeListener(eventName, listener) instead.\",\n );\n },\n getSpeechRecognitionServices: () => {\n return [] as string[];\n },\n getDefaultRecognitionService: () => {\n return {\n packageName: \"\",\n };\n },\n getAssistantService: () => {\n return {\n packageName: \"\",\n };\n },\n supportsOnDeviceRecognition: () => {\n return false;\n },\n supportsRecording: () => {\n return false;\n },\n androidTriggerOfflineModelDownload: () => {\n console.warn(\n \"androidTriggerOfflineModelDownload is not supported on web. Returning false.\",\n );\n return Promise.resolve({\n status: \"opened_dialog\",\n message: \"Offline model download is not supported on web.\",\n });\n },\n setCategoryIOS: () => {\n console.warn(\"setCategoryIOS is not supported on web.\");\n },\n getAudioSessionCategoryAndOptionsIOS: () => {\n console.warn(\n \"getAudioSessionCategoryAndOptionsIOS is not supported on web.\",\n );\n return {\n category: \"playAndRecord\",\n categoryOptions: [\"defaultToSpeaker\", \"allowBluetooth\"],\n mode: \"measurement\",\n };\n },\n setAudioSessionActiveIOS: () => {\n console.warn(\"setAudioSessionActiveIOS is not supported on web.\");\n },\n isRecognitionAvailable: () => {\n const hasSpeechRecognitionAPI =\n typeof webkitSpeechRecognition !== \"undefined\" ||\n typeof SpeechRecognition !== \"undefined\";\n\n return hasSpeechRecognitionAPI;\n },\n};\n\n/**\n * Convert the web SpeechRecognitionEventMap to the native event map for compatibility\n */\nconst webToNativeEventMap: {\n [K in keyof SpeechRecognitionEventMap]: (\n ev: SpeechRecognitionEventMap[K],\n ) => ExpoSpeechRecognitionNativeEventMap[K];\n} = {\n audioend: (ev) => ({ uri: null }),\n audiostart: (ev) => ({ uri: null }),\n end: (ev) => null,\n error: (ev) => ({ error: ev.error, message: ev.message }),\n nomatch: (ev) => null,\n result: (ev) => {\n const nativeResults: ExpoSpeechRecognitionNativeEventMap[\"result\"][\"results\"] =\n [];\n\n for (let i = 0; i < ev.results[ev.resultIndex].length; i++) {\n const result = ev.results[ev.resultIndex][i];\n nativeResults.push({\n transcript: result.transcript,\n confidence: result.confidence,\n segments: [],\n });\n }\n\n return {\n isFinal: Boolean(ev.results[ev.resultIndex]?.isFinal),\n results: nativeResults,\n };\n },\n soundstart: (ev) => null,\n speechend: (ev) => null,\n speechstart: (ev) => null,\n start: (ev) => null,\n soundend: (ev) => null,\n};\n\nexport const ExpoSpeechRecognitionModuleEmitter = {\n _nativeListeners: new Map() as Map<string, Set<(event: any) => void>>,\n _clientListeners: new Map() as Map<\n // Original listener\n (event: any) => void,\n // Native listener\n (event: any) => void\n >,\n addListener<T extends keyof SpeechRecognitionEventMap>(\n eventName: T,\n listener: (ev: ExpoSpeechRecognitionNativeEventMap[T]) => void,\n ) {\n // Convert the web event to the native event\n const nativeListener = (ev: SpeechRecognitionEventMap[T]) => {\n const eventPayload = webToNativeEventMap[eventName]?.(ev);\n listener(eventPayload);\n };\n\n _speechRecognitionRef?.addEventListener(eventName, nativeListener);\n if (!ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.set(\n eventName,\n new Set(),\n );\n }\n // Add the original listener to the enhanced listeners\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.add(nativeListener);\n\n // Map the original listener to the enhanced listener\n ExpoSpeechRecognitionModuleEmitter._clientListeners.set(\n listener,\n nativeListener,\n );\n\n return {\n remove: () => {\n _speechRecognitionRef?.removeEventListener(eventName, nativeListener);\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.delete(nativeListener);\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n },\n };\n },\n removeListener: (eventName: string, listener: (event: any) => void) => {\n const resolvedListener =\n ExpoSpeechRecognitionModuleEmitter._clientListeners.get(listener) ??\n listener;\n\n _speechRecognitionRef?.removeEventListener(eventName, resolvedListener);\n if (ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n ExpoSpeechRecognitionModuleEmitter._nativeListeners\n .get(eventName)\n ?.delete(listener);\n }\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n },\n removeAllListeners: (eventName: string) => {\n // Go through _listeners and remove all listeners for this event\n if (ExpoSpeechRecognitionModuleEmitter._nativeListeners.has(eventName)) {\n const nativeListeners =\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.get(eventName);\n if (!nativeListeners) {\n return;\n }\n\n // Remove the enhanced listeners\n for (const [\n listener,\n nativeListener,\n ] of ExpoSpeechRecognitionModuleEmitter._clientListeners) {\n // if nativeListener in listeners, remove it\n if (nativeListeners.has(nativeListener)) {\n // Remove the enhanced listener\n ExpoSpeechRecognitionModuleEmitter._clientListeners.delete(listener);\n }\n }\n\n // Remove the native listeners\n for (const listener of nativeListeners) {\n ExpoSpeechRecognitionModuleEmitter.removeListener(eventName, listener);\n }\n\n // Clean up\n ExpoSpeechRecognitionModuleEmitter._nativeListeners.delete(eventName);\n }\n },\n};\n"]}
|
|
@@ -74,7 +74,7 @@ export declare class ExpoWebSpeechRecognition implements SpeechRecognition {
|
|
|
74
74
|
onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
75
75
|
/** [TODO] */
|
|
76
76
|
onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
77
|
-
addEventListener<K extends keyof SpeechRecognitionEventMap>(type: K, listener:
|
|
77
|
+
addEventListener<K extends keyof SpeechRecognitionEventMap>(type: K, listener: SpeechListener<K>, options?: boolean | AddEventListenerOptions): void;
|
|
78
78
|
removeEventListener<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
79
79
|
dispatchEvent(event: Event): boolean;
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoWebSpeechRecognition.d.ts","sourceRoot":"","sources":["../src/ExpoWebSpeechRecognition.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,qCAAqC,CAAC;AAiJ7C,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,yBAAyB,IAAI,CAC/D,IAAI,EAAE,iBAAiB,EACvB,EAAE,EAAE,yBAAyB,CAAC,CAAC,CAAC,KAC7B,GAAG,CAAC;AAET,8FAA8F;AAC9F,qBAAa,wBAAyB,YAAW,iBAAiB;;IAChE,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CAAC,EACP,QAAQ,EAAE,CACR,IAAI,EAAE,iBAAiB,EACvB,EAAE,EAAE,yBAAyB,CAAC,CAAC,CAAC,KAC7B,GAAG,EACR,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,GACnD,IAAI;IAUP,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;CAGrC;AAED;;GAEG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;;IAChE,IAAI,MAAM,WAET;IAED,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC;IAE/B,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAI1D,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB;IAIzC,aAAa,YAAa,MAAM,WAAW,MAAM,UAK/C;CACH;AAED,qBAAa,oBAAqB,YAAW,aAAa;IACxD,GAAG,SAAM;IACT,MAAM,SAAK;gBAEC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAIzC"}
|
|
@@ -281,9 +281,9 @@ export class ExpoWebSpeechRecognition {
|
|
|
281
281
|
? ((ev) => {
|
|
282
282
|
listener.call(this, ev);
|
|
283
283
|
// remove the listeners from the map
|
|
284
|
-
this.#subscriptionMap.get(listener)
|
|
284
|
+
for (const sub of this.#subscriptionMap.get(listener) ?? []) {
|
|
285
285
|
sub.remove();
|
|
286
|
-
}
|
|
286
|
+
}
|
|
287
287
|
this.#subscriptionMap.delete(listener);
|
|
288
288
|
})
|
|
289
289
|
: listener;
|