expo-speech-recognition 3.1.1 → 3.1.2
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 +8 -0
- package/ios/ExpoSpeechRecognizer.swift +14 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# expo-speech-recognition
|
|
2
2
|
|
|
3
|
+
## 3.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5f3bd93: Avoid restarting the iOS audio engine during audio route changes while the app
|
|
8
|
+
is leaving the foreground, which could still crash some speech-recognition
|
|
9
|
+
sessions after the 3.1.1 input-node readiness fix.
|
|
10
|
+
|
|
3
11
|
## 3.1.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -2,6 +2,7 @@ import AVFoundation
|
|
|
2
2
|
import Accelerate
|
|
3
3
|
import Foundation
|
|
4
4
|
import Speech
|
|
5
|
+
import UIKit
|
|
5
6
|
|
|
6
7
|
enum RecognizerError: Error {
|
|
7
8
|
case nilRecognizer
|
|
@@ -744,19 +745,30 @@ actor ExpoSpeechRecognizer: ObservableObject {
|
|
|
744
745
|
object: AVAudioSession.sharedInstance(),
|
|
745
746
|
queue: .main
|
|
746
747
|
) { [weak self] _ in
|
|
748
|
+
let appState = UIApplication.shared.applicationState
|
|
747
749
|
Task { [weak self] in
|
|
748
750
|
let taskState = await self?.task?.state
|
|
749
|
-
await self?.handleAudioRouteChange(taskState: taskState)
|
|
751
|
+
await self?.handleAudioRouteChange(taskState: taskState, appState: appState)
|
|
750
752
|
}
|
|
751
753
|
}
|
|
752
754
|
|
|
753
755
|
}
|
|
754
756
|
|
|
755
757
|
private func handleAudioRouteChange(
|
|
756
|
-
taskState: SFSpeechRecognitionTaskState
|
|
758
|
+
taskState: SFSpeechRecognitionTaskState?,
|
|
759
|
+
appState: UIApplication.State
|
|
757
760
|
) {
|
|
758
761
|
// We only care about route changes when the recognizer is active
|
|
759
762
|
if taskState == .running || taskState == .starting {
|
|
763
|
+
// App deactivation can emit a route change while the audio session is
|
|
764
|
+
// being torn down. In that case we should stop recognition instead of
|
|
765
|
+
// trying to reconnect the engine again.
|
|
766
|
+
guard appState == .active else {
|
|
767
|
+
emitError(.audioSessionInterrupted)
|
|
768
|
+
stopListening()
|
|
769
|
+
reset(andEmitEnd: true)
|
|
770
|
+
return
|
|
771
|
+
}
|
|
760
772
|
guard !restartAudioEngineForRouteChange() else {
|
|
761
773
|
return
|
|
762
774
|
}
|