flutter_tts
flutter_tts copied to clipboard
[Android] Number being read individually instead of as one
🐛 Bug Report
I'm passing a string like so "1 5 15"
to the tts.speak(). On android it is being read as "One Five One Five".
Expected behavior
It should be read as "One Five Fifteen". That's the behavior on iOS and web. If we pass "15" by itself it is read as expected on android.
Reproduction steps
await _flutterTts.speak("1 5 15");
Configuration
Version: 1.2.0
Platform:
- [ ] :iphone: iOS
- [x] :robot: Android
@AkshatGiri Which Android API and device/emulator are you using?
@dlutton I'm running on Android 10 on a Pixel 2 XL.
I am able to reproduce this issue, however I'm not able to locate a reason for the google TTS engine to behave this way. You may want to separate the number values by commas until I'm able to locate both the reason for this and possible solution.
I had done something like this in case someone else faces the same issue
final numToWord = {
"0": "Zero",
"1": "One",
"2": "Two",
"3": "Three",
"4": "Four",
"5": "Five",
"6": "Six",
"7": "Seven",
"8": "Eight",
"9": "Nine",
};
Future sayNum(int val) async {
final valString = val.toString();
if (valString.length == 1) {
return await _flutterTts.speak("Single number $valString");
}
final splitVal = valString.split("");
return await _flutterTts.speak(
"${numToWord[splitVal[0]]} ${numToWord[splitVal[1]]} $valString");
}