0

I'm trying to reproduce some text with an android aplication that will help visually impaired people, most especially with TTS, but in my case I need Portuguese-Brazil speaking, and the TTS class does not have Portuguese available as locale. Does anyone have any idea how to implement a Portuguese Brazil reader?

I'm using Android Studio, and MinSDK is 15.

...

tts = new TextToSpeech (this, this);

tts.setLanguage(Locale.[X]);

...

tts.speak("Muito obrigado a todos!", TextToSpeech.QUEUE_FLUSH, null);

...
thor
  • 21,418
  • 31
  • 87
  • 173
EliasFNK
  • 11
  • 2
  • See my answer: http://stackoverflow.com/questions/20527164/setting-application-locale-to-pt-br-programmatically – Phantômaxx Mar 16 '16 at 20:00

2 Answers2

1

How did you make your onInitListener()? When you call tts = new TextToSpeech (this, this); onInitListener() will connect TextToSpeech service to your tts instance. So, if you try to set language or speak sound, check this value:

tts = new TextToSpeech (this, this);

@Override
public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        int res = tts.setLanguage(Locale.[X]);
        if (res >= TextToSpeech.LANG_AVAILABLE) {
            // Then, you can speak with your locale.
            // Call speak() in here or after this method.
            tts.speak("Muito obrigado a todos!", TextToSpeech.QUEUE_FLUSH, null);
        }
    }
}
Kae10
  • 619
  • 2
  • 6
  • 17
0

Solved! My problem was that on the device was not installed TTS. So, just installed it from the google store(https://play.google.com/store/apps/details?id=com.google.android.tts&hl=en).

EliasFNK
  • 11
  • 2