Java – missing language in TTS Android
•
Java
I am developing an Android application that uses the texttospeech feature provided by Google and follow the following example:
TTS Example from Google
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 should I do if there is a lack of language data on the user's device? If the data does not exist, the application cannot continue? Is there any way to allow users to access languages on their devices? I have a test device that doesn't seem to have any language at all
Solution
From http://developer.android.com/resources/articles/tts.html Start:
// missing data,install it Intent installIntent = new Intent(); installIntent.setAction( TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent);
There is no good way to know exactly what will happen if the language they want doesn't exist at all, but This is the recommended way to deal with it
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码