Global TTS in Android

后端 未结 3 1437
春和景丽
春和景丽 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:19

    You don't need to use the ACTION_CHECK_TTS_DATA. Instead use isLanguageAvailable like this: (make sure to call this only after onInit is complete)

        // check if language is available
        switch (tts.isLanguageAvailable(locale))
        {
            case TextToSpeech.LANG_AVAILABLE:
            case TextToSpeech.LANG_COUNTRY_AVAILABLE:
            case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
                Log.d(TAG, "SUPPORTED");
                break;
            case TextToSpeech.LANG_MISSING_DATA:
                Log.d(TAG, "MISSING_DATA");//launch the install data activity
                break;
            case TextToSpeech.LANG_NOT_SUPPORTED:
                Log.d(TAG, "NOT SUPPORTED");//report failure
                break;
        }
    

提交回复
热议问题