is Language Available TextToSpeech - Android android.speech.tts

Android examples for android.speech.tts:TextToSpeech

Description

is Language Available TextToSpeech

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;
import android.speech.tts.TextToSpeech;
import java.util.Locale;

public class Main {
    public static Boolean isLanguageAvailable(Context context,
            TextToSpeech tts, Locale localeTTs) {
        Boolean available = false;
        switch (tts.isLanguageAvailable(localeTTs)) {
        case TextToSpeech.LANG_AVAILABLE:
        case TextToSpeech.LANG_COUNTRY_AVAILABLE:
        case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
            //Log.d(TAG, "SUPPORTED");
            available = true;//  w w  w . j a  va2  s. c om
            break;
        case TextToSpeech.LANG_MISSING_DATA:
            //Log.d(TAG, "MISSING_DATA");
            //Log.d(TAG, "require data...");
            Intent installIntent = new Intent();
            installIntent
                    .setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            context.startActivity(installIntent);
            available = true;
            break;
        case TextToSpeech.LANG_NOT_SUPPORTED:
            //Log.d(TAG, "NOT SUPPORTED");
            available = false;
            break;
        }

        return available;
    }
}

Related Tutorials