expo-speech-recognition 57.0.0 → 57.1.1

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
@@ -428,6 +428,8 @@ useSpeechRecognitionEvent("error", (event) => {
428
428
 
429
429
  If you would like to persist the recognized audio for later use, you can enable the `recordingOptions.persist` option when calling `start()`. Enabling this setting will emit an `{ uri: string }` event object in the `audiostart` and `audioend` events with the local file path.
430
430
 
431
+ Both events also carry `timestamp`, the epoch milliseconds when capturing started or stopped. Use it to line up app events with positions in the recording.
432
+
431
433
  > [!IMPORTANT]
432
434
  > This feature is available on Android 13+ and iOS. Call [`supportsRecording()`](#supportsrecording-boolean) to see if it's available before using this feature.
433
435
 
@@ -18,4 +18,14 @@ android {
18
18
  lintOptions {
19
19
  abortOnError false
20
20
  }
21
+ testOptions {
22
+ unitTests.all {
23
+ useJUnitPlatform()
24
+ }
25
+ }
26
+ }
27
+
28
+ dependencies {
29
+ testImplementation 'org.junit.jupiter:junit-jupiter:6.1.2'
30
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
21
31
  }
@@ -37,7 +37,7 @@ class ExpoAudioRecorder(
37
37
  private var audioRecorder: AudioRecord? = null
38
38
 
39
39
  var outputFile: File? = null
40
- var outputFileUri = "file://$outputFilePath"
40
+ val outputFileUri = outputFilePath?.let { "file://$it" }
41
41
 
42
42
  /** The file where the mic stream is being output to */
43
43
  private val tempPcmFile: File
@@ -65,6 +65,10 @@ class ExpoAudioRecorder(
65
65
  private var recordingThread: Thread? = null
66
66
  private var isRecordingAudio = false
67
67
 
68
+ /** Epoch milliseconds when the microphone stopped */
69
+ var stoppedAtMillis: Long? = null
70
+ private set
71
+
68
72
  companion object {
69
73
  private const val TAG = "ExpoAudioRecorder"
70
74
 
@@ -164,6 +168,7 @@ class ExpoAudioRecorder(
164
168
  override fun stop() {
165
169
  isRecordingAudio = false
166
170
  audioRecorder?.stop()
171
+ stoppedAtMillis = System.currentTimeMillis()
167
172
  audioRecorder?.release()
168
173
  audioRecorder = null
169
174
  recordingThread = null
@@ -458,7 +458,11 @@ class ExpoSpeechRecognitionModule : Module() {
458
458
  "installedLocales" to installedLocales,
459
459
  ),
460
460
  )
461
- recognizer.destroy()
461
+ try {
462
+ recognizer.destroy()
463
+ } catch (e: Throwable) {
464
+ // Ignore Android framework bug where unbindService throws IllegalArgumentException
465
+ }
462
466
  }
463
467
 
464
468
  override fun onError(error: Int) {
@@ -477,7 +481,11 @@ class ExpoSpeechRecognitionModule : Module() {
477
481
  )
478
482
  }, 50)
479
483
 
480
- recognizer.destroy()
484
+ try {
485
+ recognizer.destroy()
486
+ } catch (e: Throwable) {
487
+ // Ignore Android framework bug where unbindService throws IllegalArgumentException
488
+ }
481
489
  }
482
490
  },
483
491
  )
@@ -119,7 +119,12 @@ class ExpoSpeechService(
119
119
  log("Start recognition.")
120
120
 
121
121
  // Destroy any previous SpeechRecognizer / audio recorder
122
- speech?.destroy()
122
+ try {
123
+ speech?.destroy()
124
+ } catch (e: Throwable) {
125
+ // Ignore Android framework bug where unbindService throws IllegalArgumentException
126
+ }
127
+ speech = null
123
128
  audioRecorder?.stop()
124
129
  audioRecorder = null
125
130
  delayedFileStreamer?.close()
@@ -134,7 +139,11 @@ class ExpoSpeechService(
134
139
  speech = createSpeechRecognizer(options)
135
140
 
136
141
  // Start the audio recorder
137
- audioRecorder?.start()
142
+ val recorderStartedAtMillis =
143
+ audioRecorder?.let {
144
+ it.start()
145
+ System.currentTimeMillis()
146
+ }
138
147
 
139
148
  // Start listening
140
149
  speech?.setRecognitionListener(this)
@@ -146,6 +155,7 @@ class ExpoSpeechService(
146
155
  "audiostart",
147
156
  mapOf(
148
157
  "uri" to audioRecorder?.outputFileUri,
158
+ "timestamp" to (recorderStartedAtMillis ?: System.currentTimeMillis()),
149
159
  ),
150
160
  )
151
161
  } catch (e: Exception) {
@@ -168,12 +178,14 @@ class ExpoSpeechService(
168
178
  */
169
179
  private fun stopRecording() {
170
180
  audioRecorder?.stop()
181
+ val timestamp = audioRecorder?.stoppedAtMillis ?: System.currentTimeMillis()
171
182
  if (audioRecorder?.outputFile != null) {
172
183
  val uri = audioRecorder?.outputFile?.absolutePath?.let { "file://$it" }
173
184
  sendEvent(
174
185
  "audioend",
175
186
  mapOf(
176
187
  "uri" to uri,
188
+ "timestamp" to timestamp,
177
189
  ),
178
190
  )
179
191
  } else {
@@ -181,6 +193,7 @@ class ExpoSpeechService(
181
193
  "audioend",
182
194
  mapOf(
183
195
  "uri" to null,
196
+ "timestamp" to timestamp,
184
197
  ),
185
198
  )
186
199
  }
@@ -233,7 +246,12 @@ class ExpoSpeechService(
233
246
  } catch (e: Exception) {
234
247
  // do nothing
235
248
  }
236
- speech?.destroy()
249
+ try {
250
+ speech?.destroy()
251
+ } catch (e: Throwable) {
252
+ // Ignore Android framework bug where unbindService throws IllegalArgumentException
253
+ }
254
+ speech = null
237
255
  stopRecording()
238
256
  soundState = SoundState.INACTIVE
239
257
  sendEvent("end", null)
@@ -130,6 +130,16 @@ export type ExpoSpeechRecognitionNativeEventMap = {
130
130
  * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.wav`
131
131
  */
132
132
  uri: string | null;
133
+ /**
134
+ * Epoch milliseconds when audio capturing started, comparable to `Date.now()`.
135
+ * May have a fractional part.
136
+ *
137
+ * With `recordingOptions.persist`, it marks the start of the file to within tens of milliseconds.
138
+ *
139
+ * iOS: an audio route change mid-recording, such as connecting headphones, leaves a gap in the file.
140
+ * Positions after the gap drift from this timestamp.
141
+ */
142
+ timestamp: number;
133
143
  };
134
144
  /** Audio capturing had ended */
135
145
  audioend: {
@@ -142,6 +152,14 @@ export type ExpoSpeechRecognitionNativeEventMap = {
142
152
  * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.wav`
143
153
  */
144
154
  uri: string | null;
155
+ /**
156
+ * Epoch milliseconds when the microphone stopped, comparable to `Date.now()`.
157
+ * May have a fractional part.
158
+ *
159
+ * Native code records this before it finalizes the file, so
160
+ * `audioend.timestamp - audiostart.timestamp` approximates the recording duration.
161
+ */
162
+ timestamp: number;
145
163
  };
146
164
  end: null;
147
165
  soundstart: null;
@@ -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;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,kCAAkC,GAAG;IAC/C,sDAAsD;IACtD,eAAe,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,qHAAqH;IACrH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,OAAO,EAAE,OAAO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AoB,CAAC;QACpE,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAEjD;;;;;;;OAOG;IACH,oCAAoC,IAAI;QACtC,QAAQ,EAAE,2BAA2B,CAAC;QACtC,eAAe,EAAE,kCAAkC,EAAE,CAAC;QACtD,IAAI,EAAE,uBAAuB,CAAC;KAC/B;IACD;;;;;;OAMG;IACH,wBAAwB,CACtB,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QACR,4FAA4F;QAC5F,0BAA0B,EAAE,OAAO,CAAC;KACrC,GACA,IAAI;IACP;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,sBAAsB,CAAC;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,O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KACrC,GACA,IAAI;IACP;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,sBAAsB,CAAC;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 +1 @@
1
- {"version":3,"file":"ExpoSpeechRecognitionModule.types.js","sourceRoot":"","sources":["../src/ExpoSpeechRecognitionModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionResponse } from \"expo-modules-core\";\nimport type { NativeModule } from \"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
+ {"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 * Epoch milliseconds when audio capturing started, comparable to `Date.now()`.\n * May have a fractional part.\n *\n * With `recordingOptions.persist`, it marks the start of the file to within tens of milliseconds.\n *\n * iOS: an audio route change mid-recording, such as connecting headphones, leaves a gap in the file.\n * Positions after the gap drift from this timestamp.\n */\n timestamp: number;\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 * Epoch milliseconds when the microphone stopped, comparable to `Date.now()`.\n * May have a fractional part.\n *\n * Native code records this before it finalizes the file, so\n * `audioend.timestamp - audiostart.timestamp` approximates the recording duration.\n */\n timestamp: number;\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":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AYnC,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;AAoGD,eAAO,MAAM,2BAA2B,uCAGvC,CAAC"}
@@ -213,8 +213,14 @@ class ExpoSpeechRecognitionModuleWeb extends NativeModule {
213
213
  * Convert the web SpeechRecognitionEventMap to the native event map for compatibility
214
214
  */
215
215
  const webToNativeEventMap = {
216
- audioend: (ev) => ({ uri: null }),
217
- audiostart: (ev) => ({ uri: null }),
216
+ audioend: (ev) => ({
217
+ uri: null,
218
+ timestamp: performance.timeOrigin + ev.timeStamp,
219
+ }),
220
+ audiostart: (ev) => ({
221
+ uri: null,
222
+ timestamp: performance.timeOrigin + ev.timeStamp,
223
+ }),
218
224
  end: (ev) => null,
219
225
  error: (ev) => ({
220
226
  // TODO: add "phrases-not-supported" support to the type
@@ -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;QAE1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AAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,SAAS;gBACX,CAAC;gBACD,QAAQ,CAAC,IAAI,CAAC;oBACZ,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,OAAO,EAAE,MAAM,CAAC,UAAU;oBAC1B,eAAe,EAAE,CAAC;oBAClB,aAAa,EAAE,CAAC;iBACjB,CAAC,CAAC;gBAEH,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC;gBAClC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP;oBACE,UAAU;oBACV,UAAU,EACR,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;wBACxD,QAAQ,CAAC,MAAM;oBACjB,QAAQ;iBACT;aACF;SACF,CAAC;IACJ,CAAC;IACD,UAAU,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 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
+ {"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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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) => ({\n uri: null,\n timestamp: performance.timeOrigin + ev.timeStamp,\n }),\n audiostart: (ev) => ({\n uri: null,\n timestamp: performance.timeOrigin + ev.timeStamp,\n }),\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.d.ts","sourceRoot":"","sources":["../src/ExpoWebSpeechRecognition.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,qCAAqC,CAAC;AAiJ7C,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,yBAAyB,IAAI,CAC/D,IAAI,EAAE,iBAAiB,EACvB,EAAE,EAAE,yBAAyB,CAAC,CAAC,CAAC,KAC7B,GAAG,CAAC;AAET,8FAA8F;AAC9F,qBAAa,wBAAyB,YAAW,iBAAiB;;IAChE,IAAI,SAAW;IACf,QAAQ,EAAE,iBAAiB,CAAkC;IAC7D,eAAe,SAAK;IACpB,UAAU,UAAS;IACnB,cAAc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AK,EAAE,MAAM,GAAG,oBAAoB;IAIzC,aAAa,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,UAK/C;CACH;AAED,qBAAa,oBAAqB,YAAW,aAAa;IACxD,GAAG,SAAM;IACT,MAAM,SAAK;gBAEC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAIzC"}
@@ -42,6 +42,7 @@ const WebListenerTransformers = {
42
42
  listener.call(instance, {
43
43
  ...createEventData(instance),
44
44
  uri: nativeEvent.uri,
45
+ timestamp: nativeEvent.timestamp,
45
46
  });
46
47
  },
47
48
  };
@@ -53,6 +54,7 @@ const WebListenerTransformers = {
53
54
  listener.call(instance, {
54
55
  ...createEventData(instance),
55
56
  uri: nativeEvent.uri,
57
+ timestamp: nativeEvent.timestamp,
56
58
  });
57
59
  },
58
60
  };
@@ -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,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,EAAE,IAAI;IACpB,WAAW,EAAE,CAAC;IACd,wBAAwB,EAAE,IAAI;IAC9B,eAAe,EAAE,IAAI;IACrB,MAAM;IACN,SAAS,EAAE,CA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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,EAAE,IAAI;IACpB,WAAW,EAAE,CAAC;IACd,wBAAwB,EAAE,IAAI;IAC9B,eAAe,EAAE,IAAI;IACrB,MAAM;IACN,SAAS,EAAE,CAAC;IACZ,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC;AAYH,SAAS,SAAS,CAChB,SAAY,EACZ,QAAkC,EAClC,QAAyD;IAEzD,OAAO;QACL,SAAS;QACT,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE,CAC9B,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,CA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GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AAED,MAAM,2BAA2B;IAC/B,aAAa,GAAuC,EAAE,CAAC;IACvD,kGAAkG;IACzF,OAAO,CAAU;IAC1B,iGAAiG;IACjG,MAAM,CAAS;IACf,+FAA+F;IAC/F,IAAI,CAAC,KAAa;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAE,CAAC;IACpC,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC,aAAa,CACvB,MAAM,CAAC,QAAQ,CAChB,EAAiD,CAAC;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,CAAE,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 timestamp: nativeEvent.timestamp,\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 timestamp: nativeEvent.timestamp,\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"]}
@@ -240,20 +240,20 @@ public class ExpoSpeechRecognitionModule: Module {
240
240
  speechStartHandler: { [weak self] in
241
241
  self?.sendEvent("speechstart")
242
242
  },
243
- audioStartHandler: { [weak self] filePath in
243
+ audioStartHandler: { [weak self] filePath, timestamp in
244
244
  if let filePath: String {
245
245
  let uri = filePath.hasPrefix("file://") ? filePath : "file://" + filePath
246
- self?.sendEvent("audiostart", ["uri": uri])
246
+ self?.sendEvent("audiostart", ["uri": uri, "timestamp": timestamp])
247
247
  } else {
248
- self?.sendEvent("audiostart", ["uri": nil])
248
+ self?.sendEvent("audiostart", ["uri": nil, "timestamp": timestamp])
249
249
  }
250
250
  },
251
- audioEndHandler: { [weak self] filePath in
251
+ audioEndHandler: { [weak self] filePath, timestamp in
252
252
  if let filePath: String {
253
253
  let uri = filePath.hasPrefix("file://") ? filePath : "file://" + filePath
254
- self?.sendEvent("audioend", ["uri": uri])
254
+ self?.sendEvent("audioend", ["uri": uri, "timestamp": timestamp])
255
255
  } else {
256
- self?.sendEvent("audioend", ["uri": nil])
256
+ self?.sendEvent("audioend", ["uri": nil, "timestamp": timestamp])
257
257
  }
258
258
  },
259
259
  volumeChangeHandler: { [weak self] value in
@@ -42,12 +42,14 @@ actor ExpoSpeechRecognizer: ObservableObject {
42
42
  private var audioSessionRouteChangeObserver: NSObjectProtocol?
43
43
  /// Whether the recognizer has been stopped by the user or the timer has timed out
44
44
  private var stoppedListening = false
45
+ /// Epoch milliseconds when the audio engine stopped
46
+ private var audioEndTimestampMillis: Double?
45
47
 
46
48
  /// Detection timer, for non-continuous speech recognition
47
49
  @MainActor var detectionTimer: Timer?
48
50
 
49
51
  @MainActor var endHandler: (() -> Void)?
50
- @MainActor var audioEndHandler: ((String?) -> Void)?
52
+ @MainActor var audioEndHandler: ((String?, Double) -> Void)?
51
53
  @MainActor var volumeChangeHandler: ((Float) -> Void)?
52
54
  @MainActor var errorHandler: ((Error) -> Void)?
53
55
 
@@ -129,8 +131,8 @@ actor ExpoSpeechRecognizer: ObservableObject {
129
131
  endHandler: (() -> Void)?,
130
132
  startHandler: @escaping (() -> Void),
131
133
  speechStartHandler: @escaping (() -> Void),
132
- audioStartHandler: @escaping (String?) -> Void,
133
- audioEndHandler: @escaping (String?) -> Void,
134
+ audioStartHandler: @escaping (String?, Double) -> Void,
135
+ audioEndHandler: @escaping (String?, Double) -> Void,
134
136
  volumeChangeHandler: @escaping (Float) -> Void
135
137
  ) {
136
138
  self.endHandler = endHandler
@@ -203,7 +205,7 @@ actor ExpoSpeechRecognizer: ObservableObject {
203
205
  errorHandler: @escaping (Error) -> Void,
204
206
  startHandler: @escaping () -> Void,
205
207
  speechStartHandler: @escaping () -> Void,
206
- audioStartHandler: @escaping (String?) -> Void
208
+ audioStartHandler: @escaping (String?, Double) -> Void
207
209
  ) {
208
210
  // Reset the speech recognizer before starting
209
211
  reset(andEmitEnd: false)
@@ -233,6 +235,7 @@ actor ExpoSpeechRecognizer: ObservableObject {
233
235
  } else {
234
236
  try prepareMicrophoneRecognition(request: request, options: options)
235
237
  }
238
+ let audioStartTimestampMillis = Date().timeIntervalSince1970 * 1000
236
239
 
237
240
  startRecognitionTask(
238
241
  with: request,
@@ -248,7 +251,7 @@ actor ExpoSpeechRecognizer: ObservableObject {
248
251
  startHandler()
249
252
 
250
253
  // If user has opted in to recording, emit an "audiostart" event with the path
251
- audioStartHandler(outputFileUrl?.absoluteString)
254
+ audioStartHandler(outputFileUrl?.absoluteString, audioStartTimestampMillis)
252
255
  } catch {
253
256
  errorHandler(error)
254
257
  reset(andEmitEnd: true)
@@ -486,10 +489,11 @@ actor ExpoSpeechRecognizer: ObservableObject {
486
489
 
487
490
  private func end() {
488
491
  let filePath = self.outputFileUrl?.absoluteString
492
+ let timestamp = audioEndTimestampMillis ?? Date().timeIntervalSince1970 * 1000
489
493
  outputFileUrl = nil
490
494
  Task {
491
495
  await MainActor.run {
492
- self.audioEndHandler?(filePath)
496
+ self.audioEndHandler?(filePath, timestamp)
493
497
  self.audioEndHandler = nil
494
498
  self.endHandler?()
495
499
  }
@@ -509,6 +513,7 @@ actor ExpoSpeechRecognizer: ObservableObject {
509
513
  }
510
514
  if audioEngine?.isRunning ?? false {
511
515
  audioEngine?.stop()
516
+ audioEndTimestampMillis = Date().timeIntervalSince1970 * 1000
512
517
  audioEngine?.inputNode.removeTap(onBus: 0)
513
518
  audioEngine?.inputNode.reset()
514
519
  audioEngine?.reset()
@@ -526,6 +531,9 @@ actor ExpoSpeechRecognizer: ObservableObject {
526
531
  stoppedListening = false
527
532
  task?.cancel()
528
533
  audioEngine?.stop()
534
+ if audioEngine != nil && audioEndTimestampMillis == nil {
535
+ audioEndTimestampMillis = Date().timeIntervalSince1970 * 1000
536
+ }
529
537
  // map through all the attached nodes
530
538
  // and remove the tap
531
539
  audioEngine?.attachedNodes.forEach(
@@ -563,6 +571,7 @@ actor ExpoSpeechRecognizer: ObservableObject {
563
571
  }
564
572
  end()
565
573
  }
574
+ audioEndTimestampMillis = nil
566
575
  }
567
576
 
568
577
  private static func prepareRequest(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-speech-recognition",
3
- "version": "57.0.0",
3
+ "version": "57.1.1",
4
4
  "description": "Speech Recognition for React Native Expo projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "clean": "expo-module clean",
13
13
  "lint": "expo-module lint",
14
14
  "test": "expo-module test",
15
+ "test:android": "node scripts/test-android.mjs",
15
16
  "prepare": "expo-module prepare",
16
17
  "prepublishOnly": "expo-module prepublishOnly",
17
18
  "expo-module": "expo-module",
@@ -0,0 +1,189 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import console from "node:console";
3
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ import process from "node:process";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const repositoryRoot = dirname(dirname(fileURLToPath(import.meta.url)));
9
+ const exampleProject = join(repositoryRoot, "example");
10
+ const androidProject = join(repositoryRoot, "example", "android");
11
+ const resultsDirectory = join(
12
+ repositoryRoot,
13
+ "android",
14
+ "build",
15
+ "test-results",
16
+ "testDebugUnitTest",
17
+ );
18
+ const startedAt = Date.now();
19
+
20
+ if (!existsSync(androidProject)) {
21
+ console.log("Preparing Android project with Expo prebuild...");
22
+ const prebuild = spawnSync(
23
+ process.platform === "win32" ? "npx.cmd" : "npx",
24
+ ["expo", "prebuild", "--platform", "android", "--no-install"],
25
+ {
26
+ cwd: exampleProject,
27
+ encoding: "utf8",
28
+ maxBuffer: 50 * 1024 * 1024,
29
+ },
30
+ );
31
+ const prebuildOutput = [prebuild.stdout, prebuild.stderr]
32
+ .filter(Boolean)
33
+ .join("\n")
34
+ .trim();
35
+
36
+ if (prebuild.error || prebuild.status !== 0) {
37
+ if (prebuildOutput) {
38
+ console.error(prebuildOutput);
39
+ }
40
+ console.error(
41
+ prebuild.error?.message ??
42
+ `Expo prebuild failed with exit code ${prebuild.status ?? "unknown"}.`,
43
+ );
44
+ process.exit(prebuild.status ?? 1);
45
+ }
46
+ }
47
+
48
+ const listReportFiles = () =>
49
+ readdirSync(resultsDirectory)
50
+ .filter((file) => file.startsWith("TEST-") && file.endsWith(".xml"))
51
+ .sort();
52
+
53
+ let previousReports = new Map();
54
+ if (existsSync(resultsDirectory)) {
55
+ previousReports = new Map(
56
+ listReportFiles().map((file) => [
57
+ file,
58
+ statSync(join(resultsDirectory, file)).mtimeMs,
59
+ ]),
60
+ );
61
+ }
62
+
63
+ const gradle = spawnSync(
64
+ join(androidProject, "gradlew"),
65
+ [
66
+ ":expo-speech-recognition:testDebugUnitTest",
67
+ "--console=plain",
68
+ "--warning-mode=none",
69
+ ],
70
+ {
71
+ cwd: androidProject,
72
+ encoding: "utf8",
73
+ maxBuffer: 50 * 1024 * 1024,
74
+ },
75
+ );
76
+
77
+ const buildOutput = [gradle.stdout, gradle.stderr].filter(Boolean).join("\n").trim();
78
+
79
+ let reportFiles;
80
+ try {
81
+ reportFiles = listReportFiles();
82
+ } catch (error) {
83
+ if (buildOutput) {
84
+ console.error(buildOutput);
85
+ }
86
+ console.error(`Gradle succeeded, but its JUnit results could not be read: ${error.message}`);
87
+ process.exit(1);
88
+ }
89
+
90
+ if (reportFiles.length === 0) {
91
+ if (buildOutput) {
92
+ console.error(buildOutput);
93
+ }
94
+ console.error("Gradle succeeded, but it produced no Android unit-test results.");
95
+ process.exit(1);
96
+ }
97
+
98
+ const hasFreshResults = reportFiles.some(
99
+ (file) =>
100
+ statSync(join(resultsDirectory, file)).mtimeMs !== previousReports.get(file),
101
+ );
102
+
103
+ if ((gradle.error || gradle.status !== 0) && !hasFreshResults) {
104
+ if (buildOutput) {
105
+ console.error(buildOutput);
106
+ }
107
+ console.error(
108
+ gradle.error?.message ??
109
+ `Android unit tests failed before producing results (exit code ${gradle.status ?? "unknown"}).`,
110
+ );
111
+ process.exit(gradle.status ?? 1);
112
+ }
113
+
114
+ const decodeXml = (value) =>
115
+ value
116
+ .replaceAll("&quot;", '"')
117
+ .replaceAll("&apos;", "'")
118
+ .replaceAll("&lt;", "<")
119
+ .replaceAll("&gt;", ">")
120
+ .replaceAll("&amp;", "&");
121
+
122
+ const attribute = (attributes, name) => {
123
+ const match = attributes.match(new RegExp(`\\b${name}="([^"]*)"`));
124
+ return match ? decodeXml(match[1]) : "";
125
+ };
126
+
127
+ let passed = 0;
128
+ let skipped = 0;
129
+ let failed = 0;
130
+
131
+ for (const reportFile of reportFiles) {
132
+ const xml = readFileSync(join(resultsDirectory, reportFile), "utf8");
133
+ const suiteAttributes = xml.match(/<testsuite\b([^>]*)>/)?.[1] ?? "";
134
+ const suiteName = attribute(suiteAttributes, "name").split(".").at(-1);
135
+
136
+ console.log(suiteName);
137
+
138
+ const testCases = xml.matchAll(
139
+ /<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g,
140
+ );
141
+ for (const testCase of testCases) {
142
+ const name = attribute(testCase[1], "name").replace(/\(\)$/, "");
143
+ const body = testCase[2] ?? "";
144
+ const failure = body.match(
145
+ /<(?:failure|error)\b([^>]*)>([\s\S]*?)<\/(?:failure|error)>/,
146
+ );
147
+
148
+ if (failure) {
149
+ failed += 1;
150
+ console.log(` ✗ ${name}`);
151
+ const message = attribute(failure[1], "message").replace(
152
+ /^[\w.$]+(?:Error|Exception):\s*/,
153
+ "",
154
+ );
155
+ if (message) {
156
+ console.log(` ${message}`);
157
+ }
158
+ const location = decodeXml(failure[2])
159
+ .split("\n")
160
+ .map((line) => line.trim())
161
+ .find((line) => line.startsWith("at expo.modules.speechrecognition."));
162
+ if (location) {
163
+ console.log(` ${location}`);
164
+ }
165
+ } else if (/<skipped\b/.test(body)) {
166
+ skipped += 1;
167
+ console.log(` ○ ${name}`);
168
+ } else {
169
+ passed += 1;
170
+ console.log(` ✓ ${name}`);
171
+ }
172
+ }
173
+ }
174
+
175
+ const summary = [`${passed} passed`];
176
+ if (skipped > 0) summary.push(`${skipped} skipped`);
177
+ if (failed > 0) summary.push(`${failed} failed`);
178
+ console.log(`\n${summary.join(", ")} in ${((Date.now() - startedAt) / 1000).toFixed(1)}s`);
179
+
180
+ if (failed > 0) {
181
+ process.exit(1);
182
+ }
183
+
184
+ if (gradle.error || gradle.status !== 0) {
185
+ if (buildOutput) {
186
+ console.error(`\n${buildOutput}`);
187
+ }
188
+ process.exit(gradle.status ?? 1);
189
+ }
@@ -150,6 +150,16 @@ export type ExpoSpeechRecognitionNativeEventMap = {
150
150
  * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.wav`
151
151
  */
152
152
  uri: string | null;
153
+ /**
154
+ * Epoch milliseconds when audio capturing started, comparable to `Date.now()`.
155
+ * May have a fractional part.
156
+ *
157
+ * With `recordingOptions.persist`, it marks the start of the file to within tens of milliseconds.
158
+ *
159
+ * iOS: an audio route change mid-recording, such as connecting headphones, leaves a gap in the file.
160
+ * Positions after the gap drift from this timestamp.
161
+ */
162
+ timestamp: number;
153
163
  };
154
164
  /** Audio capturing had ended */
155
165
  audioend: {
@@ -162,6 +172,14 @@ export type ExpoSpeechRecognitionNativeEventMap = {
162
172
  * - iOS: `file:///path/to/Library/Caches/audio_CD5E6C6C-3D9D-4754-9188-D6FAF97D9DF2.wav`
163
173
  */
164
174
  uri: string | null;
175
+ /**
176
+ * Epoch milliseconds when the microphone stopped, comparable to `Date.now()`.
177
+ * May have a fractional part.
178
+ *
179
+ * Native code records this before it finalizes the file, so
180
+ * `audioend.timestamp - audiostart.timestamp` approximates the recording duration.
181
+ */
182
+ timestamp: number;
165
183
  };
166
184
  end: null;
167
185
  soundstart: null;
@@ -309,8 +309,14 @@ const webToNativeEventMap: {
309
309
  ev: SpeechRecognitionEventMap[K],
310
310
  ) => ExpoSpeechRecognitionNativeEventMap[K];
311
311
  } = {
312
- audioend: (ev) => ({ uri: null }),
313
- audiostart: (ev) => ({ uri: null }),
312
+ audioend: (ev) => ({
313
+ uri: null,
314
+ timestamp: performance.timeOrigin + ev.timeStamp,
315
+ }),
316
+ audiostart: (ev) => ({
317
+ uri: null,
318
+ timestamp: performance.timeOrigin + ev.timeStamp,
319
+ }),
314
320
  end: (ev) => null,
315
321
  error: (ev) => ({
316
322
  // TODO: add "phrases-not-supported" support to the type
@@ -76,6 +76,7 @@ const WebListenerTransformers: {
76
76
  listener.call(instance, {
77
77
  ...createEventData(instance),
78
78
  uri: nativeEvent.uri,
79
+ timestamp: nativeEvent.timestamp,
79
80
  });
80
81
  },
81
82
  };
@@ -87,6 +88,7 @@ const WebListenerTransformers: {
87
88
  listener.call(instance, {
88
89
  ...createEventData(instance),
89
90
  uri: nativeEvent.uri,
91
+ timestamp: nativeEvent.timestamp,
90
92
  });
91
93
  },
92
94
  };