Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
775 views
in Technique[技术] by (71.8m points)

android - Text to Speech Locale Hindi Indian

I've created a Text to Speech Engine for Android that supports many languages, one of which is Hindi.

In the Android Text to Speech Settings, when the user selects a default locale, Android does a number of checks including sending the intent ACTION_GET_SAMPLE_TEXT

Here is my list of supported locales:

private static final String[] SUPPORTED_LANGUAGES = { "eng-GBR", "eng-USA", "fra-FRA", "spa-ESP", "deu-DEU", "ita-ITA",
        "kor-KOR", "nld-NLD", "dan-DNK", "fin-FIN", "jpn-JPN", "nor-NOR", "pol-POL", "por-PRT", "por-BRA", "rus-RUS",
        "swe-SWE", "zho-CHN", "zho-HKG", "zho-TWN", "ara-SAU", "hi-IN", "ces-CZE", "ell-GRC", "hun-HUN", "ron-ROU",
        "slk-SVK", "tha-THA", "tur-TUR", "cym-GBR", "isl-ISL", "in-IDN" };

For every Locale other than "hi-IN", Android sends this intent and I respond with the example text and the "Listen to an example" button becomes available.

I'm successfully returning LANG_COUNTRY_AVAILABLE from the call to onIsLanguageAvailable, but the buttons remain greyed out and it states that the language is not supported.

I've tried so many different ISO combinations of the locale:

hin-IN, hi-IND, ind-HI etc etc etc, but Android doesn't send the Intent, despite it being labelled correctly in the Locale list as Hindi(Indian) or just Hindi.

There are no errors in the logcat to suggest a failed variant match.

There's little point me posting my code, as Android simply doesn't send the Intent for this Locale, so it doesn't get to reach my code....

Any ideas how to correctly handle this locale variant?

EDIT: I've just realised it's also happening for Indonesian (in-IDN)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

TTS uses 3-letter codes* for language and locale. So, based on that language/country code for:

Hindi         hin-IND
Indonesian    ind-IDN

Hope this helps.


*This needs a proper citation from sources: I just made my conclusion based on existing TTS engine implementations.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...