expo-speech-recognition 0.2.22 → 0.2.25
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/CHANGELOG.md +7 -0
- package/README.md +112 -24
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechRecognitionModule.kt +22 -12
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechRecognitionOptions.kt +11 -0
- package/android/src/main/java/expo/modules/speechrecognition/ExpoSpeechService.kt +57 -3
- package/build/ExpoSpeechRecognitionModule.types.d.ts +60 -2
- package/build/ExpoSpeechRecognitionModule.types.d.ts.map +1 -1
- package/build/ExpoSpeechRecognitionModule.types.js.map +1 -1
- package/ios/ExpoSpeechRecognitionException.swift +6 -6
- package/ios/ExpoSpeechRecognitionModule.swift +38 -6
- package/ios/ExpoSpeechRecognizer.swift +115 -14
- package/ios/SpeechRecognitionOptions.swift +11 -0
- package/package.json +6 -1
- package/src/ExpoSpeechRecognitionModule.types.ts +62 -2
|
@@ -88,6 +88,23 @@ export type ExpoSpeechRecognitionErrorEvent = {
|
|
|
88
88
|
message: string;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
+
export type LanguageDetectionEvent = {
|
|
92
|
+
/** The language that was detected, in BCP-47 format. e.g. "en-US", "de-DE" */
|
|
93
|
+
detectedLanguage: string;
|
|
94
|
+
/** The confidence of the detected language. A value ranging between 0.0 and 1.0.
|
|
95
|
+
*
|
|
96
|
+
* Values range from:
|
|
97
|
+
*
|
|
98
|
+
* - 1.0 (highly confident)
|
|
99
|
+
* - 0.8 (confident)
|
|
100
|
+
* - 0.5 (not confident)
|
|
101
|
+
* - 0.0 (unknown)
|
|
102
|
+
*/
|
|
103
|
+
confidence: number;
|
|
104
|
+
/** The alternative locales for the same language, in BCP-47 format. e.g. ["en-US", "en-GB"] */
|
|
105
|
+
topLocaleAlternatives: string[];
|
|
106
|
+
};
|
|
107
|
+
|
|
91
108
|
/**
|
|
92
109
|
* Events that are dispatched from the native side
|
|
93
110
|
*/
|
|
@@ -127,6 +144,15 @@ export type ExpoSpeechRecognitionNativeEventMap = {
|
|
|
127
144
|
end: null;
|
|
128
145
|
soundstart: null;
|
|
129
146
|
soundend: null;
|
|
147
|
+
languagedetection: LanguageDetectionEvent;
|
|
148
|
+
volumechange: {
|
|
149
|
+
/**
|
|
150
|
+
* A float value between -2 and 10 indicating the volume of the input audio
|
|
151
|
+
*
|
|
152
|
+
* Consider anything below 0 to be inaudible
|
|
153
|
+
*/
|
|
154
|
+
value: number;
|
|
155
|
+
};
|
|
130
156
|
};
|
|
131
157
|
|
|
132
158
|
export type ExpoSpeechRecognitionOptions = {
|
|
@@ -149,7 +175,10 @@ export type ExpoSpeechRecognitionOptions = {
|
|
|
149
175
|
*
|
|
150
176
|
* Not supported on Android 12 and below.
|
|
151
177
|
*
|
|
152
|
-
* If false
|
|
178
|
+
* If false, the behaviors are the following:
|
|
179
|
+
*
|
|
180
|
+
* - on iOS 17-, recognition will run until no speech is detected for 3 seconds.
|
|
181
|
+
* - on iOS 18+ and Android, recognition will run until a result with `isFinal: true` is received.
|
|
153
182
|
*/
|
|
154
183
|
continuous?: boolean;
|
|
155
184
|
/** [Default: false] Prevent device from sending audio over the network. Only enabled if the device supports it.
|
|
@@ -160,7 +189,9 @@ export type ExpoSpeechRecognitionOptions = {
|
|
|
160
189
|
/**
|
|
161
190
|
* [Default: false] Include punctuation in the recognition results. This applies to full stops and commas.
|
|
162
191
|
*
|
|
163
|
-
* 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+).
|
|
192
|
+
* On Android, this configures [`EXTRA_ENABLE_FORMATTING`](https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING) in the recognizer intent (Android 13+, API level 33+).
|
|
193
|
+
*
|
|
194
|
+
* Note for Android: This feature is only verified to work on Android 13+ with on-device speech recognition enabled (i.e. enabling `requiresOnDeviceRecognition` or using the `com.google.android.as` service package)
|
|
164
195
|
*
|
|
165
196
|
* On iOS, this configures [`SFSpeechRecognitionRequest.addsPunctuation`](https://developer.apple.com/documentation/speech/sfspeechrecognitionrequest/3930023-addspunctuation).
|
|
166
197
|
*/
|
|
@@ -231,6 +262,26 @@ export type ExpoSpeechRecognitionOptions = {
|
|
|
231
262
|
* Docs: https://developer.apple.com/documentation/avfaudio/avaudiosession/category
|
|
232
263
|
*/
|
|
233
264
|
iosCategory?: SetCategoryOptions;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Settings for volume change events.
|
|
268
|
+
*/
|
|
269
|
+
volumeChangeEventOptions?: {
|
|
270
|
+
/**
|
|
271
|
+
* Whether to emit volume change events.
|
|
272
|
+
*
|
|
273
|
+
* Default: false
|
|
274
|
+
*/
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Specifies the interval (in milliseconds) to emit `volumechange` events.
|
|
278
|
+
*
|
|
279
|
+
* Default: 100ms on iOS
|
|
280
|
+
*
|
|
281
|
+
* Increasing this value will improve performance
|
|
282
|
+
*/
|
|
283
|
+
intervalMillis?: number;
|
|
284
|
+
};
|
|
234
285
|
};
|
|
235
286
|
|
|
236
287
|
export type IOSTaskHintValue = (typeof TaskHintIOS)[keyof typeof TaskHintIOS];
|
|
@@ -341,6 +392,15 @@ export type AndroidIntentOptions = {
|
|
|
341
392
|
* Depending on the recognizer implementation, this value may have no effect.
|
|
342
393
|
*/
|
|
343
394
|
EXTRA_ENABLE_LANGUAGE_SWITCH: (typeof RecognizerIntentEnableLanguageSwitch)[keyof typeof RecognizerIntentEnableLanguageSwitch];
|
|
395
|
+
/**
|
|
396
|
+
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING
|
|
397
|
+
*
|
|
398
|
+
* NOTE: This is also configurable through `addsPunctuation` (which sets `EXTRA_ENABLE_FORMATTING` to "quality")
|
|
399
|
+
*
|
|
400
|
+
* [API level 33] Optional string to enable text formatting (e.g. unspoken punctuation (examples: question mark, comma, period, etc.), capitalization, etc.) and specify the optimization strategy. If set, the partial and final result texts will be formatted. Each result list will contain two hypotheses in the order of 1) formatted text 2) raw text.
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
EXTRA_ENABLE_FORMATTING: "latency" | "quality";
|
|
344
404
|
/**
|
|
345
405
|
* https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_HIDE_PARTIAL_TRAILING_PUNCTUATION
|
|
346
406
|
*
|