本文整理匯總了Java中android.speech.tts.TextToSpeech.QUEUE_ADD屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextToSpeech.QUEUE_ADD屬性的具體用法?Java TextToSpeech.QUEUE_ADD怎麽用?Java TextToSpeech.QUEUE_ADD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.speech.tts.TextToSpeech
的用法示例。
在下文中一共展示了TextToSpeech.QUEUE_ADD屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: speak
@ReactMethod
public void speak(String utterance, String queueMode, Promise promise) {
if(notReady(promise)) return;
if(IS_DUCKING) {
int amResult = audioManager.requestAudioFocus(afChangeListener,
AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
if(amResult != AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
promise.reject("error", "Android AudioManager error, failed to request audio focus");
}
String utteranceId = Integer.toString(utterance.hashCode());
int mode = TextToSpeech.QUEUE_ADD;
if(queueMode.equals("ADD"))
mode = TextToSpeech.QUEUE_ADD;
else if(queueMode.equals("FLUSH"))
mode = TextToSpeech.QUEUE_FLUSH;
int speakResult = speak(utterance, mode, utteranceId);
if(speakResult == TextToSpeech.SUCCESS) {
promise.resolve(utteranceId);
} else {
promise.reject("error", "Unable to play. Error at speak(utterance, queueMode)");
}
}
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:28,代碼來源:RNAndroidTextToSpeechModule.java
示例2: onServiceConnected
@Override
public void onServiceConnected(final ComponentName className, final IBinder iBinder) {
if (iBinder != null) {
if (DEBUG) {
MyLog.i(CLS_NAME, "onServiceConnected");
MyLog.i(CLS_NAME, "onServiceConnected: CLS: " + iBinder.getClass().getSimpleName());
MyLog.v(CLS_NAME, "onServiceConnected: binder alive: " + iBinder.isBinderAlive());
}
selfAwareService = ((SelfAware.BoundSA) iBinder).getService();
if (DEBUG) {
MyLog.i(CLS_NAME, "onServiceConnected: TTS Locale: " + request.getTTSLocale().toString());
MyLog.i(CLS_NAME, "onServiceConnected: Recognition Locale: " + request.getVRLocale().toString());
}
final Pair<Boolean, Integer> isSpeakingPair = selfAwareService.isSpeaking();
final boolean isListening = selfAwareService.isListening();
final Pair<Boolean, Boolean> isHotwordActive = selfAwareService.isHotwordActive();
if (DEBUG) {
MyLog.i(CLS_NAME, "isSpeaking: " + isSpeakingPair.first);
MyLog.i(CLS_NAME, "isListening:" + isListening);
MyLog.i(CLS_NAME, "isHotwordActive:" + isHotwordActive.first);
MyLog.i(CLS_NAME, "isHotwordRestartScheduled:" + isHotwordActive.second);
}
if (request.getAction() == LocalRequest.ACTION_TOGGLE_HOTWORD) {
if (isHotwordActive.first || isHotwordActive.second) {
request.setAction(LocalRequest.ACTION_STOP_HOTWORD);
request.setShutdownHotword();
} else {
request.setAction(LocalRequest.ACTION_START_HOTWORD);
}
}
if (isHotwordActive.first && request.getAction() == LocalRequest.ACTION_START_HOTWORD) {
if (DEBUG) {
MyLog.i(CLS_NAME, "ACTION_START_HOTWORD: already running");
}
} else if (isListening) {
selfAwareService.stopListening(request.getShutdownHotword());
} else if (isSpeakingPair.first) {
final int currentPriority = isSpeakingPair.second;
final int requestPriority = request.getSpeechPriority();
if (requestPriority == currentPriority && request.getQueueType() != TextToSpeech.QUEUE_ADD) {
if (DEBUG) {
MyLog.i(CLS_NAME, "priorities match - stopping speech");
}
selfAwareService.stopSpeech(request.shouldPreventRecognition());
} else {
if (request.getAction() == LocalRequest.ACTION_UNKNOWN) {
if (DEBUG) {
MyLog.i(CLS_NAME, "priority mismatch - ACTION_UNKNOWN - stopping speech");
}
selfAwareService.stopSpeech(request.shouldPreventRecognition());
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "priority mismatch - completing request");
}
completeRequest();
}
}
} else {
completeRequest();
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "onServiceConnected: iBinder null");
}
}
doUnbindService();
}
示例3: isQueueAdd
/**
* Check if the queue type is {@link TextToSpeech#QUEUE_ADD}
*
* @param bundle the parameters
* @return true if the queue type is {@link TextToSpeech#QUEUE_ADD}. False otherwise
*/
public boolean isQueueAdd(final Bundle bundle) {
return bundle != null && bundle.getInt(LocalRequest.EXTRA_QUEUE_TYPE,
TextToSpeech.QUEUE_FLUSH) == TextToSpeech.QUEUE_ADD;
}