Missing languages in TTS android

早过忘川 提交于 2019-11-30 04:02:11

问题


I am working on an android application that uses the TextToSpeech functionality provided by google and have followed this example:

TTS Example from Google

I want to know with 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 can I do if the Language data is missing off the users device? The app will not continue if the data is not there? Is there a way to allow the user to get the language on their device? I have a test device that seems to not have any languages on it at all.


回答1:


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);

No good way to know exactly what happens if the language they want simply doesn't exist at all, but....that is the recommended way of dealing with it.



来源:https://stackoverflow.com/questions/5913188/missing-languages-in-tts-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!