本文整理匯總了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;
}
}
示例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;
}
}
示例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);
}
示例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();
}
}