int mas_client_send_assistant_specific_command(int pid, const char *command);
-int mas_client_update_result_state(int pid, int state);
+int mas_client_update_recognition_result(int pid, int result);
int mas_ui_client_initialize(int pid);
int multi_assistant_service_plugin_change_system_volume(const char *appid, int event);
-int multi_assistant_service_plugin_update_result_state(const char* appid, int state);
+int multi_assistant_service_plugin_update_recognition_result(const char* appid, int result);
int multi_assistant_service_plugin_process_event(int event, void* data, int len);
typedef int (*wakeup_manager_send_assistant_specific_command)(const char* appid, const char* command);
#define MA_WAKEUP_MANAGER_FUNC_CHANGE_SYSTEM_VOLUME "wakeup_manager_change_system_volume"
typedef int (*wakeup_manager_change_system_volume)(const char* appid, int event);
-#define MA_WAKEUP_MANAGER_FUNC_UPDATE_RESULT_STATE "wakeup_manager_update_result_state"
-typedef int (*wakeup_manager_update_result_state)(const char* appid, int state);
+#define MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT "wakeup_manager_update_recognition_result"
+typedef int (*wakeup_manager_update_recognition_result)(const char* appid, int result);
#define MA_WAKEUP_MANAGER_FUNC_PROCESS_EVENT "wakeup_manager_process_event"
typedef int (*wakeup_manager_process_event)(int event, void* data, int len);
#define MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA "wakeup_manager_start_streaming_utterance_data"
wakeup_manager_update_voice_feedback_state update_voice_feedback_state;
wakeup_manager_send_assistant_specific_command send_assistant_specific_command;
wakeup_manager_change_system_volume change_system_volume;
- wakeup_manager_update_result_state update_result_state;
+ wakeup_manager_update_recognition_result update_recognition_result;
wakeup_manager_process_event process_event;
wakeup_manager_start_streaming_utterance_data start_streaming_utterance_data;
wakeup_manager_stop_streaming_utterance_data stop_streaming_utterance_data;
} wakeup_asr_result_event_e;
-typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info event, const char* wakeup_word, void* user_data);
+typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info wakeup_info, const char* wakeup_word, void* user_data);
typedef void (*wakeup_service_speech_streaming_cb)(wakeup_speech_streaming_event_e event, unsigned char* buffer, int len, void *user_data);
typedef int (*wakeup_engine_set_language)(const char* language);
#define MA_WAKEUP_ENGINE_FUNC_UPDATE_MANAGER_STATE "wakeup_engine_update_manager_state"
typedef int (*wakeup_engine_update_manager_state)(wakeup_manager_state_e state);
+#define MA_WAKEUP_ENGINE_FUNC_UPDATE_RECOGNITION_RESULT "wakeup_engine_update_recognition_result"
+typedef int (*wakeup_engine_update_recognition_result)(const char* appid, int result);
#define MA_WAKEUP_ENGINE_FUNC_SET_AUDIO_FORMAT "wakeup_engine_set_audio_format"
typedef int (*wakeup_engine_set_audio_format)(int rate, int channel, int audio_type);
#define MA_WAKEUP_ENGINE_FUNC_GET_AUDIO_FORMAT "wakeup_engine_get_audio_format"
wakeup_engine_add_language add_language;
wakeup_engine_set_language set_language;
wakeup_engine_update_manager_state update_manager_state;
+ wakeup_engine_update_recognition_result update_recognition_result;
wakeup_engine_set_audio_format set_audio_format;
wakeup_engine_get_audio_format get_audio_format;
wakeup_engine_feed_audio_data feed_audio_data;
{
public:
virtual ~IEngineEventObserver() = default;
- virtual bool on_wakeup_event(string engine_name, wakeup_event_info info) = 0;
+ virtual bool on_wakeup_event(string engine_name, wakeup_event_info wakeup_info) = 0;
virtual bool on_speech_status(string engine_name, wakeup_service_speech_status_e status) = 0;
virtual bool on_error(string engine_name, int error_code, string error_message) = 0;
virtual bool on_audio_data_require_status(string engine_name, bool require) = 0;
void unsubscribe(IEngineEventObserver *observer);
bool get_audio_data_required();
- void set_selected_wakeup_info(wakeup_event_info info);
+ void set_selected_wakeup_info(wakeup_event_info wakeup_info);
bool set_language(string language);
void set_assistant_activated(string appid, bool activated);
void stop_streaming_current_utterance_data();
void update_manager_state(wakeup_manager_state_e state);
+ void update_recognition_result(string appid, int result);
void engine_add_target_assistant(string engine_name, string appid);
void engine_add_wakeup_word(string appid, string wakeup_word, string language);
void engine_set_assistant_specific_command(string appid, string command);
void engine_feed_audio_data(long time, void* data, int len);
- bool on_wakeup_event(string engine_name, wakeup_event_info info);
+ bool on_wakeup_event(string engine_name, wakeup_event_info wakeup_info);
bool on_speech_status(string engine_name, wakeup_service_speech_status_e status);
bool on_error(string engine_name, int error_code, string error_message);
bool on_audio_data_require_status(string engine_name, bool require);
class IWakeupEventObserver {
public:
virtual ~IWakeupEventObserver() = default;
- virtual void on_wakeup(wakeup_event_info info) = 0;
+ virtual void on_wakeup(wakeup_event_info wakeup_info) = 0;
virtual void on_streaming_audio_data(
wakeup_speech_streaming_event_e event, void* buffer, unsigned int len) = 0;
};
bool update_voice_feedback_state(string appid, bool state);
bool send_assistant_specific_command(string appid, string command);
bool change_system_volume(string appid, int event);
- bool update_result_state(string appid, int state);
+ bool update_recognition_result(string appid, int result);
bool process_event(ma_plugin_event_e event, void* data, int len);
bool get_audio_format(int* rate, int* channel, int* audio_type);
bool get_audio_source_type(char** type);
CWakeupSettings* get_wakeup_settings();
vector<IWakeupEventObserver*> get_observers();
- void set_last_wakeup_event_info(wakeup_event_info info);
+ void set_last_wakeup_event_info(wakeup_event_info wakeup_info);
bool change_manager_state(wakeup_manager_state_e state);
wakeup_manager_state_e get_manager_state();
class CEngineEventObserver : public IEngineEventObserver
{
public:
- bool on_wakeup_event(string engine_name, wakeup_event_info info) override;
+ bool on_wakeup_event(string engine_name, wakeup_event_info wakeup_info) override;
bool on_speech_status(string engine_name, wakeup_service_speech_status_e status) override;
bool on_error(string engine_name, int error_code, string error_message) override;
bool on_audio_data_require_status(string engine_name, bool require) override;
class CPolicyEventObserver : public IPolicyEventObserver
{
public:
- void on_wakeup(wakeup_event_info info) override;
+ void on_wakeup(wakeup_event_info wakeup_info) override;
void set_wakeup_manager(CWakeupManager *manager) { mWakeupManager = manager; }
private:
WAKEUP_MANAGER_STATE_VOICE_FEEDBACK = 4
} wakeup_manager_state_e;
-typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info info, void* user_data);
+typedef void (*wakeup_service_wakeup_event_cb)(wakeup_event_info wakeup_info, void* user_data);
typedef void (*wakeup_service_speech_streaming_cb)(wakeup_speech_streaming_event_e event, void* buffer, int len, void *user_data);
EXPORT_API int wakeup_manager_change_system_volume(const char *appid, int event);
-EXPORT_API int wakeup_manager_update_result_state(const char *appid, int state);
+EXPORT_API int wakeup_manager_update_recognition_result(const char *appid, int result);
EXPORT_API int wakeup_manager_process_event(int event, void* data, int len);
{
public:
virtual ~IPolicyEventObserver() = default;
- virtual void on_wakeup(wakeup_event_info info) = 0;
+ virtual void on_wakeup(wakeup_event_info wakeup_info) = 0;
};
class CWakeupPolicyImpl;
void subscribe(IPolicyEventObserver *observer);
void unsubscribe(IPolicyEventObserver *observer);
- virtual void wakeup_candidate(wakeup_event_info info) = 0;
+ virtual void wakeup_candidate(wakeup_event_info wakeup_info) = 0;
protected:
unique_ptr<CWakeupPolicyImpl> mImpl;
};
void set_assistant_priority(string appid, int priority);
void set_delay(float seconds);
- void wakeup_candidate(wakeup_event_info info);
+ void wakeup_candidate(wakeup_event_info wakeup_info);
void timer_expired();
private:
typedef struct {
void subscribe(IPolicyEventObserver *observer);
void unsubscribe(IPolicyEventObserver *observer);
- void wakeup(wakeup_event_info info);
+ void wakeup(wakeup_event_info wakeup_info);
private:
vector<IPolicyEventObserver*> mObservers;
};
void CWakeupEngineManager::set_selected_wakeup_info(wakeup_event_info wakeup_info)
{
+ mSelectedEngine = nullptr;
for (const auto& info : mEngineInfo) {
string appid = string{wakeup_info.wakeup_appid};
bool found = contains(info.assistant_list, appid);
}
}
+void CWakeupEngineManager::update_recognition_result(string appid, int result)
+{
+ if (mSelectedEngine) {
+ if (mSelectedEngine->interface.update_recognition_result) {
+ mSelectedEngine->interface.update_recognition_result(appid.c_str(), result);
+ }
+ }
+}
+
void CWakeupEngineManager::engine_add_target_assistant(string engine_name, string appid)
{
const auto& iter = find_if(mEngineInfo.begin(), mEngineInfo.end(),
info.interface.update_manager_state =
(wakeup_engine_update_manager_state)dlsym(info.engine_handle,
MA_WAKEUP_ENGINE_FUNC_UPDATE_MANAGER_STATE);
+ info.interface.update_recognition_result =
+ (wakeup_engine_update_recognition_result)dlsym(info.engine_handle,
+ MA_WAKEUP_ENGINE_FUNC_UPDATE_RECOGNITION_RESULT);
info.interface.set_audio_format =
(wakeup_engine_set_audio_format)dlsym(info.engine_handle,
MA_WAKEUP_ENGINE_FUNC_SET_AUDIO_FORMAT);
return true;
}
-static bool initialize_wakeup_event_info(wakeup_event_info* info)
+static bool initialize_wakeup_event_info(wakeup_event_info* wakeup_info)
{
bool ret = false;
- if (info) {
+ if (wakeup_info) {
ret = true;
- info->wakeup_appid = nullptr;
- info->wakeup_word = nullptr;
- info->wakeup_language = nullptr;
- info->wakeup_voice_id = nullptr;
- info->wakeup_engine = nullptr;
- info->wakeup_confidence_score = 0.0f;
+ wakeup_info->wakeup_appid = nullptr;
+ wakeup_info->wakeup_word = nullptr;
+ wakeup_info->wakeup_language = nullptr;
+ wakeup_info->wakeup_voice_id = nullptr;
+ wakeup_info->wakeup_engine = nullptr;
+ wakeup_info->wakeup_confidence_score = 0.0f;
- info->wakeup_start_time = 0;
- info->wakeup_end_time = 0L;
- info->wakeup_time_valid = false;
+ wakeup_info->wakeup_start_time = 0;
+ wakeup_info->wakeup_end_time = 0L;
+ wakeup_info->wakeup_time_valid = false;
- info->extra_data = nullptr;
- info->extra_data_length = 0;
- info->extra_data_description = nullptr;
+ wakeup_info->extra_data = nullptr;
+ wakeup_info->extra_data_length = 0;
+ wakeup_info->extra_data_description = nullptr;
}
return ret;
}
return ret;
}
-bool CWakeupManager::update_result_state(string appid, int state)
+bool CWakeupManager::update_recognition_result(string appid, int result)
{
MWR_LOGD("[ENTER]");
- if (0 == state) {
- if (WAKEUP_MANAGER_STATE_PROCESSING == mWakeupManagerState ||
- WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) {
- change_manager_state(WAKEUP_MANAGER_STATE_LISTENING);
- }
+ mWakeupEngineManager.update_recognition_result(appid, result);
+ if (WAKEUP_MANAGER_STATE_PROCESSING == mWakeupManagerState ||
+ WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) {
+ change_manager_state(WAKEUP_MANAGER_STATE_LISTENING);
}
MWR_LOGD("[END]");
return true;
/* Wakeup default assistant */
/* TODO: apply conversation timeout for selecting assistant here */
- wakeup_event_info event_info;
- initialize_wakeup_event_info(&event_info);
+ wakeup_event_info wakeup_info;
+ initialize_wakeup_event_info(&wakeup_info);
/* Make sure to use background data */
- event_info.wakeup_time_valid = true;
- event_info.wakeup_end_time = get_current_milliseconds_after_epoch();
- event_info.wakeup_engine = WAKEUP_ENGINE_VOICE_KEY;
+ wakeup_info.wakeup_time_valid = true;
+ wakeup_info.wakeup_end_time = get_current_milliseconds_after_epoch();
+ wakeup_info.wakeup_engine = WAKEUP_ENGINE_VOICE_KEY;
string appid = mWakeupSettings.get_default_assistant_appid();
- event_info.wakeup_appid = appid.c_str();
- MWR_LOGD("wakeup_appid : %s", event_info.wakeup_appid);
+ wakeup_info.wakeup_appid = appid.c_str();
+ MWR_LOGD("wakeup_appid : %s", wakeup_info.wakeup_appid);
- set_last_wakeup_event_info(event_info);
+ set_last_wakeup_event_info(wakeup_info);
+ mWakeupEngineManager.set_selected_wakeup_info(wakeup_info);
for (const auto& observer : mObservers) {
- observer->on_wakeup(event_info);
+ observer->on_wakeup(wakeup_info);
}
}
} else if (MA_PLUGIN_EVENT_VOICE_KEY_RELEASED_AFTER_PUSH == event) {
return mObservers;
}
-void CWakeupManager::set_last_wakeup_event_info(wakeup_event_info info)
+void CWakeupManager::set_last_wakeup_event_info(wakeup_event_info wakeup_info)
{
- mLastWakeupEventInfo = info;
+ mLastWakeupEventInfo = wakeup_info;
}
static Eina_Bool streaming_duration_expired(void *data)
mAudioManager.feed_audio_data(event, buffer, len);
}
-bool CWakeupManager::CEngineEventObserver::on_wakeup_event(string engine_name, wakeup_event_info info)
+bool CWakeupManager::CEngineEventObserver::on_wakeup_event(string engine_name, wakeup_event_info wakeup_info)
{
MWR_LOGD("[ENTER]");
if (nullptr == mWakeupManager) return false;
CWakeupPolicy* policy = mWakeupManager->get_wakeup_policy();
if (policy) {
- policy->wakeup_candidate(info);
+ policy->wakeup_candidate(wakeup_info);
}
return true;
}
return true;
}
-void CWakeupManager::CPolicyEventObserver::on_wakeup(wakeup_event_info info)
+void CWakeupManager::CPolicyEventObserver::on_wakeup(wakeup_event_info wakeup_info)
{
if (nullptr == mWakeupManager) return;
mWakeupManager->stop_streaming_utterance_data();
CWakeupEngineManager *engine_manager = mWakeupManager->get_engine_manager();
if (nullptr == engine_manager) return;
- mWakeupManager->set_last_wakeup_event_info(info);
- engine_manager->set_selected_wakeup_info(info);
+ mWakeupManager->set_last_wakeup_event_info(wakeup_info);
+ engine_manager->set_selected_wakeup_info(wakeup_info);
vector<IWakeupEventObserver*> observers = mWakeupManager->get_observers();
for (const auto& observer : observers) {
- observer->on_wakeup(info);
+ observer->on_wakeup(wakeup_info);
}
}
class CWakeupEventObserver : public IWakeupEventObserver
{
- void on_wakeup(wakeup_event_info info) override;
+ void on_wakeup(wakeup_event_info wakeup_info) override;
void on_streaming_audio_data(
wakeup_speech_streaming_event_e event, void* buffer, unsigned int len) override;
};
return 0;
}
-int wakeup_manager_update_result_state(const char* appid, int state)
+int wakeup_manager_update_recognition_result(const char* appid, int result)
{
MWR_LOGD("[ENTER]");
} else {
appid_string = appid;
}
- g_wakeup_manager.update_result_state(appid_string, state);
+ g_wakeup_manager.update_recognition_result(appid_string, result);
MWR_LOGD("[END]");
return 0;
return 0;
}
-void CWakeupEventObserver::on_wakeup(wakeup_event_info info)
+void CWakeupEventObserver::on_wakeup(wakeup_event_info wakeup_info)
{
if (NULL != g_wakeup_event_cb) {
- g_wakeup_event_cb(info, g_wakeup_event_user_data);
+ g_wakeup_event_cb(wakeup_info, g_wakeup_event_user_data);
}
}
}
}
-void CWakeupPolicyImpl::wakeup(wakeup_event_info info)
+void CWakeupPolicyImpl::wakeup(wakeup_event_info wakeup_info)
{
for (const auto& observer : mObservers) {
if (observer) {
- observer->on_wakeup(info);
+ observer->on_wakeup(wakeup_info);
}
}
}
return ECORE_CALLBACK_CANCEL;
}
-void CWakeupPolicyDefault::wakeup_candidate(wakeup_event_info info)
+void CWakeupPolicyDefault::wakeup_candidate(wakeup_event_info wakeup_info)
{
- mWakeupInfos.push_back(info);
+ mWakeupInfos.push_back(wakeup_info);
if (nullptr == mTimer) {
ecore_thread_main_loop_begin();
mTimer = ecore_timer_add(mDelaySeconds, timer_func, this);
MAS_LOGE("[ERROR] Fail to send result, ret(%d)", ret);
}
- multi_assistant_service_plugin_update_result_state(NULL, MA_RECOGNITION_RESULT_EVENT_SUCCESS);
+ multi_assistant_service_plugin_update_recognition_result(NULL, MA_RECOGNITION_RESULT_EVENT_SUCCESS);
return ret;
}
MAS_LOGE("[ERROR] Fail to send recognition result, ret(%d)", ret);
}
- multi_assistant_service_plugin_update_result_state(NULL, result);
+ multi_assistant_service_plugin_update_recognition_result(NULL, result);
return ret;
}
return 0;
}
-int mas_client_update_result_state(int pid, int state)
+int mas_client_update_recognition_result(int pid, int state)
{
- multi_assistant_service_plugin_update_result_state(NULL, state);
+ multi_assistant_service_plugin_update_recognition_result(NULL, state);
return 0;
}
return ECORE_CALLBACK_CANCEL;
}
-static void __wakeup_event_cb(wakeup_event_info event, void* user_data)
+static void __wakeup_event_cb(wakeup_event_info wakeup_info, void* user_data)
{
- MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", event.wakeup_word);
+ MAS_LOGD("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
int ret = -1;
if (is_ui_panel_enabled()) {
ecore_thread_main_loop_end();
}
#endif /* - TEST_CODE */
- if (event.wakeup_appid) {
+ if (wakeup_info.wakeup_appid) {
ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, __launch_assistant_by_wakeup_appid_timer, (void*)strdup(event.wakeup_appid));
+ ecore_timer_add(0.0f, __launch_assistant_by_wakeup_appid_timer, (void*)strdup(wakeup_info.wakeup_appid));
ecore_thread_main_loop_end();
- } else if (event.wakeup_word) {
+ } else if (wakeup_info.wakeup_word) {
ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, __launch_assistant_by_wakeup_word_timer, (void*)strdup(event.wakeup_word));
+ ecore_timer_add(0.0f, __launch_assistant_by_wakeup_word_timer, (void*)strdup(wakeup_info.wakeup_word));
ecore_thread_main_loop_end();
}
_wakeup_manager_interface.change_system_volume =
(wakeup_manager_change_system_volume)dlsym(g_handle,
MA_WAKEUP_MANAGER_FUNC_CHANGE_SYSTEM_VOLUME);
- _wakeup_manager_interface.update_result_state =
- (wakeup_manager_update_result_state)dlsym(g_handle,
- MA_WAKEUP_MANAGER_FUNC_UPDATE_RESULT_STATE);
+ _wakeup_manager_interface.update_recognition_result =
+ (wakeup_manager_update_recognition_result)dlsym(g_handle,
+ MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
_wakeup_manager_interface.process_event =
(wakeup_manager_process_event)dlsym(g_handle,
MA_WAKEUP_MANAGER_FUNC_PROCESS_EVENT);
return ret;
}
-int multi_assistant_service_plugin_update_result_state(const char* appid, int state)
+int multi_assistant_service_plugin_update_recognition_result(const char* appid, int state)
{
int ret = -1;
if (NULL != g_handle) {
- wakeup_manager_update_result_state func = _wakeup_manager_interface.update_result_state;
+ wakeup_manager_update_recognition_result func = _wakeup_manager_interface.update_recognition_result;
if (NULL == func) {
- MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RESULT_STATE);
+ MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_UPDATE_RECOGNITION_RESULT);
} else {
ret = func(appid, state);
if (0 != ret) {