Missing Languages ​​in TTS Android

I am working on an android application that uses the TextToSpeech functions provided by google and follows this example:

Google TTS Example

I want to know this line:

int result = mTts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { // Lanuage data is missing or the language is not supported. } 

What if language data is not available from the user device? The application will not continue if there is no data? Is there a way to let the user get the language on their device? I have a test device that doesn't seem to contain any languages ​​at all.

+6
source share
1 answer

From http://developer.android.com/resources/articles/tts.html :

 // missing data, install it Intent installIntent = new Intent(); installIntent.setAction( TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); 

There is no good way to find out what happens if the language they want simply does not exist at all, but ... this is the recommended way to deal with it.

+10
source

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


All Articles