Search in sources :

Example 1 with LocalRequest

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();
}
Also used : LocalRequest(ai.saiy.android.service.helper.LocalRequest)

Example 2 with LocalRequest

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;
}
Also used : LocalRequest(ai.saiy.android.service.helper.LocalRequest) Bundle(android.os.Bundle)

Example 3 with LocalRequest

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;
        }
    }
}
Also used : LocalRequest(ai.saiy.android.service.helper.LocalRequest)

Example 4 with LocalRequest

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");
        }
    }
}
Also used : CreateIDEnrollment(ai.saiy.android.cognitive.identity.provider.microsoft.http.CreateIDEnrollment) LocalRequest(ai.saiy.android.service.helper.LocalRequest)

Example 5 with LocalRequest

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();
}
Also used : LocalRequest(ai.saiy.android.service.helper.LocalRequest)

Aggregations

LocalRequest (ai.saiy.android.service.helper.LocalRequest)19 UtilsString (ai.saiy.android.utils.UtilsString)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 SupportedLanguage (ai.saiy.android.localisation.SupportedLanguage)2 BlackListHelper (ai.saiy.android.api.helper.BlackListHelper)1 Regex (ai.saiy.android.api.request.Regex)1 SaiyKeyphrase (ai.saiy.android.api.request.SaiyKeyphrase)1 Speaker (ai.saiy.android.cognitive.identity.provider.microsoft.Speaker)1 CreateIDEnrollment (ai.saiy.android.cognitive.identity.provider.microsoft.http.CreateIDEnrollment)1 ValidateID (ai.saiy.android.cognitive.identity.provider.microsoft.http.ValidateID)1 CustomCommand (ai.saiy.android.custom.CustomCommand)1 ExecuteIntent (ai.saiy.android.intent.ExecuteIntent)1 Resolve (ai.saiy.android.nlu.local.Resolve)1 UtilsBundle (ai.saiy.android.utils.UtilsBundle)1 Pair (android.util.Pair)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1