当前位置: 首页>>代码示例>>Java>>正文


Java TextToSpeech.LANG_COUNTRY_AVAILABLE属性代码示例

本文整理汇总了Java中android.speech.tts.TextToSpeech.LANG_COUNTRY_AVAILABLE属性的典型用法代码示例。如果您正苦于以下问题:Java TextToSpeech.LANG_COUNTRY_AVAILABLE属性的具体用法?Java TextToSpeech.LANG_COUNTRY_AVAILABLE怎么用?Java TextToSpeech.LANG_COUNTRY_AVAILABLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.speech.tts.TextToSpeech的用法示例。


在下文中一共展示了TextToSpeech.LANG_COUNTRY_AVAILABLE属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAvailableLocales

@ReactMethod 
public void getAvailableLocales(Promise promise) {
	if(notReady(promise)) return;
	
	try {
		WritableArray localeList = Arguments.createArray();
		Locale[] localesArray = Locale.getAvailableLocales();
		for(Locale locale: localesArray) {
			int isAvailable = tts.isLanguageAvailable(locale);
			if(isAvailable == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
				WritableMap newLocale = returnMapForLocale(locale);
				localeList.pushMap(newLocale);
			}
		}

		promise.resolve(localeList);
	} catch(Exception e) {
		promise.reject("error", "Unable to retrieve locales for getAvailableLocales()", e);
	}
}
 
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:20,代码来源:RNAndroidTextToSpeechModule.java

示例2: 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


注:本文中的android.speech.tts.TextToSpeech.LANG_COUNTRY_AVAILABLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。