flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

Could there be interference between flutter_tts and plugin speech_to_text ?

Open sylvainjack opened this issue 3 years ago • 6 comments

🐛 Bug Report

I am using the flutter_tts package for a vocabulary app. The student/user can do oral quizzes. He clicks on a "speaker logo", the app says the word (in English or in French) and the student must give the translation. On the "oral test screen", the user has a "speaker icon" to hear the word and a "microphone icon" to give his answer orally. The speaker works with flutter_tts : it pronounces the word. The microphone works with the plugin speech_to_text : I use it to check if the user translated the word properly.

I just tried to click on the "Microphone" before the "flutter.tts" was completely finished pronouncing the word and it prompted the bug, namely, no matter how much you type on the speaker, it never speaks anymore. Hot reload and Hot restart do not change the pb. I have to restart the app completely for "speak" to work again. The code keeps calling my Tts class (I check it with the print), but nothing comes out of the await Flutter.Tts().speak. There must be some kind of conflict : when plugin speech_to_text starts, it must have done something that "blocks" flutter_tts.

What can we do ?

Expected behavior

Reproduction steps

I created a Tts class to handle the speaking :

class Tts {
  static set() async {
    await FlutterTts().setSpeechRate(0.4);
    await FlutterTts().setPitch(1.0);
  }

  static setLanguage({required Language langue}) async {
    langue == Language.english
        ? await FlutterTts().setLanguage("en-GB")
        : await FlutterTts().setLanguage("fr-FR");
  }

  static speak({required String phrase}) async {
    print('Je suis dans speak');
   
    print(phrase);
    await FlutterTts().speak(phrase);
  }
}

Configuration

I check it on an iPhone XS PRO MAX. Version: 0.1.x

Platform:

  • [ X] :iphone: iOS
  • [ ] :robot: Android

sylvainjack avatar Jan 30 '22 14:01 sylvainjack

@sylvainjack sorry for the delay, but I haven't used this with speech_to_text, do you have a small sample app with code where I can play around with it to determine if the issue is on the end of this plugin?

dlutton avatar Mar 03 '22 23:03 dlutton

Oops, no... I am just working on one app, which is quite large... Maybe adding the speech_to_text to the TTS example app ? to see ?

sylvainjack avatar Mar 05 '22 13:03 sylvainjack

@sylvainjack good point, I'll try with the example. Also, were there any logs from the bug you encountered or did it just simply stop speaking?

dlutton avatar Mar 07 '22 19:03 dlutton

No, no logs, it just stopped speaking.

sylvainjack avatar Mar 07 '22 20:03 sylvainjack

Seeing the same issue.

Roshanalexander avatar Jun 28 '22 19:06 Roshanalexander

I have run some more tests concerning the interference between TTS and Speech_to_text : the bug is really systematic : User click on "speaker" to hear the word (with TTS) : it speaks fine... user clicks on "MICROPHONE ICON" (To translate the word he heard, it's a vocabulary app) : if user waits one or two seconds after TTS is finished, everything is fine. If user clicks on MIKE while TTS is speaking or right after TTS finished, then TTS is terminated and will no longer speak. Even a restart won't work, have to recompile the whole app. Have you found any idea why this happened ? TTS seems to interfere with AUDIOPLAYERS package as well... for some reason, AUDIOPLAYERS won't really work when I use TTS. (In my app : I have a sound effect being played when user gets the word right : if he translates right, we hear a sound, if he makes a mistake, we hear a sound). Well, it only works once.

sylvainjack avatar Jul 06 '22 04:07 sylvainjack