Android TTS says 0 as "o"

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; // speak something using google TTS Bundle lParams = new Bundle(); lParams.putInt(TextToSpeech.Engine.KEY_PARAM_STREAM, Constants.TTS_AUDIO_STREAM); mTTS.speak(finalString, TextToSpeech.QUEUE_FLUSH, lParams, ""); 

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); // speak something using google TTS Bundle lParams = new Bundle(); lParams.putInt(TextToSpeech.Engine.KEY_PARAM_STREAM, Constants.TTS_AUDIO_STREAM); mTTS.speak(lSpannedMsg, TextToSpeech.QUEUE_FLUSH, lParams, ""); 

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.

+5
source share

Source: https://habr.com/ru/post/1234624/


All Articles