Code example for TextToSpeech

Methods: setLanguage

0
 
    // Implements TextToSpeech.OnInitListener. 
    public void onInit(int status) {
        // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. 
        if (status == TextToSpeech.SUCCESS) {
            int result = mTts.setLanguage(Locale.US);
            if (result == TextToSpeech.LANG_MISSING_DATA ||
                result == TextToSpeech.LANG_NOT_SUPPORTED) {
               // Language data is missing or the language is not supported. 
                Log.e(TAG, "Language is not available.");
            } else { 
                Log.i(TAG, "TextToSpeech Initialized.");
                mSpeakingEngineAvailable = true;
            } 
        } else { 
            // Initialization failed. 
            Log.e(TAG, "Could not initialize TextToSpeech.");
        } 
    } 
 
Connect your IDE to all the code out there  Get Codota for Java