コード例 #1
0
ファイル: voice.c プロジェクト: JamesFowler42/morpheuz20
/*
 * Once dication has happened this fires, for better or worse
 */
static void voice_callback(DictationSession *session, DictationSessionStatus status, char *transcription, void *context) {
  
  // If for worse then this is where we go
  if (status != DictationSessionStatusSuccess) {
    LOG_WARN("dictation failed");
    dictation_session_stop(session);
    voice_system_active = false;
    respond_with_vibe(false);
    show_notice(status == DictationSessionStatusFailureTranscriptionRejected ? RESOURCE_ID_NOTICE_VOICE_STOPPED : RESOURCE_ID_NOTICE_VOICE_FAILED);
    return;
  } 
  
  // If we were lucky then we try to match the transcription to a menu item
  dictation_session_stop(session);
  
  LOG_INFO("dictation got %s", transcription);
  bool vibe;
  VoiceSelectAction action = determine_action(transcription, &vibe);
  
  // Allow comms and notices
  voice_system_active = false; 
  
  if (action != NULL) {
    // If we get a match then fire the action
    if (vibe)
      respond_with_vibe(true);
    action();
  } else {
    // Feedback we didn't find anything
    respond_with_vibe(false);
    show_notice_with_message(RESOURCE_ID_VOICE_DIDNT_UNDERSTAND, transcription);
  }
}
コード例 #2
0
ファイル: morpheuz.c プロジェクト: hashier/morpheuz20
/*
 * Toggle weekend mode
 */
void toggle_weekend_mode() {
  if (!get_config_data()->smart) {
    show_notice(RESOURCE_ID_NOTICE_NEED_SMART_ALARM);
    return;
  }
  // Toggle weekend
  if (get_config_data()->weekend_until > 0) {
    // Turn off weekend
    get_config_data()->weekend_until = 0;
    set_smart_status();
  } else {
    // Turn on weekend
    get_config_data()->weekend_until = time(NULL) + WEEKEND_PERIOD;
    set_smart_status();
  }
}
コード例 #3
0
ファイル: voice.c プロジェクト: JamesFowler42/morpheuz20
/*
 * Start voice control
 */
EXTFN void voice_control() {
  
  voice_system_active = true;
  if (ds == NULL) {
    ds = dictation_session_create(PHRASE_BUFFER_LEN, voice_callback, NULL);
    #ifndef TESTING_BUILD
      dictation_session_enable_confirmation(ds, false);
    #endif
    dictation_session_enable_error_dialogs(ds, false);
  }
  if (ds != NULL) {
    dictation_session_start(ds);
  } else {
    voice_system_active = false;
    respond_with_vibe(false);
    show_notice(RESOURCE_ID_NOTICE_VOICE_UNAVAILABLE);
  }
  
}