expo-speech-recognition 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # expo-speech-recognition
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 86b0b5b: Fixed an Android unhandled `ArrayIndexOutOfBoundsException` crash when the audio recording fails.
8
+
9
+ This may happen when [`audioRecorder.read()`](<https://developer.android.com/reference/android/media/AudioRecord#read(short[],%20int,%20int,%20int)>) returns [`ERROR_INVALID_OPERATION`](https://developer.android.com/reference/android/media/AudioRecord#ERROR_INVALID_OPERATION), [`ERROR_BAD_VALUE`](https://developer.android.com/reference/android/media/AudioRecord#ERROR_BAD_VALUE), [`ERROR_DEAD_OBJECT`](https://developer.android.com/reference/android/media/AudioRecord#ERROR_DEAD_OBJECT), or the more generic [`ERROR`](https://developer.android.com/reference/android/media/AudioRecord#ERROR)
10
+
3
11
  ## 2.1.2
4
12
 
5
13
  ### Patch Changes
@@ -198,18 +198,20 @@ class ExpoAudioRecorder(
198
198
 
199
199
  while (isRecordingAudio) {
200
200
  val read = audioRecorder!!.read(data, 0, data.size)
201
- try {
202
- outputStream?.write(data, 0, read)
203
- outputStream?.flush()
204
-
205
- // Write to the temp PCM file
206
- if (outputFilePath != null) {
207
- tempFileOutputStream.write(data, 0, read)
208
- tempFileOutputStream.flush()
201
+ if (read > 0) {
202
+ try {
203
+ outputStream?.write(data, 0, read)
204
+ outputStream?.flush()
205
+
206
+ // Write to the temp PCM file
207
+ if (outputFilePath != null) {
208
+ tempFileOutputStream.write(data, 0, read)
209
+ tempFileOutputStream.flush()
210
+ }
211
+ } catch (e: IOException) {
212
+ Log.e(TAG, "Failed to write to output stream", e)
213
+ e.printStackTrace()
209
214
  }
210
- } catch (e: IOException) {
211
- Log.e(TAG, "Failed to write to output stream", e)
212
- e.printStackTrace()
213
215
  }
214
216
  }
215
217
  tempFileOutputStream.close()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-speech-recognition",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Speech Recognition for React Native Expo projects",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",