cordova-plugin-speechrecognition
cordova-plugin-speechrecognition copied to clipboard
Volume of TTS decreases after recognition on IOS
I'm developing chatbot with Ionic.
We need a property in this plugin which automatically stops recognition after speech end like Android. And a solution for realtime text displays of recognition on iOS.
The problem: After recognition I send the text to the server and get response audio file from server. I play this audio file, but the volume decreases. And when using headset the volume play on the speaker of phone by default.
Same issue confirmed
I faced the same issue and fixed it by changing thee lines of "SpeechRecognition.m" file
First of all as I see, the problem was fixed in new version of plugin (v1.2.0). In my case Im using cordova-plugin-speechrecognition 1.1.2 "Speech Recognition" so I changed these lines:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[audioSession setMode:AVAudioSessionModeMeasurement error:nil];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
To
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
[audioSession setMode:AVAudioSessionModeDefault error:nil];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
I am using v1.2.0 but some of my Testers are getting the issue on iOS 13+.