use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class FragmentSuperuserHelper method audioEnroll.
/**
* All is well - begin the audio enrollment
*/
private void audioEnroll(@NonNull final String profileId) {
if (DEBUG) {
MyLog.i(CLS_NAME, "audioEnroll");
}
final String utterance;
if (SPH.getEnrollmentVerbose(getApplicationContext())) {
utterance = getApplicationContext().getString(R.string.speech_enroll_instructions_40);
} else {
SPH.setEnrollmentVerbose(getApplicationContext());
utterance = getApplicationContext().getString(R.string.speech_enroll_instructions_first);
}
final LocalRequest request = new LocalRequest(getApplicationContext());
request.prepareDefault(LocalRequest.ACTION_SPEAK_LISTEN, utterance);
request.setQueueType(TextToSpeech.QUEUE_ADD);
request.setCondition(Condition.CONDITION_IDENTITY);
request.setIdentityProfile(profileId);
request.execute();
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class SaiyTileService method onClick.
@Override
public void onClick() {
super.onClick();
if (DEBUG) {
MyLog.i(CLS_NAME, "onClick");
}
final LocalRequest lr = new LocalRequest(getApplicationContext());
lr.prepareIntro();
lr.execute();
final Intent closeShadeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeShadeIntent);
// final Intent preferenceIntent = new Intent(getApplicationContext(), ActivityTilePreferences.class);
// startActivityAndCollapse(preferenceIntent);
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class RecognitionAction method sendErrorLocalRequest.
/**
* Utility method to notify the user of a processing error
*/
private void sendErrorLocalRequest() {
final LocalRequest lr = new LocalRequest(mContext);
lr.setAction(LocalRequest.ACTION_SPEAK_ONLY);
lr.setUtterance(PersonalityResponse.getErrorEmptyVoiceData(mContext, sl));
lr.setTTSLocale(ttsLocale);
lr.setVRLocale(vrLocale);
lr.setSupportedLanguage(sl);
lr.execute();
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class GoogleNowMonitor method shutdownHotword.
/**
* Send a request to prevent the hotword detection from restarting
*
* @param ctx the application context
*/
private void shutdownHotword(@NonNull final Context ctx) {
if (DEBUG) {
MyLog.i(CLS_NAME, "shutdownHotword");
}
final LocalRequest request = new LocalRequest(ctx);
request.prepareDefault(LocalRequest.ACTION_STOP_HOTWORD, null);
request.setShutdownHotword();
request.execute();
}
use of ai.saiy.android.service.helper.LocalRequest in project Saiy-PS by brandall76.
the class NotificationService method onHandleIntent.
@Override
protected void onHandleIntent(final Intent intent) {
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent");
}
if (intent != null) {
final String action = intent.getAction();
final Bundle bundle = intent.getExtras();
if (bundle != null) {
if (DEBUG) {
examineIntent(intent);
}
if (UtilsString.notNaked(action)) {
if (intent.getAction().equals(INTENT_CLICK)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: INTENT_CLICK");
}
final SupportedLanguage sl = SupportedLanguage.getSupportedLanguage(SPH.getVRLocale(getApplicationContext()));
bundle.putSerializable(LocalRequest.EXTRA_SUPPORTED_LANGUAGE, sl);
switch(bundle.getInt(CLICK_ACTION, 0)) {
case NOTIFICATION_FOREGROUND:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_FOREGROUND");
}
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_SPEAK_LISTEN);
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityHelper.getIntro(getApplicationContext(), sl));
bundle.putString(LocalRequest.EXTRA_RECOGNITION_LANGUAGE, SPH.getVRLocale(getApplicationContext()).toString());
bundle.putString(LocalRequest.EXTRA_TTS_LANGUAGE, SPH.getTTSLocale(getApplicationContext()).toString());
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_LISTENING:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_LISTENING");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_SPEAKING:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_SPEAKING");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_FETCHING:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_FETCHING");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_INITIALISING:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_INITIALISING");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_COMPUTING:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_COMPUTING");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_PERMISSIONS:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_PERMISSIONS");
}
ExecuteIntent.openApplicationSpecificSettings(getApplicationContext(), getPackageName());
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_SPEAK_ONLY);
bundle.putString(LocalRequest.EXTRA_RECOGNITION_LANGUAGE, SPH.getVRLocale(getApplicationContext()).toString());
bundle.putString(LocalRequest.EXTRA_TTS_LANGUAGE, SPH.getTTSLocale(getApplicationContext()).toString());
String permissionContent;
switch(bundle.getInt(PermissionHelper.REQUESTED_PERMISSION, 0)) {
case PermissionHelper.REQUEST_AUDIO:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: REQUEST_AUDIO");
}
permissionContent = getString(ai.saiy.android.R.string.permission_audio);
break;
case PermissionHelper.REQUEST_GROUP_CONTACTS:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: REQUEST_GROUP_CONTACTS");
}
permissionContent = getString(ai.saiy.android.R.string.permission_group_contacts);
break;
case PermissionHelper.REQUEST_FILE:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: REQUEST_FILE");
}
// TODO
permissionContent = getString(ai.saiy.android.R.string.permission_unknown);
break;
default:
if (DEBUG) {
MyLog.w(CLS_NAME, "onHandleIntent: PermissionHelper.UNKNOWN");
}
permissionContent = getString(ai.saiy.android.R.string.permission_unknown);
break;
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, permissionContent);
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_EMOTION:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_EMOTION");
}
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_SPEAK_ONLY);
final String emotionAnalysis = AnalysisResultHelper.getEmotionDescription(getApplicationContext(), sl);
bundle.putString(LocalRequest.EXTRA_UTTERANCE, emotionAnalysis);
bundle.putString(LocalRequest.EXTRA_RECOGNITION_LANGUAGE, SPH.getVRLocale(getApplicationContext()).toString());
bundle.putString(LocalRequest.EXTRA_TTS_LANGUAGE, SPH.getTTSLocale(getApplicationContext()).toString());
bundle.putSerializable(LocalRequest.EXTRA_COMMAND, CC.COMMAND_EMOTION);
new LocalRequest(getApplicationContext(), bundle).execute();
break;
case NOTIFICATION_HOTWORD:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_HOTWORD");
}
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_STOP_HOTWORD);
final LocalRequest request = new LocalRequest(getApplicationContext(), bundle);
request.setShutdownHotword();
request.execute();
final Intent closeShadeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeShadeIntent);
break;
case NOTIFICATION_IDENTIFICATION:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: NOTIFICATION_IDENTIFICATION");
}
bundle.putInt(LocalRequest.EXTRA_ACTION, LocalRequest.ACTION_SPEAK_ONLY);
bundle.putString(LocalRequest.EXTRA_RECOGNITION_LANGUAGE, SPH.getVRLocale(getApplicationContext()).toString());
bundle.putString(LocalRequest.EXTRA_TTS_LANGUAGE, SPH.getTTSLocale(getApplicationContext()).toString());
switch(bundle.getInt(LocalRequest.EXTRA_CONDITION)) {
case Condition.CONDITION_IDENTIFY:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: CONDITION_IDENTIFY");
}
final Speaker.Confidence confidence = (Speaker.Confidence) bundle.getSerializable(Speaker.EXTRA_IDENTIFY_OUTCOME);
if (confidence != null) {
switch(confidence) {
case HIGH:
if (DEBUG) {
MyLog.i(CLS_NAME, "checkResult: confidence: " + Speaker.Confidence.HIGH.name());
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getVocalIDHigh(getApplicationContext(), sl));
break;
case NORMAL:
if (DEBUG) {
MyLog.i(CLS_NAME, "checkResult: confidence: " + Speaker.Confidence.NORMAL.name());
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getVocalIDMedium(getApplicationContext(), sl));
break;
case LOW:
if (DEBUG) {
MyLog.i(CLS_NAME, "checkResult: confidence: " + Speaker.Confidence.LOW.name());
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getVocalIDLow(getApplicationContext(), sl));
break;
case UNDEFINED:
if (DEBUG) {
MyLog.i(CLS_NAME, "checkResult: confidence: " + Speaker.Confidence.UNDEFINED.name());
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getVocalIDLow(getApplicationContext(), sl));
break;
case ERROR:
if (DEBUG) {
MyLog.i(CLS_NAME, "checkResult: confidence: " + Speaker.Confidence.ERROR.name());
}
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getVocalIDError(getApplicationContext(), sl));
break;
}
}
break;
case Condition.CONDITION_IDENTITY:
if (DEBUG) {
MyLog.i(CLS_NAME, "onHandleIntent: CONDITION_IDENTITY");
}
if (bundle.getBoolean(Speaker.EXTRA_IDENTITY_OUTCOME, false)) {
bundle.putString(LocalRequest.EXTRA_UTTERANCE, SaiyResourcesHelper.getStringResource(getApplicationContext(), sl, R.string.speech_enroll_success));
} else {
bundle.putString(LocalRequest.EXTRA_UTTERANCE, PersonalityResponse.getEnrollmentError(getApplicationContext(), sl));
}
break;
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
default:
if (DEBUG) {
MyLog.w(CLS_NAME, "onHandleIntent: default");
}
new LocalRequest(getApplicationContext(), bundle).execute();
break;
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "onHandleIntent: ACTION_UNKNOWN");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "onHandleIntent: Bundle null");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "onHandleIntent: Action null");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, " onHandleIntent: Intent null");
}
}
}
Aggregations