本文整理汇总了Java中android.speech.tts.TextToSpeech.LANG_MISSING_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java TextToSpeech.LANG_MISSING_DATA属性的具体用法?Java TextToSpeech.LANG_MISSING_DATA怎么用?Java TextToSpeech.LANG_MISSING_DATA使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.speech.tts.TextToSpeech
的用法示例。
在下文中一共展示了TextToSpeech.LANG_MISSING_DATA属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Init
public void Init() {
if (_ttsInitialized) {
Logger.getInstance().Warning(TAG, "Already initialized!");
return;
}
_ttsSpeaker = new TextToSpeech(_context, status -> {
if (status == TextToSpeech.SUCCESS) {
int result = _ttsSpeaker.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Logger.getInstance().Error(TAG, "This Language is not supported!");
} else {
_receiverController.RegisterReceiver(_speakReceiver, new String[]{TTS_SPEAK_TEXT_BROADCAST});
_ttsInitialized = true;
}
} else {
Logger.getInstance().Error(TAG, "Initialization failed!");
}
});
}
示例2: onInit
@Override
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
//int result= tts.setLanguage(Locale.ENGLISH);
Locale locale = new Locale("tr", "TR");
int result = tts.setLanguage(locale);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "Language is not supported");
} else {
btn_konus.setEnabled(true);
String text = editText1.getText().toString();
speakOut(text);
}
} else {
Log.e("TTS", "Initilization Failed");
}
}
示例3: init
public void init(Context ctx) {
prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
prefsÆndret();
tts = new TextToSpeech(ctx, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
initialiseret = true;
int res = tts.setLanguage(new Locale("da", ""));
if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
res = tts.setLanguage(Locale.getDefault());
if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
res = tts.setLanguage(Locale.US);
if (res == TextToSpeech.LANG_MISSING_DATA || res == TextToSpeech.LANG_NOT_SUPPORTED) {
initialiseret = false;
}
}
}
// udtal("Tekst til tale initialiseret for sproget " + tts.getLanguage().getDisplayLanguage(tts.getLanguage()));
}
}
});
}
示例4: createTTS
private void createTTS() {
//Creates an instance of Google API TTS
mTTS = new TextToSpeech(mContext, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
//If initializaation is sucessful so set language.
if (status == TextToSpeech.SUCCESS) {
//Set language to PT-BR and get the value returned
int result = mTTS.setLanguage(new Locale("pt", "br"));
//Check if the language is supported, if not print it on Android Monitor.
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TextToSpeechManager", "This Language is not supported");
}
} else {
Log.e("TextToSpeechManager", "Initilization Failed!");
}
}
});
}
示例5: onInit
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = mTts.setLanguage(Locale.getDefault());
isInit = true;
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("error", "This Language is not supported");
}
Log.d("TextToSpeech", "Initialization Suceeded! " + System.currentTimeMillis());
speak(mContext.getString(R.string.hello1) + ",");
} else {
Log.e("error", "Initialization Failed! " + status);
}
}
示例6: onInit
@Override
public void onInit(int status) {
if(status == TextToSpeech.SUCCESS) {
Locale English = tts.getLanguage();
int result = tts.setLanguage(English);
if(result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS","this language is not supported");
}
} else {
Log.e("TTS","Initialization failed!!");
}
}
示例7: onBtnTextToSpeechClicked
@OnClick(R.id.btn_text_to_speech)
public void onBtnTextToSpeechClicked() {
onInitListener = new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = speech.setLanguage(Locale.ENGLISH);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
ToastUtils.showShortToast("语言不支持");
} else {
String content = "This is a default voice";
if (!TextUtils.isEmpty(etTextContent.getText().toString())) {
content = etTextContent.getText().toString();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
speech.speak(content, TextToSpeech.QUEUE_FLUSH, null, null);
} else {
speech.speak(content, TextToSpeech.QUEUE_FLUSH, null);
}
}
}
}
};
speech = new TextToSpeech(this, onInitListener);
}
示例8: isLanguageAvailable
public int isLanguageAvailable(Locale loc) {
return TextToSpeech.LANG_MISSING_DATA;
}