ferrari13
ferrari13

Reputation: 91

Android text to speech in different languages

I want to make an application that can support different languages.

There is no problem with the "default" languages:

tts.setLanguage(Locale.ENGLISH);

And also some other:

Locale l = new Locale("ru","RU");
tts.setLanguage(l);

But a lot of others don't work, eg.:

Locale l = new Locale("hu","HU");
tts.setLanguage(l);

I have also tried "hu", "hu-HU", "hu-rHU", "HU"... but nothing...

Also, it doesn't work with Turkish, Greek, Dutch, Czech...

Upvotes: 9

Views: 7287

Answers (4)

Samir Alakbarov
Samir Alakbarov

Reputation: 1145

You must use ISO 639 alpha-2 or alpha-3 code for first parameter. It is "rus" for Russian language. And ISO 3166 alpha-2 for second parameter. It is correct ("RU").

Here is list of ISO country codes:

ISO 639

ISO 3166

Upvotes: 0

zaaachos
zaaachos

Reputation: 11

You have to change your phone's system language to Greek, Turkish, Dutch or whatever language you want, in order the Locale, take your Default Locale Language. I wrote println in order to check if the program takes your system language right

println(Locale.getDefault().country)
tts!!.setLanguage(Locale.getDefault())

Upvotes: 0

Bay
Bay

Reputation: 497

When you type Locale. the dropdown list opens, and available languages are listed as below:

  1. Korean
  2. Italian
  3. German
  4. Japanese
  5. French
  6. English
  7. Canada_French
  8. Chinese
  9. Simplified_Chinese
  10. Taiwan
  11. Traditional Chinese
  12. UK
  13. US

There is no Hungarian (Magyarul), Turkish (Türkçe) available at this time.

enter image description here

Upvotes: 1

marcinj
marcinj

Reputation: 50036

Not all are supported, use: Locale.getAvailableLocales() to get available possible locales and test them against isLanguageAvailable, or since api21 you can use getAvailableLanguages() to directly get available languages for current TTS engine. You can install alternative TTS engine, ie. SVOX is quite good.

Upvotes: 6

Related Questions