Global TTS in Android

后端 未结 3 1399
春和景丽
春和景丽 2021-01-21 04:31

Hi I am devloping an application for blind users so that I use very often text to speech as practicaly the only one method how to respond on user actions. I decided to make one

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 05:22

    Here's some answers by gregm again to similar questions:

    TTS - CHECK_VOICE_DATA_FAIL - Check engine availlable or

    Why is the ACTION_CHECK_TTS_DATA Intent "awkward to use"?

    that also recommend just using TextToSpeech.isLanguageAvailable() instead of ACTION_CHECK_TTS_DATA, along with a pointer to a helper class.

    I've tested this on some android 4.1.2 phones with Locale.US, and it activates the TTS engine fine, and plays nicely with 3rd party engines. When testing on an old android 1.6 phone (G1), looks like the stock TTS engine is not installed (LANG_MISSING_DATA). The following code in that case will redirect to the store to install:

    Intent installIntent = new Intent();
    installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
    startActivity(installIntent);
    

    After which, using the tts engine within the app works fine. Basically, the old blog post from the android guys is a bit overkill and dated, as it does not play nicely with Android 4.x in my experience (ANDROID_CHECK_TTS_DATA always returned CHECK_VOICE_DATA_MISSING_DATA on me in Android 4.x).

提交回复
热议问题