dlutton / flutter_tts

Flutter Text to Speech package
MIT License
583 stars 242 forks source link

setProgressHandler stop if sentence contains dot + space #228

Open MapleNoise opened 3 years ago

MapleNoise commented 3 years ago

πŸ› Bug Report

On Android (not test in iOS) when speak my sentence which contains ".", "!" or "?" followed by space char or \n. The setProgressHandler stop listening after this chars...

Reproduction steps

flutterTts = FlutterTts();

flutterTts.setProgressHandler((text, start, end, word) {
      print("TEXT HANDLED = " + word);
});

String mText = "This is my sentence. The progress handler stopped! ";

flutterTts.speak(mText)

My log :

TEXT HANDLED = This
TEXT HANDLED = is
TEXT HANDLED = my
TEXT HANDLED = sentence

For the moment, I fixed the problem with a Regex : flutterTts.speak(mText.replaceAll(RegExp(r'\.\s|\!\s|\?\s'), ".")) for replace ". ", "! " or "? " by "." and setProgressHandler works fine...

Same bug here ? Thanks !

Configuration

[βœ“] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale fr-FR) [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [βœ“] Xcode - develop for iOS and macOS [βœ“] Chrome - develop for the web [βœ“] Android Studio (version 4.1) [βœ“] Connected device (2 available)

dlutton commented 3 years ago

@MapleNoise I tested this on both iOS and Android. I'm not able to recreate this issue on either emulator. Can you run the example provided here https://gist.github.com/dlutton/30b065449cb2eb941dfd6bef86aeefaf with your sentence?

MapleNoise commented 3 years ago

Thanks for your reply,

Same problem with your exemple and all languages.

Video here : https://user-images.githubusercontent.com/1905622/117425523-238b9b00-af23-11eb-9b46-dc004df8bebd.mp4

dlutton commented 3 years ago

https://user-images.githubusercontent.com/14303235/117734823-17187400-b1a9-11eb-8ebb-8d7ad91fc51c.mp4

Unfortunately I'm not able to recreate the issue. I have attached a video showing the progress handler working with the example I linked and the text you used.

Doctor summary (to see all details, run flutter doctor -v): [βœ“] Flutter (Channel stable, 2.0.6, on macOS 11.3.1 20E241 darwin-x64, locale en-US) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

MapleNoise commented 3 years ago

I'll investigate, and get back to you if I find anything. It happened after the switch to Flutter 2. Maybe because I didn't activate the null-safety?

I'll let you know

uc-dve commented 3 years ago

@MapleNoise I tested this on both iOS and Android. I'm not able to recreate this issue on either emulator. Can you run the example provided here https://gist.github.com/dlutton/30b065449cb2eb941dfd6bef86aeefaf with your sentence?

I am facing the same issue in android devices, working fine on ios devices and simulators. i have used flutterTts.speak(mText.replaceAll(RegExp(r'.\s|!\s|\?\s'), ".")) it is working but still breaking somewhere.

I am using => 
flutter - 2.0.3 with null-safety
flutter_tts - 3.1.0
uc-dve commented 3 years ago

I have used this Regex and it solves the issue. testString.replaceAll(RegExp(r'\.\s+|\?\s+|\!\s+'), ".") But I am not sure how many special characters with space can break.

dlutton commented 3 years ago

@uc-dve can you provide the exact text that is causing this to fail for you? So far I've been unable to replicate the issue, but would like to if it's happening with multiple people.

uc-dve commented 3 years ago

below is the text. Reading is fine but the issue is, but the issue is flutterTts.setProgressHandler stops returning data.

Information Technology (IT). Information Technology (IT) refers to all aspects of managing and processing information using computers and computer networks. Because computers are vital to information management in all organizations and companies, most organizations have dedicated computer personnel referred to as IT departments. IT departments generally deal with computer, telecommunications, network and other related technologies and services to provide employees with the resources necessary to reach their organizations' goals. Information Technology is one of the fastest-growing career fields in the world today. IT skills are essential in all industries and are necessary in many different job roles. Introduction to IT Business and Careers.

androsoftweb commented 3 years ago

Hi, I am facing this issue too, and I think the problem is pause tts takes when there is ". ". so, my guess is when tts pause or stop it resets its progresshandler and the above problem generated.

dlutton commented 3 years ago

@androsoftweb can you provide your flutter config via the flutter doctor command? I'm still not able to reproduce the issue.

androsoftweb commented 3 years ago

I temporarily used the solution which is mentioned by @uc-dve . and you can reproduce it very easily just follow these steps. in your test example, you let tts speech what is entered by the user right? now, rather than that change that to a static string like this: "Hello, this is the message. Now on handler will not get an update." and execute that tts will read whole string with pause at "." but after pausing progresshandler function will not execute further on.

dlutton commented 3 years ago

@androsoftweb I provided a video above showing the progress handler working fine with a period in the text.

baranidharanofficial commented 2 years ago

Actually this error occurs after 2 sentences with a space. For Example : I am a man. I am a women. (IT BREAKS HERE) I am god.

dlutton commented 2 years ago

@Stark958 thank you for the clarification, did you mean 2 sentences with a period or space?