flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

I'm not able to trigger the setProgressHandler()

Open joervargas opened this issue 4 years ago • 6 comments

Great work on the plugin! I'm a little lost as to how to trigger the setProgressHandler though. Any help or information would be appreciated.

On my setup I'm using a shared flutter_tts Provider so that I only have 1 set of speech being triggered at a time. I've created functions in my Provider class to handle speech as follows~

` Future prgSpeak({String vocab, Function completionHandler, Function progressHandler}) async {

flutterTts = FlutterTts();
flutterTts.setCompletionHandler(() {
  setStop();
  completionHandler();
});
flutterTts.setProgressHandler((String words, int start, int end, String word) {
  progressHandler(words, start, end, word);
});
flutterTts.setErrorHandler((msg) {
  setStop();
  print("TTS Error!");
  print(msg);
});
await flutterTts.setVolume(volume);
await flutterTts.setPitch(pitch);
await flutterTts.setSpeechRate(rate);
setStart();
await flutterTts.speak(vocab);

}`

On my widgets I call this function through ~

await Provider.of<TTSProvider>(context, listen: false).prgSpeak(vocab: targetLanguage progressHandler: (String words, int start, int end, String word) { print("Progress Handler triggered"); print('PROGRESS: $word => $start - $end'); });

joervargas avatar May 21 '20 09:05 joervargas

@joervargas did you find the way? I have the same problem..

radoslaw-sz avatar Jan 28 '21 16:01 radoslaw-sz

Same issue on EMUI10(huawei) devices!

Ricardoi1 avatar Oct 13 '22 06:10 Ricardoi1

image I found the reason, only sdk version below 26 can get progressHandler working

Ricardoi1 avatar Oct 13 '22 07:10 Ricardoi1

same issue on Oneplus 8t (Colos OS 13 /Android 13). onProgress will not triggered when speak.

fan123199 avatar Feb 17 '23 10:02 fan123199

@fan123199 @Ricardoi1 sorry I've been extremely busy, but I'll try to carve out some time soon to fix this. Thanks for pointing out the issue @Ricardoi1 .

dlutton avatar Feb 22 '23 21:02 dlutton

Hello, I have found progress issues on both Android 9 and Win11 devices. I hope you can handle them as soon as possible. Thank you

anonymouszbs avatar Apr 23 '23 15:04 anonymouszbs