use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class BeyondVerbal method onError.
private void onError() {
if (DEBUG) {
MyLog.i(CLS_NAME, "onError");
}
Recognition.setState(Recognition.State.IDLE);
final LocalRequest localRequest = new LocalRequest(mContext);
localRequest.setSupportedLanguage(sl);
localRequest.setAction(LocalRequest.ACTION_SPEAK_ONLY);
localRequest.setUtterance(PersonalityResponse.getBeyondVerbalServerErrorResponse(mContext, sl));
localRequest.setTTSLocale(SPH.getTTSLocale(mContext));
localRequest.setVRLocale(SPH.getVRLocale(mContext));
localRequest.execute();
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class TranslationProvider method shouldAction.
/**
* Check to see if the completed translation command needs verbose explanation.
*
* @param ctx the application context
* @param sl the {@link SupportedLanguage}
*/
public static boolean shouldAction(@NonNull final Context ctx, @NonNull final SupportedLanguage sl) {
if (SPH.getTranslateCommandVerbose(ctx) <= COMMAND_TRANSLATE_VERBOSE_LIMIT) {
SPH.incrementTranslateCommandVerbose(ctx);
final Bundle bundle = new Bundle();
bundle.putSerializable(LocalRequest.EXTRA_SUPPORTED_LANGUAGE, sl);
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_SPEAK_ONLY);
bundle.putInt(LocalRequest.EXTRA_CONDITION, Condition.CONDITION_IGNORE);
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getClipboardSpell(ctx, sl));
bundle.putString(LocalRequest.EXTRA_TTS_LANGUAGE, SPH.getTTSLocale(ctx).toString());
new LocalRequest(ctx, bundle).execute();
return true;
}
return false;
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class Quantum method onEntanglement.
@Override
protected void onEntanglement(final EntangledPair entangledPair) {
if (DEBUG) {
MyLog.i(CLS_NAME, "onEntanglement secure: " + secure);
}
if (validatePosition(entangledPair)) {
switch(entangledPair.getPosition()) {
case TOAST_SHORT:
if (DEBUG) {
MyLog.i(CLS_NAME, "Position " + entangledPair.getPosition().name());
MyLog.i(CLS_NAME, "Position " + entangledPair.getCC().name());
MyLog.i(CLS_NAME, "Position getToastContent: " + entangledPair.getToastContent());
}
Toast.makeText(mContext, entangledPair.getToastContent(), Toast.LENGTH_SHORT).show();
break;
case TOAST_LONG:
if (DEBUG) {
MyLog.i(CLS_NAME, "Position " + entangledPair.getPosition().name());
MyLog.i(CLS_NAME, "Position " + entangledPair.getCC().name());
MyLog.i(CLS_NAME, "Position getToastContent: " + entangledPair.getToastContent());
}
Toast.makeText(mContext, entangledPair.getToastContent(), Toast.LENGTH_LONG).show();
break;
case SPEAK:
if (DEBUG) {
MyLog.i(CLS_NAME, "Position " + entangledPair.getPosition().name());
MyLog.i(CLS_NAME, "Position " + entangledPair.getCC().name());
}
final LocalRequest opuRequest = new LocalRequest(mContext);
opuRequest.setAction(LocalRequest.ACTION_SPEAK_ONLY);
opuRequest.setUtterance(entangledPair.getUtterance());
opuRequest.setTTSLocale(ttsLocale);
opuRequest.setVRLocale(vrLocale);
opuRequest.setSupportedLanguage(sl);
opuRequest.execute();
break;
case CLIPBOARD:
if (DEBUG) {
MyLog.i(CLS_NAME, "Position " + entangledPair.getPosition().name());
MyLog.i(CLS_NAME, "Position " + entangledPair.getCC().name());
}
ClipboardHelper.saveClipboardContent(mContext);
if (DEBUG) {
MyLog.i(CLS_NAME, "Position: CLIPBOARD content: " + ClipboardHelper.getClipboardContent());
}
break;
case SHOW_COMPUTING:
if (DEBUG) {
MyLog.i(CLS_NAME, "Position " + entangledPair.getPosition().name());
MyLog.i(CLS_NAME, "Position " + entangledPair.getCC().name());
}
NotificationHelper.createComputingNotification(mContext);
break;
default:
if (DEBUG) {
MyLog.w(CLS_NAME, "Position: default");
}
break;
}
}
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class SpeakerEnrollment method onFileWriteComplete.
@Override
public void onFileWriteComplete(final boolean success) {
if (DEBUG) {
MyLog.i(CLS_NAME, "onFileWriteComplete: " + success);
}
if (!mic.isInterrupted()) {
if (success) {
final LocalRequest localRequest = new LocalRequest(mic.getContext());
localRequest.setSupportedLanguage(sl);
localRequest.setAction(LocalRequest.ACTION_SPEAK_ONLY);
localRequest.setTTSLocale(SPH.getTTSLocale(mic.getContext()));
localRequest.setVRLocale(SPH.getVRLocale(mic.getContext()));
localRequest.setUtterance(SaiyResourcesHelper.getStringResource(mic.getContext(), sl, R.string.vocal_notify_enroll));
localRequest.execute();
new CreateIDEnrollment(mic, apiKey, profileId, shortAudio, mic.getFile()).stream();
} else {
onError(Speaker.ERROR_FILE);
}
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "onFileWriteComplete: mic interrupted");
}
}
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class SpeakerEnrollment method onError.
@Override
public void onError(int error) {
if (DEBUG) {
MyLog.w(CLS_NAME, "onError");
}
mic.getRecognitionListener().onComplete();
Recognition.setState(Recognition.State.IDLE);
if (mic.isInterrupted()) {
error = Speaker.ERROR_USER_CANCELLED;
}
final LocalRequest localRequest = new LocalRequest(mic.getContext());
localRequest.setSupportedLanguage(sl);
localRequest.setAction(LocalRequest.ACTION_SPEAK_ONLY);
localRequest.setTTSLocale(SPH.getTTSLocale(mic.getContext()));
localRequest.setVRLocale(SPH.getVRLocale(mic.getContext()));
switch(error) {
case Speaker.ERROR_USER_CANCELLED:
if (DEBUG) {
MyLog.w(CLS_NAME, "onError ERROR_USER_CANCELLED");
}
localRequest.setUtterance(SaiyResourcesHelper.getStringResource(mic.getContext(), sl, R.string.cancelled));
break;
case Speaker.ERROR_NETWORK:
if (DEBUG) {
MyLog.w(CLS_NAME, "onError ERROR_NETWORK");
}
localRequest.setUtterance(PersonalityResponse.getNoNetwork(mic.getContext(), sl));
break;
case Speaker.ERROR_AUDIO:
if (DEBUG) {
MyLog.w(CLS_NAME, "onError ERROR_AUDIO");
}
localRequest.setUtterance(SaiyResourcesHelper.getStringResource(mic.getContext(), sl, R.string.error_audio));
break;
case Speaker.ERROR_FILE:
if (DEBUG) {
MyLog.w(CLS_NAME, "onError ERROR_FILE");
}
localRequest.setUtterance(SaiyResourcesHelper.getStringResource(mic.getContext(), sl, R.string.error_audio));
break;
default:
if (DEBUG) {
MyLog.w(CLS_NAME, "onError default");
}
localRequest.setUtterance(SaiyResourcesHelper.getStringResource(mic.getContext(), sl, R.string.error_audio));
break;
}
localRequest.execute();
}
Aggregations