csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
351 stars 218 forks source link

Need a getter when speech to text is recognizing #58

Closed iampopal closed 3 years ago

iampopal commented 4 years ago

Like Speech.recognizing

Retuen true, if app is bussy recognizing the text

And retuen false when recognizing done or when give result.

This mostly happen when user have low internet

Or

When user start listening and not say anything and cancel it.

Then no result is retuen and neither state is notified.

sowens-csd commented 4 years ago

I think the isListening getter satisfies this need?

iampopal commented 4 years ago

isListening is true when we call listen(). isListening is false wen we call stop()

But mostly times when user have low internet connection: The isListening is false and and when i call listen() again

I get that error_busy - true

iampopal commented 4 years ago

If you test one more behavior

When user not say anything between listen() and stop()

The listening is still false

And get error_busy - true

iampopal commented 4 years ago

Or IsRecognizing shall be true until second bep of android.

When speech is recognized that android second beep gets call.

sowens-csd commented 4 years ago

There are two options to detect whether the user is speaking. Partial results in the onResult callback and the onSoundLevelChange callback. Other than that I don't have other information about whether the user is speaking or not so I don't think I can provide a new state variable.

The next version fixes the error_busy issue. It's happening because you can't call listen while a listen session is ongoing. The next version will ignore calls to listen while it is already listening.

iampopal commented 4 years ago

And when I call cancel, isListening return false and when I listen again I get error_busy - true

sowens-csd commented 4 years ago

Can you reproduce that problem in the example app? I was just testing the cancel / listen behaviour on Android this morning and it seemed to be working correctly. Do you get the same behaviour on all devices or is there a particular OS / Device that shows that behaviour?

iampopal commented 4 years ago

I use android 10, and the same problem happens in some other android phones of testers too. You can reproduce this error by disconnecting from the internet and start listening and not say anything and cancel and listen again. on the android phone.

sowens-csd commented 4 years ago

Thanks for the steps to reproduce. I'll try that sequence.

sowens-csd commented 4 years ago

I just tried this on a device with the wifi disabled and wasn't able to reproduce a problem. I modified the example app so I could see the listening state. Unfortunately I'm not fast enough to cancel manually before the error appears, I modified the code to cancel as soon as it starts listening but didn't reproduce the problem. I modified the example app so I could see the listening state in each callback, here's the changed version:

    print("Received error status: $error, listening: ${speech.isListening}");
    setState(() {
      lastError = "${error.errorMsg} - ${error.permanent}";
    });
  }

  void statusListener(String status) {
    print(
        "Received listener status: $status, listening: ${speech.isListening}");
    setState(() {
      lastStatus = "$status";
    });
  }

Maybe the issue is with the way I'm testing it. How are you creating the low / no Internet scenario?

danillus commented 4 years ago

I have the same problem when user have low internet connection, it would be interesting to have a recognizing status. When user say anything between listen() and stop(), the following statuses occur:

I/flutter (16198): status: listening
I/flutter (16198): status: notListening
I/flutter (16198): status: notListening
I/flutter (16198): result: 0.9451897 test

When the user says anything between listening() and stop() and an error occurs:

I/flutter (16198): status: listening
I/flutter (16198): status: notListening
I/flutter (16198): error: SpeechRecognitionError msg: error_no_match, permanent: true

When user NOT say anything between listen() and stop(), the following statuses occur:

I/flutter (16198): status: listening
I/flutter (16198): status: notListening

Notice that there is no pattern, why not show the second notListening when user NOT say anything?

The second notListening could not be the recognizing status?

sowens-csd commented 4 years ago

Can you define 'low internet connection'? I've had a couple of reports of problems under poor connectivity but I can't reproduce them. Can you reproduce this behaviour? If so, how do you test it?

sowens-csd commented 3 years ago

Closing this because I don't have enough information to reproduce.