csdcorp / speech_to_text

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

Fails to function with car's Bluetooth connection #508

Open uphoon opened 2 weeks ago

uphoon commented 2 weeks ago

Hello, I have identified a bug through several tests and am registering it here. The app does not function when the car's Bluetooth is connected. Below are a few cases I tested for your reference.

Case 1:

Case 2:

Case 3:

In summary, the Speech-to-Text app functions correctly either when the access permission for nearby devices is denied or when the phone feature in the Bluetooth settings is turned off. However, it seems that listening does not work when both are applied. Thank you for your attention to this matter. I hope this can be fixed soon. I always appreciate the functionality of this product.

https://github.com/csdcorp/speech_to_text/assets/3182587/4558b53f-5eec-4660-8f24-1afc39cf1a0d

sowens-csd commented 2 weeks ago

Interesting. I haven’t tried this case. I’ll try it out. It will be a few weeks before I can look at it.

uphoon commented 1 week ago

Hello, I have experienced issues with microphone recognition via car Bluetooth. I have conducted further tests. First, take a look at the code below:


...

  void listening() async {
    _available = await speech.initialize(
      onError: (error) {
        print(error.errorMsg);
      },
      onStatus: (status) async {
        if (status == "notListening") {
          // No action taken when not listening
        } else if (status == "done") {
          await speech.stop();
          setState(() {
            isListening = false;
            listening();  // <<< Microphone recognition works from the second call onwards
          });
        }
      },
    );

    if (_available) {
      await speech.listen(
        onResult: (result) {
          // Code continues below
      ... 
  }

To provide more detail, when the app is first launched, the microphone is activated for the first time, recognizes the speech correctly, and returns accurate results. However, from the second attempt onwards, the microphone fails to recognize any speech.

I tested using a recursive function as shown in the code above, and from the second call to the listening() function, the microphone was recognized correctly.

I believe this is not the correct way to handle this situation, but I hope this information helps in resolving the bug.

Have a great day.