Example usage for android.speech.tts TextToSpeech LANG_NOT_SUPPORTED

List of usage examples for android.speech.tts TextToSpeech LANG_NOT_SUPPORTED

Introduction

In this page you can find the example usage for android.speech.tts TextToSpeech LANG_NOT_SUPPORTED.

Prototype

int LANG_NOT_SUPPORTED

To view the source code for android.speech.tts TextToSpeech LANG_NOT_SUPPORTED.

Click Source Link

Document

Denotes the language is not supported.

Usage

From source file:com.altcanvas.twitspeak.TwitSpeakActivity.java

public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        int result = mTts.setLanguage(Locale.US);
        // Try this someday for some interesting results.
        // int result mTts.setLanguage(Locale.FRANCE);
        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e(TAG, "Language is not available.");
        } else {/*from   w  w  w.j a v  a2  s . c  o  m*/
            this.twitter = G.checkTwitterCreds();

            if (twitter == null) {
                startActivityForResult(new Intent(this, TwitterLoginActivity.class), G.REQCODE_TWITTER_LOGIN);
            } else {
                speakTwit();
            }
        }
    } else {
        Log.e(TAG, "TTS init error: " + status);
    }
}

From source file:com.xengar.android.englishverbs.ui.DetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  ww w  . ja  v a 2 s.co m*/
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Bundle bundle = getIntent().getExtras();
    demo = bundle.getBoolean(DEMO_MODE, false);
    verbID = bundle.getLong(VERB_ID, -1);
    String title = bundle.getString(VERB_NAME);
    getSupportActionBar().setTitle(title);

    // Invalidate the options menu, so the "Edit" menu option can be hidden.
    invalidateOptionsMenu();

    //Text
    infinitive = (TextView) findViewById(R.id.infinitive);
    simplePast = (TextView) findViewById(R.id.simple_past);
    pastParticiple = (TextView) findViewById(R.id.past_participle);
    pInfinitive = (TextView) findViewById(R.id.phonetic_infinitive);
    pSimplePast = (TextView) findViewById(R.id.phonetic_simple_past);
    pPastParticiple = (TextView) findViewById(R.id.phonetic_past_participle);
    definition = (TextView) findViewById(R.id.definition);
    translation = (TextView) findViewById(R.id.translation);
    sample1 = (TextView) findViewById(R.id.sample1);
    sample2 = (TextView) findViewById(R.id.sample2);
    sample3 = (TextView) findViewById(R.id.sample3);

    // define click listeners
    LinearLayout header = (LinearLayout) findViewById(R.id.play_infinitive);
    header.setOnClickListener(this);
    header = (LinearLayout) findViewById(R.id.play_simple_past);
    header.setOnClickListener(this);
    header = (LinearLayout) findViewById(R.id.play_past_participle);
    header.setOnClickListener(this);

    // initialize Speaker
    tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if (status == TextToSpeech.SUCCESS) {
                int result = tts.setLanguage(Locale.US);
                if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                    if (LOG) {
                        Log.e("TTS", "This Language is not supported");
                    }
                }
            } else {
                if (LOG) {
                    Log.e("TTS", "Initilization Failed!");
                }
            }
        }
    });

    // Initialize a loader to read the verb data from the database and display it
    getLoaderManager().initLoader(EXISTING_VERB_LOADER, null, this);
    showFavoriteButtons();

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    ActivityUtils.firebaseAnalyticsLogEventSelectContent(mFirebaseAnalytics, PAGE_VERB_DETAILS,
            PAGE_VERB_DETAILS, TYPE_PAGE);

    // create AdMob banner
    listener = new LogAdListener(mFirebaseAnalytics, DETAILS_ACTIVITY);
    mAdView = ActivityUtils.createAdMobBanner(this, listener);

    if (demo) {
        defineDemoMode();
    }
}

From source file:com.nbplus.vbroadlistener.BaseActivity.java

@Override
public void onInit(int status) {
    Log.d(TAG, "> TTS onInit()");

    LauncherSettings.getInstance(this).setIsCheckedTTSEngine(true);
    if (status != TextToSpeech.SUCCESS) {
        Log.e(TAG, String.format("TextToSpeechManager.onInit(%d) fail!", status));
        Log.d(TAG, "   ??.... ? ??...");
        if (mcheckText2SpeechLister != null) {
            mcheckText2SpeechLister.onCheckResult(null);
            mText2Speech.shutdown();/*from ww  w.ja v a  2  s .  c om*/
            mText2Speech = null;
        }
        showText2SpeechAlertDialog();
    } else {
        int result = mText2Speech.setLanguage(Locale.KOREA);
        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e(TAG, String.format("TextToSpeech.setLanguage(%s) fail!", Locale.KOREA.getDisplayName()));
            Log.d(TAG, "   ??.... ? ??...");
            if (mcheckText2SpeechLister != null) {
                mcheckText2SpeechLister.onCheckResult(null);
                mText2Speech.shutdown();
                mText2Speech = null;
            }
            showText2SpeechAlertDialog();
        } else {
            if (mcheckText2SpeechLister != null) {
                mcheckText2SpeechLister.onCheckResult(mText2Speech);

            } else {
                if (mcheckText2SpeechLister != null) {
                    mcheckText2SpeechLister.onCheckResult(null);
                    mText2Speech.shutdown();
                    mText2Speech = null;
                }
            }
        }
    }
}

From source file:com.example.h156252.connected_cars.CarGrid.java

@Override
public void onInit(int status) {

    if (status == TextToSpeech.SUCCESS) {

        int result = tts.setLanguage(Locale.US);

        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e("TTS", "This Language is not supported");
        } else {/* w ww. j a  v  a2s . c om*/
            /*btnSpeak.setEnabled(true);
            speakOut();*/
        }

    } else {
        Log.e("TTS", "Initilization Failed!");
    }

}

From source file:com.abid_mujtaba.fetchheaders.MainActivity.java

@Override
public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        int result = mTTS.setLanguage(Locale.US);

        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Resources.Loge("This Language is not supported. result: " + result, null);
            Resources.Loge(// w  ww.j av a  2 s.c o m
                    "If result is -1 simply install 'Speech Synthesis Data Installer' from the Google Play Store.",
                    null);
        } else {
            return;
        }
    }

    mTTS.stop();
    mTTS.shutdown();
    mTTS = null;

    Resources.Loge("Initialization failed", null);
}

From source file:com.nbplus.vbroadlauncher.service.BroadcastChatHeadService.java

@Override
public void onInit(int status) {
    Log.d(TAG, "> TTS onInit()");

    if (status != TextToSpeech.SUCCESS) {
        Log.e(TAG, String.format("TextToSpeechManager.onInit(%d) fail!", status));
        Log.d(TAG, "   ??.... ? ??...");
        mText2Speech.shutdown();/*  w w w . j ava 2  s. c om*/
        mText2Speech = null;

        // TODO : ? ?????
    } else {
        int result = mText2Speech.setLanguage(Locale.KOREA);
        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e(TAG, String.format("TextToSpeech.setLanguage(%s) fail!", Locale.KOREA.getDisplayName()));

            // TODO : ? ?????
            mText2Speech.shutdown();
            mText2Speech = null;
        } else {
            mText2SpeechHandler.setTextToSpeechObject(mText2Speech);
            mText2SpeechHandler.play(mBroadcastData.getMessage());
        }
    }
}

From source file:com.bdcorps.videonews.MainActivity.java

@Override
public void onInit(int status) {

    // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR
    if (status == TextToSpeech.SUCCESS) {
        // Set preferred language to US english.
        // Note that a language may not be available, and the topicNames will indicate this.
        int result = mTts.setLanguage(Locale.US);

        mTts.setOnUtteranceCompletedListener(this);

        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            // Lanuage data is missing or the language is not supported.
            Log.e("404", "Language is not available.");
        }//w w  w  . j  a va 2  s . com
    } else {
        // Initialization failed.
        Log.e("404", "Could not initialize TextToSpeech.");
        // May be its not installed so we prompt it to be installed
        Intent installIntent = new Intent();
        installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
        startActivity(installIntent);
    }

}

From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.PlayBlackJackGameFragment.java

/**
 * Check accessibility and set flags. Set-up The Android TextToSpeech Engine. Also Set-up
 *  the Google MessageApi Client.// w  ww. j  ava  2 s. c  o  m
 *
 *  Android Developers Website was used to aid in creating the MessageApi Client. For more info
 *   go there
 *  Source: http://developer.android.com/training/wearables/data-layer/events.html
 * @param savedInstanceState
 *
 * A Tutorial from tutorialspoint.com was used to aid with Android TextToSpeech
 *  Source: http://www.tutorialspoint.com/android/android_text_to_speech.htm
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    context = this.getActivity();

    /* Check if Accessibility is on to Speak upon certain events */
    am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    isAccessibilityEnabled = am.isEnabled();
    isExploreByTouchEnabled = am.isTouchExplorationEnabled();

    /* Set-up the TTS Api */
    textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if (status == TextToSpeech.SUCCESS) {
                int result = textToSpeech.setLanguage(Locale.US);
                if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                    Log.e("error", "Language chosen is not supported");
                } else {
                    if (isAccessibilityEnabled) {
                        if (!first_draw_spoken) {
                            String speak = "You drew " + player_left_card.getCardDescription() + " and "
                                    + player_right_card.getCardDescription() + "\n  Dealer drew "
                                    + dealer_right_card.getCardDescription();

                            convertTextToSpeech(speak);
                            first_draw_spoken = true;
                        }
                    }
                }
            } else {
                Log.e("error", "Initialization Failed!");
            }
        }
    });

    Log.d(TAG, "Attempting to connect to Google Api Client");
    mGoogleApiClient = new GoogleApiClient.Builder(context).addApi(Wearable.API).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).build();
    Log.d(TAG, "Connected to Google Api Client");

    // Initialize state flags
    button_hit_state = true;
    button_stand_state = true;
    button_hint_state = true;
    button_start_over_state = true;
    first_draw_spoken = false;
}

From source file:com.github.olga_yakovleva.rhvoice.android.RHVoiceService.java

@Override
protected int onIsLanguageAvailable(String language, String country, String variant) {
    if (BuildConfig.DEBUG) {
        Log.v(TAG, "onIsLanguageAvailable called");
        logLanguage(language, country, variant);
    }/*from  ww  w. j  a va  2s. c  om*/
    Tts tts = ttsManager.get();
    if (tts == null) {
        if (BuildConfig.DEBUG)
            Log.w(TAG, "Not initialized yet");
        return TextToSpeech.LANG_NOT_SUPPORTED;
    }
    Candidate bestMatch = findBestVoice(tts, language, country, variant, "", null);
    int result = languageSupportConstants[bestMatch.score];
    if (BuildConfig.DEBUG)
        Log.v(TAG, "Result: " + result);
    return result;
}

From source file:com.ola.insta.BookingAcivity.java

@Override
public void onInit(int status) {
    if (status == TextToSpeech.SUCCESS) {
        int result = mTextToSpeech.setLanguage(Locale.US);
        // mTextToSpeech.setPitch(5); // set pitch level
        mTextToSpeech.setSpeechRate(0.8f); // set speech speed rate
        if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Log.e("TextToSpeech", "Language is not supported");
        }//from ww w  . j a  v  a  2s .c  o  m
        speakOut("Tap on mike and say; CHALLO NEEKLLO!");
    } else {
        Log.e("TextToSpeech", "Initilization Failed");
    }

}