I have an app in Flutter that works on Android and iOS. On iOS everything works perfect. But on Android I'm facing some issues with speech to text...
I'm using this plugin: https://pub.flutter-io.cn/packages/speech_to_text/
My code for Android is:
void startListeningAndroid(BuildContext context) async {
try {
speech.listen(
onResult: (SpeechRecognitionResult result) {
processWords(result, context);
},
listenFor: Duration(seconds: 10),
localeId: _currentLocaleId,
onSoundLevelChange: soundLevelListener,
cancelOnError: false,
partialResults: true,
onDevice: true,
listenMode: ListenMode.dictation,
pauseFor: Duration(seconds: 9),
);
} catch (e) {
print(e.toString());
}
setState(() {});
}
And every 11 seconds I start the listening again with the following code:
if (Platform.isAndroid) {
timerSpeech = Timer.periodic(Duration(seconds: 11), ((Timer t) async {
if (voiceRecognitionActivated) {
startListeningAndroid(context);
}
}));
}
But as soon as I start the lisening I get the following log:
initSpeechState error SpeechRecognitionError msg: error_speech_timeout, permanent: true
initSpeechState error SpeechRecognitionError msg: error_client, permanent: true
The code is the same that was working before, it even doesn't do the 'beep' it did before each time the lisening was working. Is there any change in android policy or in teh pluging version that could cause this issue?
Also in the AndroidManifest.xml in main and debug folder I have:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>