expo-speech-recognition 56.0.0 → 56.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -64,8 +64,8 @@ expo-speech-recognition implements the iOS [`SFSpeechRecognizer`](https://develo
64
64
  npm install expo-speech-recognition
65
65
 
66
66
  # Or for older SDKs:
67
- npm install expo-speech-recognition@sdk-51
68
- npm install expo-speech-recognition@sdk-50
67
+ npm install expo-speech-recognition@sdk-54
68
+ npm install expo-speech-recognition@sdk-53
69
69
  ```
70
70
 
71
71
  2. Configure the config plugin.
@@ -523,17 +523,17 @@ Instead of using the microphone, you can configure the `audioSource.uri` option
523
523
 
524
524
  The following audio formats have been verified on a Samsung Galaxy S23 Ultra on Android 14:
525
525
 
526
- - 16000hz 16-bit 1-channel PCM WAV ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote-en-us-sentence-16000hz-pcm_s16le.wav))
527
- - 16000hz MP3 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote-en-us-sentence-16000hz.mp3))
526
+ - 16000hz 16-bit 1-channel PCM WAV ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote_en_us_sentence_16000hz_pcm_s16le.wav))
527
+ - 16000hz MP3 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote_en_us_sentence_16000hz.mp3))
528
528
  - 16000hz MP3 2-channel
529
- - 16000hz ogg vorbis 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote-en-us-sentence-16000hz.ogg))
529
+ - 16000hz ogg vorbis 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote_en_us_sentence_16000hz.ogg))
530
530
 
531
531
  #### iOS
532
532
 
533
533
  The following audio formats have been verified on an iPhone 15 Pro Max on iOS 17.5:
534
534
 
535
- - 16000hz 16-bit 1-channel PCM WAV ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote-en-us-sentence-16000hz-pcm_s16le.wav))
536
- - 16000hz MP3 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote-en-us-sentence-16000hz.mp3))
535
+ - 16000hz 16-bit 1-channel PCM WAV ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote_en_us_sentence-16000hz-pcm_s16le.wav))
536
+ - 16000hz MP3 1-channel ([example file](https://github.com/jamsch/expo-speech-recognition/blob/main/example/assets/audio-remote/remote_en_us_sentence-16000hz.mp3))
537
537
 
538
538
  ### File transcription example
539
539
 
@@ -1150,13 +1150,14 @@ ExpoSpeechRecognitionModule.androidTriggerOfflineModelDownload({
1150
1150
  console.log("Offline model download dialog opened.");
1151
1151
  break;
1152
1152
  case "download_success":
1153
- // On Android 14+, model was succesfully downloaded.
1153
+ // On Android 14+, model was successfully downloaded immediately.
1154
1154
  console.log("Offline model downloaded successfully!");
1155
1155
  break;
1156
- case "download_canceled":
1157
- // On Android 14+, the download was canceled by a user interaction.
1158
- console.log("Offline model download was canceled.");
1156
+ case "download_scheduled":
1157
+ // On Android 14+, the download was queued (e.g., waiting for WiFi) and will complete later.
1158
+ console.log("Offline model download has been scheduled.");
1159
1159
  break;
1160
+ }
1160
1161
  })
1161
1162
  .catch((err) => {
1162
1163
  console.log("Failed to download offline model!", err.message);
@@ -1,7 +1,10 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'expo.modules.speechrecognition'
4
- version = '0.1.0'
4
+
5
+ // Read version from package.json
6
+ def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
7
+ version = packageJson.version
5
8
 
6
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
10
  apply from: expoModulesCorePlugin
@@ -35,7 +38,7 @@ android {
35
38
  namespace "expo.modules.speechrecognition"
36
39
  defaultConfig {
37
40
  versionCode 1
38
- versionName "0.1.0"
41
+ versionName packageJson.version
39
42
  }
40
43
  lintOptions {
41
44
  abortOnError false
@@ -24,6 +24,7 @@ import expo.modules.kotlin.Promise
24
24
  import expo.modules.kotlin.modules.Module
25
25
  import expo.modules.kotlin.modules.ModuleDefinition
26
26
  import java.util.concurrent.Executors
27
+ import java.util.concurrent.atomic.AtomicBoolean
27
28
 
28
29
  private const val TAG = "ESRModule"
29
30
 
@@ -258,18 +259,7 @@ class ExpoSpeechRecognitionModule : Module() {
258
259
  // Do nothing
259
260
  }
260
261
 
261
- var isDownloadingModel = false
262
-
263
262
  AsyncFunction("androidTriggerOfflineModelDownload") { options: TriggerOfflineModelDownloadOptions, promise: Promise ->
264
- if (isDownloadingModel) {
265
- promise.reject(
266
- "download_in_progress",
267
- "An offline model download is already in progress.",
268
- Throwable(),
269
- )
270
- return@AsyncFunction
271
- }
272
-
273
263
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
274
264
  promise.reject(
275
265
  "not_supported",
@@ -299,7 +289,7 @@ class ExpoSpeechRecognitionModule : Module() {
299
289
  }
300
290
 
301
291
  // API 34+ (Android 14+) -- Trigger the model download and listen to the progress
302
- isDownloadingModel = true
292
+ val settled = AtomicBoolean(false)
303
293
  Handler(appContext.reactContext!!.mainLooper).post {
304
294
  val recognizer =
305
295
  SpeechRecognizer.createOnDeviceSpeechRecognizer(appContext.reactContext!!)
@@ -313,34 +303,38 @@ class ExpoSpeechRecognitionModule : Module() {
313
303
  }
314
304
 
315
305
  override fun onSuccess() {
316
- promise.resolve(
317
- mapOf(
318
- "status" to "download_success",
319
- "message" to "Offline model download completed successfully.",
320
- ),
321
- )
322
- isDownloadingModel = false
323
306
  recognizer.destroy()
307
+ if (settled.compareAndSet(false, true)) {
308
+ promise.resolve(
309
+ mapOf(
310
+ "status" to "download_success",
311
+ "message" to "Offline model download completed successfully.",
312
+ ),
313
+ )
314
+ }
324
315
  }
325
316
 
326
317
  override fun onScheduled() {
327
- promise.resolve(
328
- mapOf(
329
- "status" to "download_canceled",
330
- "message" to "The offline model download was canceled.",
331
- ),
332
- )
318
+ if (settled.compareAndSet(false, true)) {
319
+ promise.resolve(
320
+ mapOf(
321
+ "status" to "download_scheduled",
322
+ "message" to "Offline model download has been scheduled.",
323
+ ),
324
+ )
325
+ }
333
326
  }
334
327
 
335
328
  override fun onError(error: Int) {
336
329
  Log.e("ExpoSpeechService", "Error downloading model with code: $error")
337
- isDownloadingModel = false
338
- promise.reject(
339
- "error_$error",
340
- "Failed to download offline model download with error: $error",
341
- Throwable(),
342
- )
343
330
  recognizer.destroy()
331
+ if (settled.compareAndSet(false, true)) {
332
+ promise.reject(
333
+ "error_$error",
334
+ "Failed to download offline model download with error: $error",
335
+ Throwable(),
336
+ )
337
+ }
344
338
  }
345
339
  },
346
340
  )
@@ -424,7 +418,7 @@ class ExpoSpeechRecognitionModule : Module() {
424
418
  return
425
419
  }
426
420
 
427
- var didResolve = false
421
+ val settled = AtomicBoolean(false)
428
422
 
429
423
  // Speech Recognizer can only be ran on main thread
430
424
  Handler(appContext.mainLooper).post {
@@ -447,11 +441,9 @@ class ExpoSpeechRecognitionModule : Module() {
447
441
  object : RecognitionSupportCallback {
448
442
  override fun onSupportResult(recognitionSupport: RecognitionSupport) {
449
443
  Log.d("ExpoSpeechService", "onSupportResult() called with recognitionSupport: $recognitionSupport")
450
- // Seems to get called twice when using `createSpeechRecognizer()`
451
- if (didResolve) {
444
+ if (!settled.compareAndSet(false, true)) {
452
445
  return
453
446
  }
454
- didResolve = true
455
447
  // These languages are supported but need to be downloaded before use.
456
448
  val installedLocales = recognitionSupport.installedOnDeviceLanguages
457
449
 
@@ -471,11 +463,11 @@ class ExpoSpeechRecognitionModule : Module() {
471
463
 
472
464
  override fun onError(error: Int) {
473
465
  Log.e("ExpoSpeechService", "getSupportedLocales.onError() called with error code: $error")
474
- // This is a workaround for when both the onSupportResult and onError callbacks are called
475
- // This occurs when providing some packages such as com.google.android.tts
476
- // com.samsung.android.bixby.agent usually errors though
466
+ // Workaround: some packages (e.g. com.google.android.tts) fire both
467
+ // onSupportResult and onError. Delay gives onSupportResult time to win the CAS.
468
+ // note: if you're using com.samsung.android.bixby.agent, it usually errors though
477
469
  Handler(appContext.mainLooper).postDelayed({
478
- if (didResolve) {
470
+ if (!settled.compareAndSet(false, true)) {
479
471
  return@postDelayed
480
472
  }
481
473
  promise.reject(
package/app.plugin.js CHANGED
@@ -107,5 +107,5 @@ const withExpoSpeechRecognition = (config, props) => {
107
107
  module.exports = createRunOncePlugin(
108
108
  withExpoSpeechRecognition,
109
109
  "expo-speech-recognition",
110
- "1.0.0",
110
+ "56.0.1",
111
111
  );
@@ -666,11 +666,11 @@ export declare class ExpoSpeechRecognitionModuleType extends NativeModule<ExpoSp
666
666
  locale: string;
667
667
  }): Promise<{
668
668
  /**
669
- * On Android 13, the status will be "opened_dialog" indicating that the model download dialog was opened.
670
- * On Android 14+, the status will be "download_success" indicating that the model download was successful.
671
- * On Android 14+, "download_canceled" will be returned if the download was canceled by a user interaction.
669
+ * On Android 13, "opened_dialog" - the model download dialog was shown (fire-and-forget, no events emitted).
670
+ * On Android 14+, "download_success" if the model downloaded immediately,
671
+ * or "download_scheduled" if the download was queued (e.g., waiting for WiFi).
672
672
  */
673
- status: "download_success" | "opened_dialog" | "download_canceled";
673
+ status: "download_success" | "opened_dialog" | "download_scheduled";
674
674
  message: string;
675
675
  }>;
676
676
  /**
@@ -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,MAAM,CAAC;AAEzC,MAAM,MAAM,uCAAuC,GAAG,kBAAkB,GAAG;IACzE;;;;;;OAMG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;CACjD;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,eAAe,EAAE,kCAAkC,EAAE,CAAC;IACtD,IAAI,CAAC,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAEF,KAAK,sBAAsB,GACvB,UAAU,GACV,UAAU,GACV,aAAa,GACb,UAAU,CAAC;AAEf;;;;GAIG;AACH,MAAM,MAAM,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
+ {"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,MAAM,CAAC;AAEzC,MAAM,MAAM,uCAAuC,GAAG,kBAAkB,GAAG;IACzE;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,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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":"ExpoSpeechRecognitionModule.types.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type { NativeModule } from \"expo\";\n\nexport type ExpoSpeechRecognitionPermissionResponse = PermissionResponse & {\n /**\n * Whether the speech recognition is restricted by Content & Privacy Restrictions.\n *\n * This value corresponds to the `restricted` enum of `SFSpeechRecognizer.authorizationStatus()`.\n *\n * This is only available on iOS.\n */\n restricted?: boolean;\n};\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 /** (iOS) The audio session was interrupted (phone call, Siri, alarm). */\n | \"interrupted\"\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 * The underlying native error code from the platform-specific speech recognition service.\n *\n * - On Android: Maps to SpeechRecognizer error constants (e.g., ERROR_AUDIO = 3)\n * - Value of -1 indicates a generic/unknown error or when native code is not available\n *\n * Usually you won't need this field, but it can be useful for debugging purposes.\n */\n code?: number;\n};\n\nexport type LanguageDetectionEvent = {\n /** The language that was detected, in BCP-47 format. e.g. \"en-US\", \"de-DE\" */\n detectedLanguage: string;\n /** The confidence of the detected language. A value ranging between 0.0 and 1.0.\n *\n * Values range from:\n *\n * - 1.0 (highly confident)\n * - 0.8 (confident)\n * - 0.5 (not confident)\n * - 0.0 (unknown)\n */\n confidence: number;\n /** The alternative locales for the same language, in BCP-47 format. e.g. [\"en-US\", \"en-GB\"] */\n topLocaleAlternatives: 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.wav`\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.wav`\n */\n uri: string | null;\n };\n end: null;\n soundstart: null;\n soundend: null;\n languagedetection: LanguageDetectionEvent;\n volumechange: {\n /**\n * A float value between -2 and 10 indicating the volume of the input audio\n *\n * Consider anything below 0 to be inaudible\n */\n value: number;\n };\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, the behaviors are the following:\n *\n * - on iOS 17-, recognition will run until no speech is detected for 3 seconds.\n * - on iOS 18+ and Android, recognition will run until a result with `isFinal: true` is received.\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 (Android 13+, API level 33+).\n *\n * 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)\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 /**\n * Settings for volume change events.\n */\n volumeChangeEventOptions?: {\n /**\n * Whether to emit volume change events.\n *\n * Default: false\n */\n enabled?: boolean;\n /**\n * Specifies the interval (in milliseconds) to emit `volumechange` events.\n *\n * Default: 100ms on iOS\n *\n * Increasing this value will improve performance\n */\n intervalMillis?: number;\n };\n\n /**\n * [iOS only] Enabling this option will prevent microphone feedback.\n *\n * When enabled, extra signal processing is applied on the incoming audio, and any audio that is coming from the device is taken out.\n *\n * Note: this setting may switch the AVAudioSession mode to \"voiceChat\" and lower the volume of speaker playback\n *\n * (This option will place both input and output nodes in voice processing mode as noted in Apple docs: http://developer.apple.com/videos/play/wwdc2019/510/?time=66)\n */\n iosVoiceProcessingEnabled?: boolean;\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_ENABLE_FORMATTING\n *\n * NOTE: This is also configurable through `addsPunctuation` (which sets `EXTRA_ENABLE_FORMATTING` to \"quality\")\n *\n * [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.\n *\n */\n EXTRA_ENABLE_FORMATTING: \"latency\" | \"quality\";\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 type ExpoSpeechRecognitionNativeEvents = {\n [K in keyof ExpoSpeechRecognitionNativeEventMap]: (\n event: ExpoSpeechRecognitionNativeEventMap[K],\n ) => void;\n};\n\nexport declare class ExpoSpeechRecognitionModuleType extends NativeModule<ExpoSpeechRecognitionNativeEvents> {\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 Android, this will request RECORD_AUDIO permission.\n *\n * For iOS, this will request microphone and speech recognition permissions.\n * Once a user has granted (or denied) 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<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * Returns the current permission status for speech recognition and the microphone.\n *\n * You may also use `getMicrophonePermissionsAsync` and `getSpeechRecognizerPermissionsAsync` to get the permissions separately.\n */\n getPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * Returns the current permission status for the microphone.\n */\n getMicrophonePermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Presents a dialog to the user to request permissions for using the microphone.\n *\n * For iOS, once a user has granted (or denied) 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 requestMicrophonePermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns the current permission status for speech recognition.\n */\n getSpeechRecognizerPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * [iOS only] Presents a dialog to the user to request permissions for using the speech recognizer.\n * This permission is required when `requiresOnDeviceRecognition` is disabled (i.e. network-based recognition)\n *\n * For iOS, once a user has granted (or denied) 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 requestSpeechRecognizerPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\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
+ {"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 \"expo\";\n\nexport type ExpoSpeechRecognitionPermissionResponse = PermissionResponse & {\n /**\n * Whether the speech recognition is restricted by Content & Privacy Restrictions.\n *\n * This value corresponds to the `restricted` enum of `SFSpeechRecognizer.authorizationStatus()`.\n *\n * This is only available on iOS.\n */\n restricted?: boolean;\n};\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 /** (iOS) The audio session was interrupted (phone call, Siri, alarm). */\n | \"interrupted\"\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 * The underlying native error code from the platform-specific speech recognition service.\n *\n * - On Android: Maps to SpeechRecognizer error constants (e.g., ERROR_AUDIO = 3)\n * - Value of -1 indicates a generic/unknown error or when native code is not available\n *\n * Usually you won't need this field, but it can be useful for debugging purposes.\n */\n code?: number;\n};\n\nexport type LanguageDetectionEvent = {\n /** The language that was detected, in BCP-47 format. e.g. \"en-US\", \"de-DE\" */\n detectedLanguage: string;\n /** The confidence of the detected language. A value ranging between 0.0 and 1.0.\n *\n * Values range from:\n *\n * - 1.0 (highly confident)\n * - 0.8 (confident)\n * - 0.5 (not confident)\n * - 0.0 (unknown)\n */\n confidence: number;\n /** The alternative locales for the same language, in BCP-47 format. e.g. [\"en-US\", \"en-GB\"] */\n topLocaleAlternatives: 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.wav`\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.wav`\n */\n uri: string | null;\n };\n end: null;\n soundstart: null;\n soundend: null;\n languagedetection: LanguageDetectionEvent;\n volumechange: {\n /**\n * A float value between -2 and 10 indicating the volume of the input audio\n *\n * Consider anything below 0 to be inaudible\n */\n value: number;\n };\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, the behaviors are the following:\n *\n * - on iOS 17-, recognition will run until no speech is detected for 3 seconds.\n * - on iOS 18+ and Android, recognition will run until a result with `isFinal: true` is received.\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 (Android 13+, API level 33+).\n *\n * 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)\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 /**\n * Settings for volume change events.\n */\n volumeChangeEventOptions?: {\n /**\n * Whether to emit volume change events.\n *\n * Default: false\n */\n enabled?: boolean;\n /**\n * Specifies the interval (in milliseconds) to emit `volumechange` events.\n *\n * Default: 100ms on iOS\n *\n * Increasing this value will improve performance\n */\n intervalMillis?: number;\n };\n\n /**\n * [iOS only] Enabling this option will prevent microphone feedback.\n *\n * When enabled, extra signal processing is applied on the incoming audio, and any audio that is coming from the device is taken out.\n *\n * Note: this setting may switch the AVAudioSession mode to \"voiceChat\" and lower the volume of speaker playback\n *\n * (This option will place both input and output nodes in voice processing mode as noted in Apple docs: http://developer.apple.com/videos/play/wwdc2019/510/?time=66)\n */\n iosVoiceProcessingEnabled?: boolean;\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_ENABLE_FORMATTING\n *\n * NOTE: This is also configurable through `addsPunctuation` (which sets `EXTRA_ENABLE_FORMATTING` to \"quality\")\n *\n * [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.\n *\n */\n EXTRA_ENABLE_FORMATTING: \"latency\" | \"quality\";\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 type ExpoSpeechRecognitionNativeEvents = {\n [K in keyof ExpoSpeechRecognitionNativeEventMap]: (\n event: ExpoSpeechRecognitionNativeEventMap[K],\n ) => void;\n};\n\nexport declare class ExpoSpeechRecognitionModuleType extends NativeModule<ExpoSpeechRecognitionNativeEvents> {\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 Android, this will request RECORD_AUDIO permission.\n *\n * For iOS, this will request microphone and speech recognition permissions.\n * Once a user has granted (or denied) 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<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * Returns the current permission status for speech recognition and the microphone.\n *\n * You may also use `getMicrophonePermissionsAsync` and `getSpeechRecognizerPermissionsAsync` to get the permissions separately.\n */\n getPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * Returns the current permission status for the microphone.\n */\n getMicrophonePermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Presents a dialog to the user to request permissions for using the microphone.\n *\n * For iOS, once a user has granted (or denied) 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 requestMicrophonePermissionsAsync(): Promise<PermissionResponse>;\n /**\n * Returns the current permission status for speech recognition.\n */\n getSpeechRecognizerPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\n /**\n * [iOS only] Presents a dialog to the user to request permissions for using the speech recognizer.\n * This permission is required when `requiresOnDeviceRecognition` is disabled (i.e. network-based recognition)\n *\n * For iOS, once a user has granted (or denied) 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 requestSpeechRecognizerPermissionsAsync(): Promise<ExpoSpeechRecognitionPermissionResponse>;\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, \"opened_dialog\" - the model download dialog was shown (fire-and-forget, no events emitted).\n * On Android 14+, \"download_success\" if the model downloaded immediately,\n * or \"download_scheduled\" if the download was queued (e.g., waiting for WiFi).\n */\n status: \"download_success\" | \"opened_dialog\" | \"download_scheduled\";\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":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAqB,YAAY,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAEV,mCAAmC,EACnC,iCAAiC,EACjC,4BAA4B,EAE7B,MAAM,qCAAqC,CAAC;AAI7C,KAAK,mBAAmB,GAAG,CACzB,KAAK,EAAE,yBAAyB,CAAC,MAAM,yBAAyB,CAAC,KAC9D,IAAI,CAAC;AAIV,cAAM,8BAA+B,SAAQ,YAAY,CAAC,iCAAiC,CAAC;IAC1F,gBAAgB,EAAE,GAAG,CAEnB,iCAAiC,CAAC,MAAM,iCAAiC,CAAC,EAE1E,mBAAmB,CACpB,CAAa;IAEd,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAa;IAGpE,iBAAiB,GAAI,CAAC,SAAS,MAAM,yBAAyB,EAC5D,WAAW,CAAC,EACZ,IAAI,yBAAyB,CAAC,CAAC,CAAC,UAShC;IAEF,WAAW,CAAC,SAAS,SAAS,MAAM,mCAAmC,EACrE,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,iCAAiC,CAAC,SAAS,CAAC,GACrD,iBAAiB;IAyCpB,kBAAkB,CAChB,SAAS,EAAE,MAAM,mCAAmC,GAC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IAEF,WAAW,CAAC,SAAS,SAAS,MAAM,mCAAmC,EACrE,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,iCAAiC,CAAC,SAAS,CAAC,GACrD,iBAAiB;IAyCpB,kBAAkB,CAChB,SAAS,EAAE,MAAM,mCAAmC,GACnD,IAAI;IA4BP,KAAK,CAAC,OAAO,EAAE,4BAA4B;IAyB3C,aAAa;IAOb,IAAI;IAGJ,KAAK;IAIL,uBAAuB;IAYvB,mBAAmB;IAYnB,6BAA6B;IAY7B,iCAAiC;IAYjC,mCAAmC;IAYnC,uCAAuC;IAYjC,mBAAmB;iBAKN,MAAM,EAAE;0BACC,MAAM,EAAE;;IAQpC,4BAA4B,IACb,MAAM,EAAE;IAGvB,4BAA4B;;;IAM5B,mBAAmB;;;IAMnB,2BAA2B;IAI3B,iBAAiB;IAIjB,kCAAkC;;;;IAUlC,cAAc;IAId,oCAAoC;;;;;IAWpC,wBAAwB;IAIxB,sBAAsB;CAOvB;AA8FD,eAAO,MAAM,2BAA2B,uCAGvC,CAAC"}
@@ -226,13 +226,19 @@ const webToNativeEventMap = {
226
226
  const isFinal = Boolean(ev.results[ev.resultIndex]?.isFinal);
227
227
  if (isFinal) {
228
228
  const results = [];
229
- for (let i = 0; i < ev.results[ev.resultIndex].length; i++) {
230
- const result = ev.results[ev.resultIndex][i];
231
- results.push({
232
- transcript: result.transcript,
233
- confidence: result.confidence,
234
- segments: [],
235
- });
229
+ const resultList = ev.results[ev.resultIndex];
230
+ if (resultList) {
231
+ for (let i = 0; i < resultList.length; i++) {
232
+ const result = resultList[i];
233
+ if (!result) {
234
+ continue;
235
+ }
236
+ results.push({
237
+ transcript: result.transcript,
238
+ confidence: result.confidence,
239
+ segments: [],
240
+ });
241
+ }
236
242
  }
237
243
  return {
238
244
  isFinal: true,
@@ -244,6 +250,9 @@ const webToNativeEventMap = {
244
250
  const segments = [];
245
251
  for (let i = ev.resultIndex; i < ev.results.length; i++) {
246
252
  const resultList = ev.results[i];
253
+ if (!resultList) {
254
+ continue;
255
+ }
247
256
  for (let j = 0; j < resultList.length; j++) {
248
257
  const result = resultList[j];
249
258
  if (!result) {
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoSpeechRecognitionModule.web.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASvD,IAAI,qBAAqB,GAA6B,IAAI,CAAC;AAM3D,kEAAkE;AAClE,4EAA4E;AAC5E,MAAM,8BAA+B,SAAQ,YAA+C;IAC1F,gBAAgB,GAKZ,IAAI,GAAG,EAAE,CAAC;IAEd,gBAAgB,GAA0C,IAAI,GAAG,EAAE,CAAC;IAEpE,4CAA4C;IAC5C,iBAAiB,GAAG,CAClB,SAAY,EACZ,EAAgC,EAChC,EAAE;QACF,MAAM,YAAY,GAAG,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,IAAI,CACP,SAAS;QACT,iDAAiD;QACjD,YAAY,CACb,CAAC;IACJ,CAAC,CAAC;IAEF,WAAW,CACT,SAAoB,EACpB,QAAsD;QAEtD,4CAA4C;QAE5C,mDAAmD;QACnD,MAAM,cAAc,GAAG,CAAC,EAAwC,EAAE,EAAE;YAClE,MAAM,OAAO,GACX,SAAS,IAAI,mBAAmB;gBAC9B,CAAC,CAAC,mBAAmB,CAAC,SAA4C,CAAC;gBACnE,CAAC,CAAC,IAAI,CAAC;YAEX,iDAAiD;YACjD,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;YAEnC,mBAAmB;YACnB,QAAQ,CAAC,YAAY,CAAC,CAAC;QACzB,CAAC,CAAC;QAEF,mBAAmB;QACnB,qBAAqB,EAAE,gBAAgB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,S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EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;IACxB,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;IACvB,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,iBAAiB,CAC1D,8BAA8B,EAC9B,6BAA6B,CAC9B,CAAC","sourcesContent":["import type { EventSubscription, PermissionResponse } from \"expo-modules-core\";\nimport { registerWebModule, NativeModule } from \"expo\";\nimport type {\n ExpoSpeechRecognitionErrorCode,\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionNativeEvents,\n ExpoSpeechRecognitionOptions,\n ExpoSpeechRecognitionResultSegment,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nlet _speechRecognitionRef: SpeechRecognition | null = null;\n\ntype NativeEventListener = (\n event: SpeechRecognitionEventMap[keyof SpeechRecognitionEventMap],\n) => void;\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.\nclass ExpoSpeechRecognitionModuleWeb extends NativeModule<ExpoSpeechRecognitionNativeEvents> {\n _clientListeners: Map<\n // Original listener\n ExpoSpeechRecognitionNativeEvents[keyof ExpoSpeechRecognitionNativeEvents],\n // Native listener\n NativeEventListener\n > = new Map();\n\n _nativeListeners: Map<string, Set<NativeEventListener>> = new Map();\n\n // Convert the web event to the native event\n bindEventListener = <T extends keyof SpeechRecognitionEventMap>(\n eventName: T,\n ev: SpeechRecognitionEventMap[T],\n ) => {\n const eventPayload = webToNativeEventMap[eventName]?.(ev);\n\n this.emit(\n eventName,\n // @ts-expect-error payload typings are incorrect\n eventPayload,\n );\n };\n\n addListener<EventName extends keyof ExpoSpeechRecognitionNativeEventMap>(\n eventName: EventName,\n listener: ExpoSpeechRecognitionNativeEvents[EventName],\n ): EventSubscription {\n // Convert the web event to the native event\n\n // @ts-expect-error Not all events are covered here\n const nativeListener = (ev: SpeechRecognitionEventMap[EventName]) => {\n const handler =\n eventName in webToNativeEventMap\n ? webToNativeEventMap[eventName as keyof SpeechRecognitionEventMap]\n : null;\n\n // @ts-expect-error payload typings are incorrect\n const eventPayload = handler?.(ev);\n\n // @ts-expect-error\n listener(eventPayload);\n };\n\n // @ts-expect-error\n _speechRecognitionRef?.addEventListener(eventName, nativeListener);\n if (!this._nativeListeners.has(eventName)) {\n this._nativeListeners.set(eventName, new Set());\n }\n // Add the original listener to the enhanced listeners\n // @ts-expect-error\n this._nativeListeners.get(eventName)?.add(nativeListener);\n // Map the original listener to the enhanced listener\n // @ts-expect-error\n this._clientListeners.set(listener, nativeListener);\n\n const handle = super.addListener(eventName, listener);\n\n return {\n remove: () => {\n // @ts-expect-error\n this._nativeListeners.get(eventName)?.delete(nativeListener);\n this._clientListeners.delete(listener);\n handle.remove();\n },\n };\n }\n\n removeAllListeners(\n eventName: keyof ExpoSpeechRecognitionNativeEventMap,\n ): void {\n // Go through _listeners and remove all listeners for this event\n if (this._nativeListeners.has(eventName)) {\n const nativeListeners = this._nativeListeners.get(eventName);\n if (!nativeListeners) {\n return;\n }\n\n // Remove the enhanced listeners\n for (const [listener, nativeListener] of this._clientListeners) {\n // if nativeListener in listeners, remove it\n if (nativeListeners.has(nativeListener)) {\n // Remove the enhanced listener\n this.removeListener(eventName, listener);\n }\n }\n\n // ...and the native listeners\n for (const listener of nativeListeners) {\n // @ts-expect-error\n this.removeListener(eventName, listener);\n }\n\n // Clean up\n this._nativeListeners.delete(eventName);\n }\n }\n\n start(options: ExpoSpeechRecognitionOptions) {\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 this._nativeListeners.forEach((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 // Start the speech recognition!\n _speechRecognitionRef.start();\n }\n\n getStateAsync() {\n console.warn(\n \"getStateAsync is not supported on web. Returning 'inactive'.\",\n );\n return Promise.resolve(\"inactive\");\n }\n\n stop() {\n _speechRecognitionRef?.stop();\n }\n abort() {\n _speechRecognitionRef?.abort();\n }\n\n requestPermissionsAsync() {\n console.warn(\n \"requestPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getPermissionsAsync() {\n console.warn(\n \"getPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getMicrophonePermissionsAsync() {\n console.warn(\n \"getMicrophonePermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n requestMicrophonePermissionsAsync() {\n console.warn(\n \"requestMicrophonePermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getSpeechRecognizerPermissionsAsync() {\n console.warn(\n \"getSpeechRecognizerPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n requestSpeechRecognizerPermissionsAsync() {\n console.warn(\n \"requestSpeechRecognizerPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n async getSupportedLocales() {\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\n // addListener() {}\n\n // removeListeners() {}\n\n getSpeechRecognitionServices() {\n return [] as string[];\n }\n\n getDefaultRecognitionService() {\n return {\n packageName: \"\",\n };\n }\n\n getAssistantService() {\n return {\n packageName: \"\",\n };\n }\n\n supportsOnDeviceRecognition() {\n return false;\n }\n\n supportsRecording() {\n return false;\n }\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\n setCategoryIOS() {\n console.warn(\"setCategoryIOS is not supported on web.\");\n }\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\n setAudioSessionActiveIOS() {\n console.warn(\"setAudioSessionActiveIOS is not supported on web.\");\n }\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) => ({\n // TODO: add \"phrases-not-supported\" support to the type\n error: ev.error as ExpoSpeechRecognitionErrorCode,\n message: ev.message,\n }),\n nomatch: (ev) => null,\n result: (ev): ExpoSpeechRecognitionNativeEventMap[\"result\"] => {\n const isFinal = Boolean(ev.results[ev.resultIndex]?.isFinal);\n\n if (isFinal) {\n const results: 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 results.push({\n transcript: result.transcript,\n confidence: result.confidence,\n segments: [],\n });\n }\n return {\n isFinal: true,\n results,\n };\n }\n\n // Interim results: Append to the transcript\n let transcript = \"\";\n const segments: ExpoSpeechRecognitionResultSegment[] = [];\n\n for (let i = ev.resultIndex; i < ev.results.length; i++) {\n const resultList = ev.results[i];\n\n for (let j = 0; j < resultList.length; j++) {\n const result = resultList[j];\n if (!result) {\n continue;\n }\n segments.push({\n confidence: result.confidence,\n segment: result.transcript,\n startTimeMillis: 0,\n endTimeMillis: 0,\n });\n\n if (!isFinal) {\n transcript += result.transcript;\n }\n }\n }\n\n return {\n isFinal: false,\n results: [\n {\n transcript,\n confidence:\n segments.reduce((acc, curr) => acc + curr.confidence, 0) /\n segments.length,\n segments,\n },\n ],\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 ExpoSpeechRecognitionModule = registerWebModule(\n ExpoSpeechRecognitionModuleWeb,\n \"ExpoSpeechRecognitionModule\",\n);\n"]}
1
+ {"version":3,"file":"ExpoSpeechRecognitionModule.web.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASvD,IAAI,qBAA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AAE,EAAE,CAAC,IAAI;IACzB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,iBAAiB,CAC1D,8BAA8B,EAC9B,6BAA6B,CAC9B,CAAC","sourcesContent":["import type { EventSubscription, PermissionResponse } from \"expo-modules-core\";\nimport { registerWebModule, NativeModule } from \"expo\";\nimport type {\n ExpoSpeechRecognitionErrorCode,\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionNativeEvents,\n ExpoSpeechRecognitionOptions,\n ExpoSpeechRecognitionResultSegment,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nlet _speechRecognitionRef: SpeechRecognition | null = null;\n\ntype NativeEventListener = (\n event: SpeechRecognitionEventMap[keyof SpeechRecognitionEventMap],\n) => void;\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.\nclass ExpoSpeechRecognitionModuleWeb extends NativeModule<ExpoSpeechRecognitionNativeEvents> {\n _clientListeners: Map<\n // Original listener\n ExpoSpeechRecognitionNativeEvents[keyof ExpoSpeechRecognitionNativeEvents],\n // Native listener\n NativeEventListener\n > = new Map();\n\n _nativeListeners: Map<string, Set<NativeEventListener>> = new Map();\n\n // Convert the web event to the native event\n bindEventListener = <T extends keyof SpeechRecognitionEventMap>(\n eventName: T,\n ev: SpeechRecognitionEventMap[T],\n ) => {\n const eventPayload = webToNativeEventMap[eventName]?.(ev);\n\n this.emit(\n eventName,\n // @ts-expect-error payload typings are incorrect\n eventPayload,\n );\n };\n\n addListener<EventName extends keyof ExpoSpeechRecognitionNativeEventMap>(\n eventName: EventName,\n listener: ExpoSpeechRecognitionNativeEvents[EventName],\n ): EventSubscription {\n // Convert the web event to the native event\n\n // @ts-expect-error Not all events are covered here\n const nativeListener = (ev: SpeechRecognitionEventMap[EventName]) => {\n const handler =\n eventName in webToNativeEventMap\n ? webToNativeEventMap[eventName as keyof SpeechRecognitionEventMap]\n : null;\n\n // @ts-expect-error payload typings are incorrect\n const eventPayload = handler?.(ev);\n\n // @ts-expect-error\n listener(eventPayload);\n };\n\n // @ts-expect-error\n _speechRecognitionRef?.addEventListener(eventName, nativeListener);\n if (!this._nativeListeners.has(eventName)) {\n this._nativeListeners.set(eventName, new Set());\n }\n // Add the original listener to the enhanced listeners\n // @ts-expect-error\n this._nativeListeners.get(eventName)?.add(nativeListener);\n // Map the original listener to the enhanced listener\n // @ts-expect-error\n this._clientListeners.set(listener, nativeListener);\n\n const handle = super.addListener(eventName, listener);\n\n return {\n remove: () => {\n // @ts-expect-error\n this._nativeListeners.get(eventName)?.delete(nativeListener);\n this._clientListeners.delete(listener);\n handle.remove();\n },\n };\n }\n\n removeAllListeners(\n eventName: keyof ExpoSpeechRecognitionNativeEventMap,\n ): void {\n // Go through _listeners and remove all listeners for this event\n if (this._nativeListeners.has(eventName)) {\n const nativeListeners = this._nativeListeners.get(eventName);\n if (!nativeListeners) {\n return;\n }\n\n // Remove the enhanced listeners\n for (const [listener, nativeListener] of this._clientListeners) {\n // if nativeListener in listeners, remove it\n if (nativeListeners.has(nativeListener)) {\n // Remove the enhanced listener\n this.removeListener(eventName, listener);\n }\n }\n\n // ...and the native listeners\n for (const listener of nativeListeners) {\n // @ts-expect-error\n this.removeListener(eventName, listener);\n }\n\n // Clean up\n this._nativeListeners.delete(eventName);\n }\n }\n\n start(options: ExpoSpeechRecognitionOptions) {\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 this._nativeListeners.forEach((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 // Start the speech recognition!\n _speechRecognitionRef.start();\n }\n\n getStateAsync() {\n console.warn(\n \"getStateAsync is not supported on web. Returning 'inactive'.\",\n );\n return Promise.resolve(\"inactive\");\n }\n\n stop() {\n _speechRecognitionRef?.stop();\n }\n abort() {\n _speechRecognitionRef?.abort();\n }\n\n requestPermissionsAsync() {\n console.warn(\n \"requestPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getPermissionsAsync() {\n console.warn(\n \"getPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getMicrophonePermissionsAsync() {\n console.warn(\n \"getMicrophonePermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n requestMicrophonePermissionsAsync() {\n console.warn(\n \"requestMicrophonePermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n getSpeechRecognizerPermissionsAsync() {\n console.warn(\n \"getSpeechRecognizerPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n requestSpeechRecognizerPermissionsAsync() {\n console.warn(\n \"requestSpeechRecognizerPermissionsAsync is not supported on web. Returning a granted permission response.\",\n );\n return Promise.resolve({\n granted: true,\n canAskAgain: false,\n expires: \"never\",\n status: \"granted\",\n } as PermissionResponse);\n }\n\n async getSupportedLocales() {\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\n // addListener() {}\n\n // removeListeners() {}\n\n getSpeechRecognitionServices() {\n return [] as string[];\n }\n\n getDefaultRecognitionService() {\n return {\n packageName: \"\",\n };\n }\n\n getAssistantService() {\n return {\n packageName: \"\",\n };\n }\n\n supportsOnDeviceRecognition() {\n return false;\n }\n\n supportsRecording() {\n return false;\n }\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\n setCategoryIOS() {\n console.warn(\"setCategoryIOS is not supported on web.\");\n }\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\n setAudioSessionActiveIOS() {\n console.warn(\"setAudioSessionActiveIOS is not supported on web.\");\n }\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) => ({\n // TODO: add \"phrases-not-supported\" support to the type\n error: ev.error as ExpoSpeechRecognitionErrorCode,\n message: ev.message,\n }),\n nomatch: (ev) => null,\n result: (ev): ExpoSpeechRecognitionNativeEventMap[\"result\"] => {\n const isFinal = Boolean(ev.results[ev.resultIndex]?.isFinal);\n\n if (isFinal) {\n const results: ExpoSpeechRecognitionNativeEventMap[\"result\"][\"results\"] =\n [];\n const resultList = ev.results[ev.resultIndex];\n\n if (resultList) {\n for (let i = 0; i < resultList.length; i++) {\n const result = resultList[i];\n if (!result) {\n continue;\n }\n results.push({\n transcript: result.transcript,\n confidence: result.confidence,\n segments: [],\n });\n }\n }\n return {\n isFinal: true,\n results,\n };\n }\n\n // Interim results: Append to the transcript\n let transcript = \"\";\n const segments: ExpoSpeechRecognitionResultSegment[] = [];\n\n for (let i = ev.resultIndex; i < ev.results.length; i++) {\n const resultList = ev.results[i];\n if (!resultList) {\n continue;\n }\n\n for (let j = 0; j < resultList.length; j++) {\n const result = resultList[j];\n if (!result) {\n continue;\n }\n segments.push({\n confidence: result.confidence,\n segment: result.transcript,\n startTimeMillis: 0,\n endTimeMillis: 0,\n });\n\n if (!isFinal) {\n transcript += result.transcript;\n }\n }\n }\n\n return {\n isFinal: false,\n results: [\n {\n transcript,\n confidence:\n segments.reduce((acc, curr) => acc + curr.confidence, 0) /\n segments.length,\n segments,\n },\n ],\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 ExpoSpeechRecognitionModule = registerWebModule(\n ExpoSpeechRecognitionModuleWeb,\n \"ExpoSpeechRecognitionModule\",\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoWebSpeechRecognition.js","sourceRoot":"","sources":["../src/ExpoWebSpeechRecognition.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAM5E,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,MAA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AAC;IACrD,CAAC;IAED,YACE,OAAgB,EAChB,YAAgD;QAEhD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AAED,MAAM,gCAAgC;IACpC,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,YAAY,UAAkB,EAAE,UAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoSpeechRecognition.web.ts\n// and on native platforms to ExpoSpeechRecognition.ts\nimport type { EventSubscription } from \"expo-modules-core\";\nimport { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\nimport type {\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionOptions,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nconst noop = () => {};\n\nconst createEventData = (target: EventTarget) => ({\n AT_TARGET: 2 as const,\n bubbles: false,\n BUBBLING_PHASE: 3 as const,\n cancelable: false,\n CAPTURING_PHASE: 1 as const,\n composed: false,\n composedPath: () => [],\n currentTarget: target,\n defaultPrevented: false,\n eventPhase: 0,\n isTrusted: true,\n NONE: 0 as const,\n preventDefault: noop,\n resultIndex: 0,\n stopImmediatePropagation: noop,\n stopPropagation: noop,\n target,\n timeStamp: 0,\n type: \"\",\n cancelBubble: false,\n returnValue: false,\n srcElement: null,\n initEvent: noop,\n});\n\ntype NativeEventAndListener<\n TEventName extends keyof ExpoSpeechRecognitionNativeEventMap,\n> = {\n /** Event name to listen for on native side */\n eventName: TEventName;\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[TEventName],\n ) => void;\n};\n\nfunction stubEvent<K extends keyof SpeechRecognitionEventMap>(\n eventName: K,\n instance: ExpoWebSpeechRecognition,\n listener: (this: SpeechRecognition, ev: Event) => unknown,\n): NativeEventAndListener<K> {\n return {\n eventName,\n nativeListener: (nativeEvent) =>\n listener.call(instance, createEventData(instance)),\n };\n}\n\n/**\n * Transforms the native listener payloads to web-compatible shapes\n */\nconst WebListenerTransformers: {\n [K in keyof SpeechRecognitionEventMap]?: (\n instance: ExpoWebSpeechRecognition,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => unknown,\n ) => NativeEventAndListener<K>;\n} = {\n audiostart: (instance, listener) => {\n return {\n eventName: \"audiostart\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n audioend: (instance, listener) => {\n return {\n eventName: \"audioend\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n nomatch: (instance, listener) => {\n // @ts-ignore\n return stubEvent(\"nomatch\", instance, listener);\n },\n end: (instance, listener) => {\n return stubEvent(\"end\", instance, listener);\n },\n start: (instance, listener) => {\n return {\n eventName: \"start\",\n nativeListener() {\n listener.call(instance, createEventData(instance));\n },\n };\n },\n error: (instance, listener) => {\n return {\n eventName: \"error\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"error\"],\n ) => {\n const clientEvent: SpeechRecognitionEventMap[\"error\"] = {\n ...createEventData(instance),\n // TODO: handle custom ios error codes\n error: nativeEvent.error as SpeechRecognitionErrorCode,\n message: nativeEvent.message,\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n result: (instance, listener) => {\n return {\n eventName: \"result\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"result\"],\n ) => {\n if (!instance.interimResults && !nativeEvent.isFinal) {\n return;\n }\n const alternatives = nativeEvent.results.map(\n (result) =>\n new ExpoSpeechRecognitionAlternative(\n result.confidence,\n result.transcript,\n ),\n );\n const clientEvent: SpeechRecognitionEventMap[\"result\"] = {\n ...createEventData(instance),\n results: new ExpoSpeechRecognitionResultList([\n new ExpoSpeechRecognitionResult(nativeEvent.isFinal, alternatives),\n ]),\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n};\n\ntype SpeechListener<K extends keyof SpeechRecognitionEventMap> = (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n) => any;\n\n/** A compatibility wrapper that implements the web SpeechRecognition API for React Native. */\nexport class ExpoWebSpeechRecognition implements SpeechRecognition {\n lang = \"en-US\";\n grammars: SpeechGrammarList = new ExpoWebSpeechGrammarList();\n maxAlternatives = 1;\n continuous = false;\n processLocally = false;\n\n #interimResults = false;\n\n get interimResults(): boolean {\n return this.#interimResults;\n }\n\n set interimResults(interimResults: boolean) {\n this.#interimResults = interimResults;\n // Subscribe to native\n }\n\n // Extended properties\n\n /** [EXTENDED, default: undefined] An array of strings that will be used to provide context to the speech recognition engine. */\n contextualStrings?: string[] = undefined;\n /** [EXTENDED, default: false] Whether the speech recognition engine should require the device to be on when the recognition starts. */\n requiresOnDeviceRecognition = false;\n /** [EXTENDED, default: false] Whether the speech recognition engine should add punctuation to the transcription. */\n addsPunctuation = false;\n /** [EXTENDED, default: undefined] Android-specific options to pass to the recognizer. */\n androidIntentOptions: ExpoSpeechRecognitionOptions[\"androidIntentOptions\"];\n /** [EXTENDED, default: undefined] Audio source options to pass to the recognizer. */\n audioSource?: ExpoSpeechRecognitionOptions[\"audioSource\"];\n /** [EXTENDED, default: undefined] Audio recording options to pass to the recognizer. */\n recordingOptions?: ExpoSpeechRecognitionOptions[\"recordingOptions\"];\n /** [EXTENDED, default: \"android.speech.action.RECOGNIZE_SPEECH\"] The kind of intent action */\n androidIntent?: ExpoSpeechRecognitionOptions[\"androidIntent\"] = undefined;\n /** [EXTENDED, default: undefined] The hint for the speech recognition task. */\n iosTaskHint?: ExpoSpeechRecognitionOptions[\"iosTaskHint\"] = undefined;\n /** [EXTENDED, default: undefined] The audio session category and options to use. */\n iosCategory?: ExpoSpeechRecognitionOptions[\"iosCategory\"] = undefined;\n /**\n * [EXTENDED, default: undefined]\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.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage: ExpoSpeechRecognitionOptions[\"androidRecognitionServicePackage\"];\n\n // keyed by listener function\n #subscriptionMap: Map<SpeechListener<any>, EventSubscription[]> = new Map();\n\n start() {\n ExpoSpeechRecognitionModule.requestPermissionsAsync().then(() => {\n // A result doesn't matter,\n // the module will emit an error if permissions are not granted\n ExpoSpeechRecognitionModule.start({\n lang: this.lang,\n interimResults: this.interimResults,\n maxAlternatives: this.maxAlternatives,\n contextualStrings: this.contextualStrings,\n requiresOnDeviceRecognition: this.requiresOnDeviceRecognition,\n addsPunctuation: this.addsPunctuation,\n continuous: this.continuous,\n recordingOptions: this.recordingOptions,\n androidIntentOptions: this.androidIntentOptions,\n androidRecognitionServicePackage: this.androidRecognitionServicePackage,\n audioSource: this.audioSource,\n androidIntent: this.androidIntent,\n iosTaskHint: this.iosTaskHint,\n iosCategory: this.iosCategory,\n });\n });\n }\n stop = ExpoSpeechRecognitionModule.stop;\n abort = ExpoSpeechRecognitionModule.abort;\n\n #onstart: SpeechListener<\"start\"> | null = null;\n set onstart(listener: SpeechListener<\"start\"> | null) {\n this._setListeners(\"start\", listener, this.#onstart);\n this.#onstart = listener;\n }\n /** Fired when the speech recognition starts. */\n get onstart() {\n return this.#onstart;\n }\n\n #onend: SpeechListener<\"end\"> | null = null;\n set onend(listener: SpeechListener<\"end\"> | null) {\n this._setListeners(\n \"end\",\n (ev) => {\n listener?.call(this, ev);\n },\n this.#onend,\n );\n this.#onend = listener;\n }\n /** Fired when the speech recognition service has disconnected. */\n get onend() {\n return this.#onend;\n }\n\n #onerror: SpeechListener<\"error\"> | null = null;\n set onerror(listener: SpeechListener<\"error\"> | null) {\n this._setListeners(\"error\", listener, this.#onerror);\n this.#onerror = listener;\n }\n /** Fired when the speech recognition service encounters an error. */\n get onerror() {\n return this.#onerror;\n }\n\n _setListeners<K extends keyof SpeechRecognitionEventMap>(\n key: K,\n listenerFn: SpeechListener<K> | null,\n existingListener: SpeechListener<K> | null,\n ) {\n if (existingListener) {\n this.removeEventListener(key, existingListener);\n }\n if (listenerFn) {\n this.addEventListener(key, listenerFn);\n }\n }\n\n #onresult: SpeechListener<\"result\"> | null = null;\n set onresult(listener: SpeechListener<\"result\"> | null) {\n this._setListeners(\"result\", listener, this.#onresult);\n this.#onresult = listener;\n }\n /** Fired when the speech recognition service returns a result —\n * a word or phrase has been positively recognized and this has been communicated back to the app. */\n get onresult() {\n return this.#onresult;\n }\n\n #onnomatch: SpeechListener<\"nomatch\"> | null = null;\n set onnomatch(listener: SpeechListener<\"nomatch\"> | null) {\n this._setListeners(\"nomatch\", listener, this.#onnomatch);\n this.#onnomatch = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onnomatch() {\n return this.#onnomatch;\n }\n\n #onspeechstart: SpeechListener<\"speechstart\"> | null = null;\n set onspeechstart(listener: SpeechListener<\"speechstart\"> | null) {\n this._setListeners(\"speechstart\", listener, this.#onspeechstart);\n this.#onspeechstart = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechstart() {\n return this.#onspeechstart;\n }\n\n #onspeechend: SpeechListener<\"speechend\"> | null = null;\n set onspeechend(listener: SpeechListener<\"speechend\"> | null) {\n this._setListeners(\"speechend\", listener, this.#onspeechend);\n this.#onspeechend = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechend() {\n return this.#onspeechend;\n }\n\n #onaudiostart: SpeechListener<\"audiostart\"> | null = null;\n set onaudiostart(listener: SpeechListener<\"audiostart\"> | null) {\n this._setListeners(\"audiostart\", listener, this.#onaudiostart);\n this.#onaudiostart = listener;\n }\n /** Fired when the user agent has started to capture audio. */\n get onaudiostart() {\n return this.#onaudiostart;\n }\n\n #onaudioend: SpeechListener<\"audioend\"> | null = null;\n set onaudioend(listener: SpeechListener<\"audioend\"> | null) {\n this._setListeners(\"audioend\", listener, this.#onaudioend);\n this.#onaudioend = listener;\n }\n /** Fired when the user agent has finished capturing audio. */\n get onaudioend() {\n return this.#onaudioend;\n }\n\n /** [TODO] */\n onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n /** [TODO] */\n onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n\n addEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: SpeechListener<K>,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const once = typeof options === \"object\" && options.once;\n\n // If the user opts in to only listening once,\n // wrap the listener in a function that removes the listener\n const wrappedListener = once\n ? (((ev) => {\n listener.call(this, ev);\n // remove the listeners from the map\n for (const sub of this.#subscriptionMap.get(listener) ?? []) {\n sub.remove();\n }\n this.#subscriptionMap.delete(listener);\n }) as SpeechListener<K>)\n : listener;\n\n // Enhance the native listener with any necessary polyfills\n const enhancedEvent: NativeEventAndListener<K> =\n WebListenerTransformers[type]?.(this, wrappedListener) ??\n stubEvent(\n type,\n this,\n wrappedListener as (this: SpeechRecognition, ev: Event) => unknown,\n );\n\n const subscription = ExpoSpeechRecognitionModule.addListener(\n enhancedEvent.eventName,\n // @ts-expect-error\n enhancedEvent.nativeListener,\n );\n\n // Store the subscriptions so we can remove them later\n // This is keyed by the listener function so we can remove all subscriptions for a given listener\n this.#subscriptionMap.set(listener, [subscription]);\n }\n\n removeEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => any,\n options?: boolean | EventListenerOptions | undefined,\n ): void {\n const subscriptions = this.#subscriptionMap.get(listener);\n if (subscriptions) {\n for (const subscription of subscriptions) {\n subscription.remove();\n }\n this.#subscriptionMap.delete(listener);\n }\n }\n\n dispatchEvent(event: Event): boolean {\n throw new Error(\"Method not implemented.\");\n }\n}\n\n/**\n * This class is just a polyfill and does nothing on Android/iOS\n */\nexport class ExpoWebSpeechGrammarList implements SpeechGrammarList {\n get length() {\n return this.#grammars.length;\n }\n #grammars: ExpoWebSpeechGrammar[] = [];\n [index: number]: SpeechGrammar; // Indexer property\n\n addFromURI(src: string, weight?: number | undefined): void {\n // todo\n }\n\n item(index: number): ExpoWebSpeechGrammar {\n return this.#grammars[index];\n }\n\n addFromString = (grammar: string, weight?: number) => {\n // TODO: parse grammar to html entities (data:application/xml,....)\n this.#grammars.push(new ExpoWebSpeechGrammar(grammar, weight));\n // Set key on this object for compatibility with web SpeechGrammarList API\n this[this.length - 1] = this.#grammars[this.length - 1];\n };\n}\n\nexport class ExpoWebSpeechGrammar implements SpeechGrammar {\n src = \"\";\n weight = 1;\n\n constructor(src: string, weight?: number) {\n this.src = src;\n this.weight = weight ?? 1;\n }\n}\n\nclass ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {\n #results: ExpoSpeechRecognitionResult[] = [];\n\n [Symbol.iterator](): ArrayIterator<ExpoSpeechRecognitionResult> {\n return this.#results[\n Symbol.iterator\n ]() as ArrayIterator<ExpoSpeechRecognitionResult>;\n }\n length: number;\n item(index: number): SpeechRecognitionResult {\n return this.#results[index];\n }\n [index: number]: SpeechRecognitionResult;\n\n constructor(results: ExpoSpeechRecognitionResult[]) {\n this.#results = results;\n this.length = results.length;\n for (let i = 0; i < this.#results.length; i++) {\n this[i] = this.#results[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionResult implements SpeechRecognitionResult {\n #alternatives: ExpoSpeechRecognitionAlternative[] = [];\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/isFinal) */\n readonly isFinal: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/length) */\n length: number;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */\n item(index: number): SpeechRecognitionAlternative {\n return this.#alternatives[index];\n }\n [index: number]: SpeechRecognitionAlternative;\n [Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative> {\n return this.#alternatives[\n Symbol.iterator\n ]() as ArrayIterator<SpeechRecognitionAlternative>;\n }\n\n constructor(\n isFinal: boolean,\n alternatives: ExpoSpeechRecognitionAlternative[],\n ) {\n this.isFinal = isFinal;\n this.length = alternatives.length;\n this.#alternatives = alternatives;\n for (let i = 0; i < alternatives.length; i++) {\n this[i] = alternatives[i];\n }\n }\n}\n\nclass ExpoSpeechRecognitionAlternative implements SpeechRecognitionAlternative {\n confidence: number;\n transcript: string;\n\n constructor(confidence: number, transcript: string) {\n this.confidence = confidence;\n this.transcript = transcript;\n }\n}\n"]}
1
+ {"version":3,"file":"ExpoWebSpeechRecognition.js","sourceRoot":"","sources":["../src/ExpoWebSpeechRecognition.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAM5E,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,MAAmB,EAAE,EAAE,CAAC,CAAC;IAChD,SAAS,EAAE,CAAU;IACrB,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,CAAU;IAC1B,UAAU,EAAE,KAAK;IACjB,eAAe,EAAE,CAAU;IAC3B,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE;IACtB,aAAa,EAAE,MAAM;IACrB,gBAAgB,EAAE,KAAK;IACvB,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,CAAU;IAChB,cAAc,E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CAAC;QAC7B,CAAC;IACH,CAAC;CACF;AAED,MAAM,gCAAgC;IACpC,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,YAAY,UAAkB,EAAE,UAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Import the native module. On web, it will be resolved to ExpoSpeechRecognition.web.ts\n// and on native platforms to ExpoSpeechRecognition.ts\nimport type { EventSubscription } from \"expo-modules-core\";\nimport { ExpoSpeechRecognitionModule } from \"./ExpoSpeechRecognitionModule\";\nimport type {\n ExpoSpeechRecognitionNativeEventMap,\n ExpoSpeechRecognitionOptions,\n} from \"./ExpoSpeechRecognitionModule.types\";\n\nconst noop = () => {};\n\nconst createEventData = (target: EventTarget) => ({\n AT_TARGET: 2 as const,\n bubbles: false,\n BUBBLING_PHASE: 3 as const,\n cancelable: false,\n CAPTURING_PHASE: 1 as const,\n composed: false,\n composedPath: () => [],\n currentTarget: target,\n defaultPrevented: false,\n eventPhase: 0,\n isTrusted: true,\n NONE: 0 as const,\n preventDefault: noop,\n resultIndex: 0,\n stopImmediatePropagation: noop,\n stopPropagation: noop,\n target,\n timeStamp: 0,\n type: \"\",\n cancelBubble: false,\n returnValue: false,\n srcElement: null,\n initEvent: noop,\n});\n\ntype NativeEventAndListener<\n TEventName extends keyof ExpoSpeechRecognitionNativeEventMap,\n> = {\n /** Event name to listen for on native side */\n eventName: TEventName;\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[TEventName],\n ) => void;\n};\n\nfunction stubEvent<K extends keyof SpeechRecognitionEventMap>(\n eventName: K,\n instance: ExpoWebSpeechRecognition,\n listener: (this: SpeechRecognition, ev: Event) => unknown,\n): NativeEventAndListener<K> {\n return {\n eventName,\n nativeListener: (nativeEvent) =>\n listener.call(instance, createEventData(instance)),\n };\n}\n\n/**\n * Transforms the native listener payloads to web-compatible shapes\n */\nconst WebListenerTransformers: {\n [K in keyof SpeechRecognitionEventMap]?: (\n instance: ExpoWebSpeechRecognition,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => unknown,\n ) => NativeEventAndListener<K>;\n} = {\n audiostart: (instance, listener) => {\n return {\n eventName: \"audiostart\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n audioend: (instance, listener) => {\n return {\n eventName: \"audioend\",\n nativeListener(nativeEvent) {\n listener.call(instance, {\n ...createEventData(instance),\n uri: nativeEvent.uri,\n });\n },\n };\n },\n nomatch: (instance, listener) => {\n // @ts-ignore\n return stubEvent(\"nomatch\", instance, listener);\n },\n end: (instance, listener) => {\n return stubEvent(\"end\", instance, listener);\n },\n start: (instance, listener) => {\n return {\n eventName: \"start\",\n nativeListener() {\n listener.call(instance, createEventData(instance));\n },\n };\n },\n error: (instance, listener) => {\n return {\n eventName: \"error\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"error\"],\n ) => {\n const clientEvent: SpeechRecognitionEventMap[\"error\"] = {\n ...createEventData(instance),\n // TODO: handle custom ios error codes\n error: nativeEvent.error as SpeechRecognitionErrorCode,\n message: nativeEvent.message,\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n result: (instance, listener) => {\n return {\n eventName: \"result\",\n nativeListener: (\n nativeEvent: ExpoSpeechRecognitionNativeEventMap[\"result\"],\n ) => {\n if (!instance.interimResults && !nativeEvent.isFinal) {\n return;\n }\n const alternatives = nativeEvent.results.map(\n (result) =>\n new ExpoSpeechRecognitionAlternative(\n result.confidence,\n result.transcript,\n ),\n );\n const clientEvent: SpeechRecognitionEventMap[\"result\"] = {\n ...createEventData(instance),\n results: new ExpoSpeechRecognitionResultList([\n new ExpoSpeechRecognitionResult(nativeEvent.isFinal, alternatives),\n ]),\n };\n listener.call(instance, clientEvent);\n },\n };\n },\n};\n\ntype SpeechListener<K extends keyof SpeechRecognitionEventMap> = (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n) => any;\n\n/** A compatibility wrapper that implements the web SpeechRecognition API for React Native. */\nexport class ExpoWebSpeechRecognition implements SpeechRecognition {\n lang = \"en-US\";\n grammars: SpeechGrammarList = new ExpoWebSpeechGrammarList();\n maxAlternatives = 1;\n continuous = false;\n processLocally = false;\n\n #interimResults = false;\n\n get interimResults(): boolean {\n return this.#interimResults;\n }\n\n set interimResults(interimResults: boolean) {\n this.#interimResults = interimResults;\n // Subscribe to native\n }\n\n // Extended properties\n\n /** [EXTENDED, default: undefined] An array of strings that will be used to provide context to the speech recognition engine. */\n contextualStrings?: string[] = undefined;\n /** [EXTENDED, default: false] Whether the speech recognition engine should require the device to be on when the recognition starts. */\n requiresOnDeviceRecognition = false;\n /** [EXTENDED, default: false] Whether the speech recognition engine should add punctuation to the transcription. */\n addsPunctuation = false;\n /** [EXTENDED, default: undefined] Android-specific options to pass to the recognizer. */\n androidIntentOptions: ExpoSpeechRecognitionOptions[\"androidIntentOptions\"];\n /** [EXTENDED, default: undefined] Audio source options to pass to the recognizer. */\n audioSource?: ExpoSpeechRecognitionOptions[\"audioSource\"];\n /** [EXTENDED, default: undefined] Audio recording options to pass to the recognizer. */\n recordingOptions?: ExpoSpeechRecognitionOptions[\"recordingOptions\"];\n /** [EXTENDED, default: \"android.speech.action.RECOGNIZE_SPEECH\"] The kind of intent action */\n androidIntent?: ExpoSpeechRecognitionOptions[\"androidIntent\"] = undefined;\n /** [EXTENDED, default: undefined] The hint for the speech recognition task. */\n iosTaskHint?: ExpoSpeechRecognitionOptions[\"iosTaskHint\"] = undefined;\n /** [EXTENDED, default: undefined] The audio session category and options to use. */\n iosCategory?: ExpoSpeechRecognitionOptions[\"iosCategory\"] = undefined;\n /**\n * [EXTENDED, default: undefined]\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.samsung.android.bixby.agent\"\n */\n androidRecognitionServicePackage: ExpoSpeechRecognitionOptions[\"androidRecognitionServicePackage\"];\n\n // keyed by listener function\n #subscriptionMap: Map<SpeechListener<any>, EventSubscription[]> = new Map();\n\n start() {\n ExpoSpeechRecognitionModule.requestPermissionsAsync().then(() => {\n // A result doesn't matter,\n // the module will emit an error if permissions are not granted\n ExpoSpeechRecognitionModule.start({\n lang: this.lang,\n interimResults: this.interimResults,\n maxAlternatives: this.maxAlternatives,\n contextualStrings: this.contextualStrings,\n requiresOnDeviceRecognition: this.requiresOnDeviceRecognition,\n addsPunctuation: this.addsPunctuation,\n continuous: this.continuous,\n recordingOptions: this.recordingOptions,\n androidIntentOptions: this.androidIntentOptions,\n androidRecognitionServicePackage: this.androidRecognitionServicePackage,\n audioSource: this.audioSource,\n androidIntent: this.androidIntent,\n iosTaskHint: this.iosTaskHint,\n iosCategory: this.iosCategory,\n });\n });\n }\n stop = ExpoSpeechRecognitionModule.stop;\n abort = ExpoSpeechRecognitionModule.abort;\n\n #onstart: SpeechListener<\"start\"> | null = null;\n set onstart(listener: SpeechListener<\"start\"> | null) {\n this._setListeners(\"start\", listener, this.#onstart);\n this.#onstart = listener;\n }\n /** Fired when the speech recognition starts. */\n get onstart() {\n return this.#onstart;\n }\n\n #onend: SpeechListener<\"end\"> | null = null;\n set onend(listener: SpeechListener<\"end\"> | null) {\n this._setListeners(\n \"end\",\n (ev) => {\n listener?.call(this, ev);\n },\n this.#onend,\n );\n this.#onend = listener;\n }\n /** Fired when the speech recognition service has disconnected. */\n get onend() {\n return this.#onend;\n }\n\n #onerror: SpeechListener<\"error\"> | null = null;\n set onerror(listener: SpeechListener<\"error\"> | null) {\n this._setListeners(\"error\", listener, this.#onerror);\n this.#onerror = listener;\n }\n /** Fired when the speech recognition service encounters an error. */\n get onerror() {\n return this.#onerror;\n }\n\n _setListeners<K extends keyof SpeechRecognitionEventMap>(\n key: K,\n listenerFn: SpeechListener<K> | null,\n existingListener: SpeechListener<K> | null,\n ) {\n if (existingListener) {\n this.removeEventListener(key, existingListener);\n }\n if (listenerFn) {\n this.addEventListener(key, listenerFn);\n }\n }\n\n #onresult: SpeechListener<\"result\"> | null = null;\n set onresult(listener: SpeechListener<\"result\"> | null) {\n this._setListeners(\"result\", listener, this.#onresult);\n this.#onresult = listener;\n }\n /** Fired when the speech recognition service returns a result —\n * a word or phrase has been positively recognized and this has been communicated back to the app. */\n get onresult() {\n return this.#onresult;\n }\n\n #onnomatch: SpeechListener<\"nomatch\"> | null = null;\n set onnomatch(listener: SpeechListener<\"nomatch\"> | null) {\n this._setListeners(\"nomatch\", listener, this.#onnomatch);\n this.#onnomatch = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onnomatch() {\n return this.#onnomatch;\n }\n\n #onspeechstart: SpeechListener<\"speechstart\"> | null = null;\n set onspeechstart(listener: SpeechListener<\"speechstart\"> | null) {\n this._setListeners(\"speechstart\", listener, this.#onspeechstart);\n this.#onspeechstart = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechstart() {\n return this.#onspeechstart;\n }\n\n #onspeechend: SpeechListener<\"speechend\"> | null = null;\n set onspeechend(listener: SpeechListener<\"speechend\"> | null) {\n this._setListeners(\"speechend\", listener, this.#onspeechend);\n this.#onspeechend = listener;\n }\n /** Fired when the speech recognition service returns a final result with no significant recognition. */\n get onspeechend() {\n return this.#onspeechend;\n }\n\n #onaudiostart: SpeechListener<\"audiostart\"> | null = null;\n set onaudiostart(listener: SpeechListener<\"audiostart\"> | null) {\n this._setListeners(\"audiostart\", listener, this.#onaudiostart);\n this.#onaudiostart = listener;\n }\n /** Fired when the user agent has started to capture audio. */\n get onaudiostart() {\n return this.#onaudiostart;\n }\n\n #onaudioend: SpeechListener<\"audioend\"> | null = null;\n set onaudioend(listener: SpeechListener<\"audioend\"> | null) {\n this._setListeners(\"audioend\", listener, this.#onaudioend);\n this.#onaudioend = listener;\n }\n /** Fired when the user agent has finished capturing audio. */\n get onaudioend() {\n return this.#onaudioend;\n }\n\n /** [TODO] */\n onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n /** [TODO] */\n onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null = null;\n\n addEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: SpeechListener<K>,\n options?: boolean | AddEventListenerOptions,\n ): void {\n const once = typeof options === \"object\" && options.once;\n\n // If the user opts in to only listening once,\n // wrap the listener in a function that removes the listener\n const wrappedListener = once\n ? (((ev) => {\n listener.call(this, ev);\n // remove the listeners from the map\n for (const sub of this.#subscriptionMap.get(listener) ?? []) {\n sub.remove();\n }\n this.#subscriptionMap.delete(listener);\n }) as SpeechListener<K>)\n : listener;\n\n // Enhance the native listener with any necessary polyfills\n const enhancedEvent: NativeEventAndListener<K> =\n WebListenerTransformers[type]?.(this, wrappedListener) ??\n stubEvent(\n type,\n this,\n wrappedListener as (this: SpeechRecognition, ev: Event) => unknown,\n );\n\n const subscription = ExpoSpeechRecognitionModule.addListener(\n enhancedEvent.eventName,\n // @ts-expect-error\n enhancedEvent.nativeListener,\n );\n\n // Store the subscriptions so we can remove them later\n // This is keyed by the listener function so we can remove all subscriptions for a given listener\n this.#subscriptionMap.set(listener, [subscription]);\n }\n\n removeEventListener<K extends keyof SpeechRecognitionEventMap>(\n type: K,\n listener: (\n this: SpeechRecognition,\n ev: SpeechRecognitionEventMap[K],\n ) => any,\n options?: boolean | EventListenerOptions | undefined,\n ): void {\n const subscriptions = this.#subscriptionMap.get(listener);\n if (subscriptions) {\n for (const subscription of subscriptions) {\n subscription.remove();\n }\n this.#subscriptionMap.delete(listener);\n }\n }\n\n dispatchEvent(event: Event): boolean {\n throw new Error(\"Method not implemented.\");\n }\n}\n\n/**\n * This class is just a polyfill and does nothing on Android/iOS\n */\nexport class ExpoWebSpeechGrammarList implements SpeechGrammarList {\n get length() {\n return this.#grammars.length;\n }\n #grammars: ExpoWebSpeechGrammar[] = [];\n [index: number]: SpeechGrammar; // Indexer property\n\n addFromURI(src: string, weight?: number | undefined): void {\n // todo\n }\n\n item(index: number): ExpoWebSpeechGrammar {\n return this.#grammars[index]!;\n }\n\n addFromString = (grammar: string, weight?: number) => {\n // TODO: parse grammar to html entities (data:application/xml,....)\n this.#grammars.push(new ExpoWebSpeechGrammar(grammar, weight));\n // Set key on this object for compatibility with web SpeechGrammarList API\n this[this.length - 1] = this.#grammars[this.length - 1]!;\n };\n}\n\nexport class ExpoWebSpeechGrammar implements SpeechGrammar {\n src = \"\";\n weight = 1;\n\n constructor(src: string, weight?: number) {\n this.src = src;\n this.weight = weight ?? 1;\n }\n}\n\nclass ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {\n #results: ExpoSpeechRecognitionResult[] = [];\n\n [Symbol.iterator](): ArrayIterator<ExpoSpeechRecognitionResult> {\n return this.#results[\n Symbol.iterator\n ]() as ArrayIterator<ExpoSpeechRecognitionResult>;\n }\n length: number;\n item(index: number): SpeechRecognitionResult {\n return this.#results[index]!;\n }\n [index: number]: SpeechRecognitionResult;\n\n constructor(results: ExpoSpeechRecognitionResult[]) {\n this.#results = results;\n this.length = results.length;\n for (let i = 0; i < this.#results.length; i++) {\n this[i] = this.#results[i]!;\n }\n }\n}\n\nclass ExpoSpeechRecognitionResult implements SpeechRecognitionResult {\n #alternatives: ExpoSpeechRecognitionAlternative[] = [];\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/isFinal) */\n readonly isFinal: boolean;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/length) */\n length: number;\n /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */\n item(index: number): SpeechRecognitionAlternative {\n return this.#alternatives[index]!;\n }\n [index: number]: SpeechRecognitionAlternative;\n [Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative> {\n return this.#alternatives[\n Symbol.iterator\n ]() as ArrayIterator<SpeechRecognitionAlternative>;\n }\n\n constructor(\n isFinal: boolean,\n alternatives: ExpoSpeechRecognitionAlternative[],\n ) {\n this.isFinal = isFinal;\n this.length = alternatives.length;\n this.#alternatives = alternatives;\n for (let i = 0; i < alternatives.length; i++) {\n this[i] = alternatives[i]!;\n }\n }\n}\n\nclass ExpoSpeechRecognitionAlternative implements SpeechRecognitionAlternative {\n confidence: number;\n transcript: string;\n\n constructor(confidence: number, transcript: string) {\n this.confidence = confidence;\n this.transcript = transcript;\n }\n}\n"]}
@@ -12,20 +12,33 @@ public class EXSpeechRecognitionPermissionRequester: NSObject, EXPermissionsRequ
12
12
  ) {
13
13
  SFSpeechRecognizer.requestAuthorization { status in
14
14
  if status != .authorized {
15
- resolve(self.getPermissions())
15
+ resolve(self.permissionsResult(
16
+ speechPermission: status,
17
+ recordPermission: AVAudioSession.sharedInstance().recordPermission
18
+ ))
16
19
  return
17
20
  }
18
21
  AVAudioSession.sharedInstance().requestRecordPermission { authorized in
19
- resolve(self.getPermissions())
22
+ resolve(self.permissionsResult(
23
+ speechPermission: status,
24
+ recordPermission: authorized ? .granted : .denied
25
+ ))
20
26
  }
21
27
  }
22
28
  }
23
29
 
24
30
  public func getPermissions() -> [AnyHashable: Any] {
25
- var status: EXPermissionStatus
31
+ return permissionsResult(
32
+ speechPermission: SFSpeechRecognizer.authorizationStatus(),
33
+ recordPermission: AVAudioSession.sharedInstance().recordPermission
34
+ )
35
+ }
26
36
 
27
- let recordPermission = AVAudioSession.sharedInstance().recordPermission
28
- let speechPermission = SFSpeechRecognizer.authorizationStatus()
37
+ private func permissionsResult(
38
+ speechPermission: SFSpeechRecognizerAuthorizationStatus,
39
+ recordPermission: AVAudioSession.RecordPermission
40
+ ) -> [AnyHashable: Any] {
41
+ var status: EXPermissionStatus
29
42
 
30
43
  if speechPermission == .authorized && recordPermission == .granted {
31
44
  status = EXPermissionStatusGranted
@@ -9,14 +9,16 @@ public class MicrophoneRequester: NSObject, EXPermissionsRequester {
9
9
  resolver resolve: @escaping EXPromiseResolveBlock, rejecter reject: EXPromiseRejectBlock
10
10
  ) {
11
11
  AVAudioSession.sharedInstance().requestRecordPermission { authorized in
12
- resolve(self.getPermissions())
12
+ resolve(self.permissionsResult(recordPermission: authorized ? .granted : .denied))
13
13
  }
14
14
  }
15
15
 
16
16
  public func getPermissions() -> [AnyHashable: Any] {
17
- var status: EXPermissionStatus
17
+ return permissionsResult(recordPermission: AVAudioSession.sharedInstance().recordPermission)
18
+ }
18
19
 
19
- let recordPermission = AVAudioSession.sharedInstance().recordPermission
20
+ private func permissionsResult(recordPermission: AVAudioSession.RecordPermission) -> [AnyHashable: Any] {
21
+ var status: EXPermissionStatus
20
22
 
21
23
  if recordPermission == .granted {
22
24
  status = EXPermissionStatusGranted
@@ -10,14 +10,16 @@ public class SpeechRecognizerRequester: NSObject, EXPermissionsRequester {
10
10
  resolver resolve: @escaping EXPromiseResolveBlock, rejecter reject: EXPromiseRejectBlock
11
11
  ) {
12
12
  SFSpeechRecognizer.requestAuthorization { status in
13
- resolve(self.getPermissions())
13
+ resolve(self.permissionsResult(speechPermission: status))
14
14
  }
15
15
  }
16
16
 
17
17
  public func getPermissions() -> [AnyHashable: Any] {
18
- var status: EXPermissionStatus
18
+ return permissionsResult(speechPermission: SFSpeechRecognizer.authorizationStatus())
19
+ }
19
20
 
20
- let speechPermission = SFSpeechRecognizer.authorizationStatus()
21
+ private func permissionsResult(speechPermission: SFSpeechRecognizerAuthorizationStatus) -> [AnyHashable: Any] {
22
+ var status: EXPermissionStatus
21
23
 
22
24
  if speechPermission == .authorized {
23
25
  status = EXPermissionStatusGranted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-speech-recognition",
3
- "version": "56.0.0",
3
+ "version": "56.0.3",
4
4
  "description": "Speech Recognition for React Native Expo projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -43,8 +43,8 @@
43
43
  "@changesets/cli": "^2.31.0",
44
44
  "@types/dom-speech-recognition": "^0.0.11",
45
45
  "@types/react": "~19.2.14",
46
- "expo": "^56.0.0-preview.12",
47
- "expo-module-scripts": "^55.0.2",
46
+ "expo": "~56.0.12",
47
+ "expo-module-scripts": "^56.0.3",
48
48
  "globals": "17.6.0",
49
49
  "typescript": "~6.0.3",
50
50
  "typescript-eslint": "8.59.0"
@@ -713,11 +713,11 @@ export declare class ExpoSpeechRecognitionModuleType extends NativeModule<ExpoSp
713
713
  locale: string;
714
714
  }): Promise<{
715
715
  /**
716
- * On Android 13, the status will be "opened_dialog" indicating that the model download dialog was opened.
717
- * On Android 14+, the status will be "download_success" indicating that the model download was successful.
718
- * On Android 14+, "download_canceled" will be returned if the download was canceled by a user interaction.
716
+ * On Android 13, "opened_dialog" - the model download dialog was shown (fire-and-forget, no events emitted).
717
+ * On Android 14+, "download_success" if the model downloaded immediately,
718
+ * or "download_scheduled" if the download was queued (e.g., waiting for WiFi).
719
719
  */
720
- status: "download_success" | "opened_dialog" | "download_canceled";
720
+ status: "download_success" | "opened_dialog" | "download_scheduled";
721
721
  message: string;
722
722
  }>;
723
723
  /**
@@ -324,14 +324,20 @@ const webToNativeEventMap: {
324
324
  if (isFinal) {
325
325
  const results: ExpoSpeechRecognitionNativeEventMap["result"]["results"] =
326
326
  [];
327
-
328
- for (let i = 0; i < ev.results[ev.resultIndex].length; i++) {
329
- const result = ev.results[ev.resultIndex][i];
330
- results.push({
331
- transcript: result.transcript,
332
- confidence: result.confidence,
333
- segments: [],
334
- });
327
+ const resultList = ev.results[ev.resultIndex];
328
+
329
+ if (resultList) {
330
+ for (let i = 0; i < resultList.length; i++) {
331
+ const result = resultList[i];
332
+ if (!result) {
333
+ continue;
334
+ }
335
+ results.push({
336
+ transcript: result.transcript,
337
+ confidence: result.confidence,
338
+ segments: [],
339
+ });
340
+ }
335
341
  }
336
342
  return {
337
343
  isFinal: true,
@@ -345,6 +351,9 @@ const webToNativeEventMap: {
345
351
 
346
352
  for (let i = ev.resultIndex; i < ev.results.length; i++) {
347
353
  const resultList = ev.results[i];
354
+ if (!resultList) {
355
+ continue;
356
+ }
348
357
 
349
358
  for (let j = 0; j < resultList.length; j++) {
350
359
  const result = resultList[j];
@@ -426,14 +426,14 @@ export class ExpoWebSpeechGrammarList implements SpeechGrammarList {
426
426
  }
427
427
 
428
428
  item(index: number): ExpoWebSpeechGrammar {
429
- return this.#grammars[index];
429
+ return this.#grammars[index]!;
430
430
  }
431
431
 
432
432
  addFromString = (grammar: string, weight?: number) => {
433
433
  // TODO: parse grammar to html entities (data:application/xml,....)
434
434
  this.#grammars.push(new ExpoWebSpeechGrammar(grammar, weight));
435
435
  // Set key on this object for compatibility with web SpeechGrammarList API
436
- this[this.length - 1] = this.#grammars[this.length - 1];
436
+ this[this.length - 1] = this.#grammars[this.length - 1]!;
437
437
  };
438
438
  }
439
439
 
@@ -457,7 +457,7 @@ class ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {
457
457
  }
458
458
  length: number;
459
459
  item(index: number): SpeechRecognitionResult {
460
- return this.#results[index];
460
+ return this.#results[index]!;
461
461
  }
462
462
  [index: number]: SpeechRecognitionResult;
463
463
 
@@ -465,7 +465,7 @@ class ExpoSpeechRecognitionResultList implements SpeechRecognitionResultList {
465
465
  this.#results = results;
466
466
  this.length = results.length;
467
467
  for (let i = 0; i < this.#results.length; i++) {
468
- this[i] = this.#results[i];
468
+ this[i] = this.#results[i]!;
469
469
  }
470
470
  }
471
471
  }
@@ -478,7 +478,7 @@ class ExpoSpeechRecognitionResult implements SpeechRecognitionResult {
478
478
  length: number;
479
479
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SpeechRecognitionResult/item) */
480
480
  item(index: number): SpeechRecognitionAlternative {
481
- return this.#alternatives[index];
481
+ return this.#alternatives[index]!;
482
482
  }
483
483
  [index: number]: SpeechRecognitionAlternative;
484
484
  [Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative> {
@@ -495,7 +495,7 @@ class ExpoSpeechRecognitionResult implements SpeechRecognitionResult {
495
495
  this.length = alternatives.length;
496
496
  this.#alternatives = alternatives;
497
497
  for (let i = 0; i < alternatives.length; i++) {
498
- this[i] = alternatives[i];
498
+ this[i] = alternatives[i]!;
499
499
  }
500
500
  }
501
501
  }