When using Android TextToSpeech for conversations with numbers, Android says 0 (zero) as โaboutโ, not โzeroโ. All other numbers say as expected.
I tried a couple of different ways to talk, they all lead to this problem. First, I tried in the usual way:
mTTS = new TextToSpeech(mContext, this); String text= "this is a test"; String digits= "0 0 0 1"; String finalString= text+digits;
I also tried digits as "0001" (no spaces). Both ended the conversation as "this is a test, oh, oh, oh, one." Then I tried using TtsSpans:
mTTS = new TextToSpeech(mContext, this); String text= "this is a test"; String digits= "0 0 0 1"; String finalString= text+digits; Spannable lSpannedMsg = new SpannableString( finalString ); TtsSpan lSpan = new TtsSpan.DigitsBuilder(digits).build(); TtsSpan lSpanText = new TtsSpan.TextBuilder(text).build(); lSpannedMsg.setSpan(lSpan, finalString.indexOf(digits), finalString.indexOf(digits) + digits.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); lSpannedMsg.setSpan(lSpanText, finalString.indexOf(text), finalString.indexOf(text) + text.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Even with the string pulled, the engine still said, "this is a test, oh, oh, oh, one." Is there a way to get Google to say 0 as "zero"? I would like not to examine the string sent and replacing 0 with "zero", as this will cause problems with other languages.
source share