本文整理汇总了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;
}