SimplyVoice *simply_voice_create(Simply *simply) { if (s_voice) { return s_voice; } SimplyVoice *self = malloc(sizeof(*self)); *self = (SimplyVoice) { .simply = simply, .in_progress = false, }; #ifndef PBL_SDK_2 self->session = dictation_session_create(SIMPLY_VOICE_BUFFER_LENGTH, dictation_session_callback, NULL); #endif s_voice = self; return self; } void simply_voice_destroy(SimplyVoice *self) { if (!self) { return; } free(self); s_voice = NULL; }
static void select_click_handler(ClickRecognizerRef recognizer, void *context) { if (!is_connected) { return; } // Start dictation UI #if defined(PBL_MICROPHONE) if (s_dictation_session == NULL) { s_dictation_session = dictation_session_create(sizeof(dictated_message), dictation_session_callback, NULL); if (s_dictation_session != NULL) { dictation_session_enable_confirmation(s_dictation_session, false); } } if (s_state == BEGINNING_STATE) { dictation_session_start(s_dictation_session); } if (s_state == CREATING_FINAL_MESSAGE_STATE) { dictation_session_start(s_dictation_session); } #endif if (s_state == CONFIRMING_FINAL_MESSAGE_STATE) { change_state(SENDING_FINAL_MESSAGE_STATE); send_final_message(); action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL); action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL); action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL); } }
void nw_start_dictation() { nw_set_busy_state(false); if (dictationSession == NULL) dictationSession = dictation_session_create(400, dictation_session_callback, NULL); dictation_session_start(dictationSession); }
/* * 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); } }
static void onSelect(int index, void *context) { window_stack_pop(true); window_destroy(window); // Do action... if (index == 0) { // Add item dictSession = dictation_session_create(1024, onDictation, NULL); dictation_session_start(dictSession); } else if (index == 1) { // Select shopping list listsmenu_init(); } else if (index == 2) { // Clean up list } }
static void window_unload(Window *window) { text_layer_destroy(message_layer); } static void init() { s_main_window = window_create(); window_set_click_config_provider(s_main_window, click_config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); window_stack_push(s_main_window, true); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); s_dictation_session = dictation_session_create(sizeof(display_message), dictation_session_callback, NULL); dictation_session_enable_confirmation(s_dictation_session, false); app_message_register_outbox_sent(outbox_sent_callback); } static void deinit() { dictation_session_destroy(s_dictation_session); window_destroy(s_main_window); } int main() { init(); app_event_loop(); deinit();
static void start_dictation(){ session = dictation_session_create(0, dictation_session_callback, NULL); dictation_session_enable_confirmation(session, true); dictation_session_enable_error_dialogs(session, true); dictation_session_start(session); }
void prepare_dictation() { s_dictation_session = dictation_session_create(BUFFER_SIZE, dictation_session_callback, NULL); }
// open AppMessage with sensible buffer sizes app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); // main window s_main_window = window_create(); window_set_click_config_provider(s_main_window, click_config_provider); window_set_window_handlers(s_main_window, (WindowHandlers) { .load = window_load, .unload = window_unload, }); window_set_background_color(s_main_window, GColorFromHEX(0x000000)); window_stack_push(s_main_window, true); // dictation s_dictation_session = dictation_session_create(sizeof(s_last_text), dictation_session_callback, NULL); if (persist_exists(KEY_ENABLE_CONFIRMATION_DIALOG)) { dictation_session_enable_confirmation(s_dictation_session, persist_read_bool(KEY_ENABLE_CONFIRMATION_DIALOG)); } if (persist_exists(KEY_ENABLE_ERROR_DIALOG)) { dictation_session_enable_error_dialogs(s_dictation_session, persist_read_bool(KEY_ENABLE_ERROR_DIALOG)); } if (persist_exists(KEY_START_IMMEDIATELY) && persist_read_bool(KEY_START_IMMEDIATELY)) { dictation_session_start(s_dictation_session); } else { show_text("Press SELECT button to start", GColorFromHEX(0xffffff), GColorFromHEX(0x000000)); } }
static void search_select_callback(int index, void *ctx) { window_stack_push(search, true); dictation_session = dictation_session_create(sizeof(last_text), dictation_session_callback, NULL); dictation_session_start(dictation_session); }