speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

Send error code to errorHandler

Open vintage opened this issue 6 years ago • 1 comments

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");
    }
});

vintage avatar May 04 '19 18:05 vintage

This would be great!

wardpenney avatar Jun 07 '19 20:06 wardpenney