Code example for TextToSpeech

Methods: isLanguageAvailable, setLanguage

0
        Log.i(TAG, "onInit(" + status + ")");
 
        if (status == TextToSpeech.SUCCESS) {
            Log.i(TAG, "TextToSpeech successfully loaded");
 
            if (mTts.isLanguageAvailable(Locale.US) == TextToSpeech.LANG_AVAILABLE) {
                mTts.setLanguage(Locale.US);
            } else Log.e(TAG, "Locale.US is unavailable");
 
        } else Log.e(TAG, "TextToSpeech engine failed to load");
    } 
 
    public void showOcrDialog(String string) {
        Log.i(TAG, "showOcrDialog(\"" + string + "\")");
 
        ocrResult = string;
 
        mBuilder.setMessage(ocrResult);
        AlertDialog dialog = mBuilder.create();
        dialog.show();
    }