當前位置: 首頁>>代碼示例>>Java>>正文


Java TextToSpeech.LANG_AVAILABLE屬性代碼示例

本文整理匯總了Java中android.speech.tts.TextToSpeech.LANG_AVAILABLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextToSpeech.LANG_AVAILABLE屬性的具體用法?Java TextToSpeech.LANG_AVAILABLE怎麽用?Java TextToSpeech.LANG_AVAILABLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.speech.tts.TextToSpeech的用法示例。


在下文中一共展示了TextToSpeech.LANG_AVAILABLE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isArabicSupported

public boolean isArabicSupported() {
    try {
        return isActive && tts != null && tts.isLanguageAvailable(arabicLanguage) == TextToSpeech.LANG_AVAILABLE;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:8,代碼來源:DefaultTextSpeech.java

示例2: isLangAvailable

private boolean isLangAvailable(Locale locale){
    try {
        return isActive && tts != null && tts.isLanguageAvailable(locale) == TextToSpeech.LANG_AVAILABLE;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:8,代碼來源:DefaultTextSpeech.java

示例3: onInit

@Override
public void onInit(int status) {
    if (mTts == null) {
        EasyTrackerUtils.sendNonFatalException(this,
                new IllegalStateException("TTS field somehow null in TTS onInit callback"));
        return;
    }

    // text to speech engine ready
    mTtsReady = true;

    Locale currentLocale = Locale.getDefault();
    final String lang = currentLocale.getLanguage();

    // Do we currently have enough translated strings for the language?
    // TODO fix this shit... oh god.
    boolean haveTranslations = (
            lang.matches("en") ||
                    lang.matches("fr") ||
                    lang.matches("ru") ||
                    lang.matches("pt") ||
                    lang.matches("ko"));

    if (haveTranslations) {
        int langAvailable = mTts.isLanguageAvailable(currentLocale);
        if (langAvailable == TextToSpeech.LANG_AVAILABLE ||
                langAvailable == TextToSpeech.LANG_COUNTRY_AVAILABLE ||
                langAvailable == TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE) {
            mTts.setLanguage(currentLocale);
            return;
        }
    }

    // TODO inform the user that TTS data isn't available for their language, and what
    // they can do to get it etc.
    mTts.setLanguage(Locale.US);
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:37,代碼來源:PlaybackActivity.java

示例4: onInit

@Override
public void onInit(int initStatus) {
    //check for successful instantiation
    if (initStatus == TextToSpeech.SUCCESS) {
        if(tts.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE)
            tts.setLanguage(Locale.US);
    }
    else if (initStatus == TextToSpeech.ERROR) {
        Toast.makeText(getActivity(), "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:vikasdesale,項目名稱:News24x7-news-from-every-part-of-the-world,代碼行數:11,代碼來源:DetailsFragment.java


注:本文中的android.speech.tts.TextToSpeech.LANG_AVAILABLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。