From: Wonnam Jang Date: Fri, 5 Oct 2018 06:37:55 +0000 (+0900) Subject: Add codes to request speech data X-Git-Tag: submit/tizen/20181005.114359~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88d4f6bbd42cca034063b857c74b1c71052e74af;p=platform%2Fcore%2Fuifw%2Fwakeup-engine-default.git Add codes to request speech data Change-Id: I0bb3bd68afdf0dc0e36dced1198ce3fcbbe93c1f Signed-off-by: Wonnam Jang --- diff --git a/inc/multi_assistant_service_plugin.h b/inc/multi_assistant_service_plugin.h index dc4432a..6f8be89 100644 --- a/inc/multi_assistant_service_plugin.h +++ b/inc/multi_assistant_service_plugin.h @@ -1,6 +1,5 @@ /* - * Samsung TTS - * Copyright 2012-2014 Samsung Electronics Co., Ltd + * Copyright 2018 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the License); * you may not use this file except in compliance with the License. diff --git a/inc/multi_wakeup_recognizer.h b/inc/multi_wakeup_recognizer.h index c793a4b..862deb4 100644 --- a/inc/multi_wakeup_recognizer.h +++ b/inc/multi_wakeup_recognizer.h @@ -1,6 +1,5 @@ /* - * Samsung TTS - * Copyright 2012-2014 Samsung Electronics Co., Ltd + * Copyright 2018 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.1 (the License); * you may not use this file except in compliance with the License. @@ -26,12 +25,6 @@ extern "C" { #endif -/* -#define ENGINE_UUID "27F277E9-BBC4-4dca-B553-D9884A3CDAA0" -#define ENGINE_NAME "Samsung TTS" -#define ENGINE_UG_NAME "tts_smt_setting_ug.so" -*/ - typedef enum { WAKEUP_EVENT_ERROR = -1, /**< Event when the wakeup recognition has failed */ WAKEUP_EVENT_SUCCESS = 1, /**< Event when the wakeup word is matched succesfully */ diff --git a/inc/multi_wakeup_recognizer.h.org b/inc/multi_wakeup_recognizer.h.org deleted file mode 100644 index 734374d..0000000 --- a/inc/multi_wakeup_recognizer.h.org +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Samsung TTS - * Copyright 2012-2014 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef _MULTI_WAKEUP_RECOGNIZER_H_ -#define _MULTI_WAKEUP_RECOGNIZER_H_ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -/* -#define ENGINE_UUID "27F277E9-BBC4-4dca-B553-D9884A3CDAA0" -#define ENGINE_NAME "Samsung TTS" -#define ENGINE_UG_NAME "tts_smt_setting_ug.so" -*/ - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "multi-wakeup" - -typedef enum { - WAKEUP_EVENT_ERROR = -1, /**< Event when the wakeup recognition has failed */ - WAKEUP_EVENT_SUCCESS = 1, /**< Event when the wakeup word is matched succesfully */ - WAKEUP_EVENT_REJECTED = 2 /**< Event when the wakeup word is not matched */ -} wakeup_service_wakeup_event_e; - -typedef enum { - WAKEUP_SPEECH_STREAMING_EVENT_FAIL = -1, /**< Failed */ - WAKEUP_SPEECH_STREAMING_EVENT_START = 1, /**< Start event */ - WAKEUP_SPEECH_STREAMING_EVENT_CONTINUE = 2, /**< Continue event */ - WAKEUP_SPEECH_STREAMING_EVENT_FINISH = 3 /**< Finish event */ -} wakeup_service_speech_streaming_event_e; - -typedef enum { - WAKEUP_SPEECH_STATUS_NONE = -1, /**< None */ - WAKEUP_SPEECH_STATUS_STARTED = 1, /**< Event when speech is started */ - WAKEUP_SPEECH_STATUS_COMPLETED = 2, /**< Event when speech is completed (EPD) */ - WAKEUP_SPEECH_STATUS_CANCELED = 3 /**< Event when speech is cancelled */ -} wakeup_service_speech_status_e; - - -typedef void (*wakeup_service_wakeup_event_cb)(wakeup_service_wakeup_event_e event, void* user_data); - -typedef void (*wakeup_service_speech_streaming_cb)(wakeup_service_speech_streaming_event_e event, char* buffer, int len, void *user_data); - -typedef void (*wakeup_service_speech_status_cb)(wakeup_service_speech_status_e status, void *user_data); - - -int wakeup_service_initialize(void); - -int wakeup_service_deinitialize(void); - -int wakeup_service_set_language(const char* language); - -int wakeup_service_set_wakeup_word(const char* language, const char* wakeup_word); - -int wakeup_service_start_recording(void); - -int wakeup_service_stop_recording(void); - -int wakeup_service_cancel_recording(void); - -int wakeup_service_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data); - -int wakeup_service_set_speech_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data); - -int wakeup_service_set_speech_status_callback(wakeup_service_speech_status_cb callback, void* user_data); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _MULTI_WAKEUP_RECOGNIZER_H_ */ diff --git a/src/multi_assistant_service.c b/src/multi_assistant_service.c index 7b20468..f7ad1f6 100644 --- a/src/multi_assistant_service.c +++ b/src/multi_assistant_service.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -72,6 +73,18 @@ int mas_client_send_asr_result(int pid, int event, char* asr_result) return ret; } +Eina_Bool __start_recording(void *data) +{ + (void)data; + + MAS_LOGD("[Enter] Start Recording again"); + int ret = multi_assistant_service_plugin_start_recording(); + if (0 != ret) { + MAS_LOGE("[ERROR] Fail to start recording, ret(%d)", ret); + } + return EINA_FALSE; +} + int mas_client_send_result(int pid, char* display_text, char* utterance_text, char* result_json) { MAS_LOGD("[Enter] pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json); @@ -80,6 +93,8 @@ int mas_client_send_result(int pid, char* display_text, char* utterance_text, ch MAS_LOGE("[ERROR] Fail to send result, ret(%d)", ret); } + ecore_timer_add(0, __start_recording, NULL); + return ret; } diff --git a/src/multi_assistant_service_plugin.c b/src/multi_assistant_service_plugin.c index ce9db1b..ece29e4 100644 --- a/src/multi_assistant_service_plugin.c +++ b/src/multi_assistant_service_plugin.c @@ -46,7 +46,7 @@ static int g_count = 1; #endif -/* + TEST_CODE */ +#if 0 /* + TEST_CODE */ Eina_Bool __send_asr_result(void *data) { MAS_LOGD("[ENTER]"); @@ -75,6 +75,7 @@ Eina_Bool __send_result(void *data) MAS_LOGD("END"); return EINA_FALSE; } +#endif /* -TEST_CODE */ Eina_Bool __request_speech_data(void *data) { @@ -88,7 +89,6 @@ Eina_Bool __request_speech_data(void *data) MAS_LOGD("END"); return EINA_FALSE; } -/* -TEST_CODE */ static void __wakeup_event_cb(wakeup_service_wakeup_event_e event, const char* wakeup_word, void* user_data) { @@ -155,7 +155,7 @@ static void __wakeup_event_cb(wakeup_service_wakeup_event_e event, const char* w } } - /* TEST_CODE */ +#if 0 /* + TEST_CODE */ if (WAKEUP_EVENT_SUCCESS == event) { ecore_thread_main_loop_begin(); ecore_timer_add(1.0, __send_asr_result, "Today's"); @@ -168,9 +168,14 @@ static void __wakeup_event_cb(wakeup_service_wakeup_event_e event, const char* w ecore_thread_main_loop_begin(); ecore_timer_add(3.0, __send_result, "Partly cloudy with temperatures from 75 to 88"); ecore_thread_main_loop_end(); + } +#endif /* - TEST_CODE */ + // if App is already launched, request speech data + /* TO_DO */ + if (WAKEUP_EVENT_SUCCESS == event) { ecore_thread_main_loop_begin(); - ecore_timer_add(4.0, __request_speech_data, NULL); + ecore_timer_add(0, __request_speech_data, NULL); ecore_thread_main_loop_end(); } } @@ -318,9 +323,9 @@ int multi_assistant_service_plugin_cancel_recording(void) int multi_assistant_service_plugin_request_speech_data(void) { - int ret = wakeup_service_cancel_recording(); + int ret = wakeup_service_request_speech_data(); if (0 != ret) { - MAS_LOGE("[ERROR] Fail to cancel recording, ret(%d)", ret); + MAS_LOGE("[ERROR] Fail to request speech data, ret(%d)", ret); } return ret; }