speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

Not getting text in recognitionResultHandler function

Open devs4522 opened this issue 6 years ago • 3 comments

//Here I am not getting text (audio which i speaks converted into text) in result. But platform //handler shows below message in console
_platformCallHandler call speech.onRecognitionComplete hello

//My result handler function is here. _speech.setRecognitionResultHandler((String result) { setState(() { transcription = result; stop(); }); } );

devs4522 avatar Feb 19 '20 09:02 devs4522

I'm having same issue.

Note that, in dart raw file, the arguments of transcription are only sent to recognitionResultHandler() on onSpeech, not on onComplete:


Future _platformCallHandler(MethodCall call) async {
    print("_platformCallHandler call ${call.method} ${call.arguments}");
    switch (call.method) {
      case "speech.onSpeechAvailability":
        availabilityHandler(call.arguments);
        break;
      case "speech.onCurrentLocale":
        currentLocaleHandler(call.arguments);
        break;
      case "speech.onSpeech":
        recognitionResultHandler(call.arguments);
        break;
      case "speech.onRecognitionStarted":
        recognitionStartedHandler();
        break;
      case "speech.onRecognitionComplete":
        recognitionCompleteHandler();
        break;
      default:
        print('Unknowm method ${call.method} ');
    }
  }

So we lose this trigger after "endOfSpeech" callback. I'm trying to bypass it, but i can't find out.

On this way i'm always losing last words of the recognition on the transcription state.

viniciuspaludo avatar Apr 14 '20 04:04 viniciuspaludo

I have the same problems. I solved one of them by changing the type for "recognitionCompleteHandler" from "VoidCallback" to "StringResultHandler" and sending the parameter in recognitionCompleteHandler(call.arguments) in dart raw file.

I think this PR solves the other problem: https://github.com/rxlabz/speech_recognition/pull/89

rodolZ80 avatar Apr 14 '20 06:04 rodolZ80

That's good rodolZ80 Works fine here. :)

What i did, and also works, is add a call to recognitionResultHandler(call.arguments); inside recognitionCompleteHandler in dart raw file

So it triggers ResultHandler after recognition is complete, too.

viniciuspaludo avatar Apr 16 '20 14:04 viniciuspaludo