Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: PlatformException(recognizerNotAvailable, Speech recognition not available on this device, , null) #279

Closed
thuchau opened this issue Dec 16, 2021 · 5 comments

Comments

@thuchau
Copy link

thuchau commented Dec 16, 2021

Emulator: Pixel XL
API: 30
speech_to_text: ^5.3.0

code init:
bool ready = await _speechToText.initialize(onError: onError, onStatus: onStatus);

void onStatus(String status) { }

void onError(SpeechRecognitionError errorNotification) {}

Exception at this code in lib:
return await _channel.invokeMethod<bool>( 'initialize', params, ) ?? false;

`E/SpeechToTextPlugin( 3342): Speech recognition not available on this device
E/flutter ( 3342): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(recognizerNotAvailable, Speech recognition not available on this device, , null)
E/flutter ( 3342): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter ( 3342): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter ( 3342):
E/flutter ( 3342): #2 MethodChannelSpeechToText.initialize (package:speech_to_text_platform_interface/method_channel_speech_to_text.dart:39:12)
E/flutter ( 3342):
E/flutter ( 3342): #3 SpeechToText.initialize (package:speech_to_text/speech_to_text.dart:238:19)
E/flutter ( 3342):

@dominiqueware34
Copy link

Have you tried on Pixel 4? Check this thread https://stackoverflow.com/questions/5916521/how-can-you-make-the-android-emulator-support-speech-recognition

I believe it has something to do with the emulator needing the google search feature ( i could be wrong)

image

@sowens-csd
Copy link
Contributor

Yes, that's right, you must make sure that the emulator has support. I think the README has some links on how to set that up.

@thuchau
Copy link
Author

thuchau commented Dec 20, 2021

  1. I think this exception occurs on emulators don't support google play. I wonder Speech_To_Text package can return an error, is it better than throw an exception? because I think many developers want to test other functions on these emulators.

  2. "checks if a speech recognizer is available on the device before completing initialize"
    I'm a newbie in flutter, I don't find how a way to check a speech recognizer is available on the device in programming, could you help me?

  3. Another question: I don't find anywhere define about all error message that the package can return. I need it to handle and show message to user, may I have?

@sowens-csd
Copy link
Contributor

  1. You can catch the exception with a try, but yes, I probably will change this to a false response and an error at some point.
  2. I misremembered, I'd thought there was a separate test to see if speech recognition is available but I see that it is embedded as part of the initialize call. In fact it's that test that you're hitting to get the exception you're seeing.
  3. The documentation for the SpeechErrorListener type has the current list of errors. I see that it has gotten slightly out of date so I'll update in an upcoming release.

@thuchau
Copy link
Author

thuchau commented Dec 21, 2021

  1. You can catch the exception with a try, but yes, I probably will change this to a false response and an error at some point.
  2. I misremembered, I'd thought there was a separate test to see if speech recognition is available but I see that it is embedded as part of the initialize call. In fact it's that test that you're hitting to get the exception you're seeing.
  3. The documentation for the SpeechErrorListener type has the current list of errors. I see that it has gotten slightly out of date so I'll update in an upcoming release.

Thank you so much, I got it.

@thuchau thuchau closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants