speech_recognition
speech_recognition copied to clipboard
Send error code to errorHandler
Improve error handling by exposing error code of failure to the consumer (developer). With this change it's finally possible to handle different kind of errors differently - we can distinguish whenever speech recognition failed due to timeout or some permission issue.
Official list of error codes can be found here:
- https://developer.android.com/reference/android/speech/SpeechRecognizer.html#ERROR_AUDIO (all are mapped to enums)
import 'package:speech_recognition/speech_recognition.dart';
_speech = SpeechRecognition();
_speech.setErrorHandler((error) {
if (error == SpeechRecognitionError.busy) {
print("Recognizer is really busy");
} else {
print("Recognizer is not busy, but still not working");
}
});
This would be great!