/* get current engine from config */
if (0 == sttd_config_get_default_engine(&cur_engine_uuid)) {
SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] current engine from config : %s", cur_engine_uuid);
- if (NULL != g_engine_info->engine_uuid) {
+ if (NULL != g_engine_info->engine_uuid && NULL != cur_engine_uuid) {
if (!strcmp(g_engine_info->engine_uuid, cur_engine_uuid)) {
is_default_engine = true;
}
}
if (false == is_default_engine) {
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Current engine is not Default engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Current engine is not Default engine");
} else {
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Current engine is Default engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Current engine is Default engine");
}
/* Load engine */
#endif
g_engine_info->is_loaded = true;
- SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent SUCCESS] The %s has been loaded !!!", g_engine_info->engine_name);
+ SECURE_SLOG(LOG_INFO, TAG_STTD, "[Engine Agent SUCCESS] The %s has been loaded !!!", g_engine_info->engine_name);
return 0;
}
return STTD_ERROR_OPERATION_FAILED;
}
+ bool temp = false;
+ if (0 != stt_engine_support_silence(&temp)) {
+ SLOG(LOG_WARN, TAG_STTD, "[WARNING] Fail to get support silence");
+ }
+
*silence = g_engine_info->support_silence_detection;
+ if (temp != *silence) {
+ SLOG(LOG_WARN, TAG_STTD, "[WARNING] Metadata and Engine spec are different (engine:%d) (meta:%d)", temp, *silence);
+ }
return 0;
}
if (engine->support_silence_detection) {
if (2 == silence) {
/* default option set */
- if (g_default_silence_detected != engine->silence_detection) {
+// if (g_default_silence_detected != engine->silence_detection) {
if (0 != stt_engine_set_silence_detection(g_default_silence_detected)) {
SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to set silence detection : %s", g_default_silence_detected ? "true" : "false");
} else {
engine->silence_detection = g_default_silence_detected;
SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Set silence detection : %s", g_default_silence_detected ? "true" : "false");
}
- }
+// }
} else {
if (silence != engine->silence_detection) {
if (0 != stt_engine_set_silence_detection(silence)) {
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "g_default_language %s", g_default_language);
+ SLOG(LOG_INFO, TAG_STTD, "g_default_language %s", g_default_language);
int ret;
char* temp = NULL;
temp = strdup(lang);
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Start engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start engine");
ret = stt_engine_recognize_start(temp, recognition_type, appid, credential, user_param);
if (NULL != temp) free(temp);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Recognition start error(%d)", ret);
- sttd_recorder_destroy();
return ret;
}
return ret;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Create recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Create recorder");
ret = sttd_recorder_create(atype, channels, rate);
if (0 != ret) {
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Start recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start recorder");
int ret;
ret = sttd_recorder_start(uid);
return 0;
}
+int sttd_engine_agent_recognize_start_file(int uid, const char* filepath)
+{
+ if (NULL == g_engine_info) {
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (false == g_engine_info->is_loaded) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start recorder");
+
+ int ret;
+ ret = sttd_recorder_start_file(uid, filepath);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start recorder : result(%d)", ret);
+ stt_engine_recognize_cancel();
+ sttd_recorder_stop_file();
+ return ret;
+ }
+
+ return 0;
+}
+
int sttd_engine_agent_set_recording_data(const void* data, unsigned int length)
{
if (false == g_agent_init) {
return ret;
}
+int sttd_engine_agent_recognize_stop_file()
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL == g_engine_info) {
+ SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] The engine is not valid");
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (false == g_engine_info->is_loaded) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop recorder");
+ int ret;
+ ret = sttd_recorder_stop_file();
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to stop recorder : result(%d)", ret);
+ return ret;
+ }
+
+#ifdef AUDIO_CREATE_ON_START
+ SECURE_SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Destroy recorder");
+ if (0 != sttd_recorder_destroy())
+ SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder");
+#endif
+
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent Success] Stop recorder");
+ return 0;
+}
+
int sttd_engine_agent_recognize_stop_recorder()
{
if (false == g_agent_init) {
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop recorder");
int ret;
ret = sttd_recorder_stop();
if (0 != ret) {
SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder");
#endif
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Stop recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent Success] Stop recorder");
return 0;
}
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop engine");
int ret;
ret = stt_engine_recognize_stop();
return ret;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Stop engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent Success] Stop engine");
return 0;
}
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Cancel engine");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Cancel engine");
int ret;
ret = stt_engine_recognize_cancel();
return ret;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Stop recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Stop recorder");
ret = sttd_recorder_stop();
if (0 != ret) {
}
#ifdef AUDIO_CREATE_ON_START
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Destroy recorder");
if (0 != sttd_recorder_destroy())
SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder");
#endif
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent Success] Cancel recognition");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent Success] Cancel recognition");
return 0;
}
return STTD_ERROR_ENGINE_NOT_FOUND;
}
- SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Default engine uuid(%s)", g_engine_info->engine_uuid);
+ SECURE_SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Default engine uuid(%s)", g_engine_info->engine_uuid);
return 0;
}
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Get engine right : %s", *result ? "true" : "false");
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Get engine right : %s", *result ? "true" : "false");
return 0;
}
+static void __recorder_destroy_by_error_result(void *data)
+{
+ SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Destroy recorder");
+ if (0 != sttd_recorder_destroy())
+ SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder");
+
+ return;
+}
+
int sttd_engine_agent_send_result(stte_result_event_e event, const char* type, const char** result, int result_count,
const char* msg, void* time_info, void *user_data)
{
+ int ret = -1;
+
if (false == g_agent_init) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Result Callback : Not Initialized");
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Server] === Result time callback ===");
+ SLOG(LOG_INFO, TAG_STTD, "[Server] === Result time callback ===");
if (NULL != time_info) {
/* Get the time info */
- int ret = stt_engine_foreach_result_time(time_info, __result_time_cb, NULL);
+ ret = stt_engine_foreach_result_time(time_info, __result_time_cb, NULL);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get time info : %d", ret);
return ret;
}
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Server] ============================");
+ SLOG(LOG_INFO, TAG_STTD, "[Server] ============================");
- g_result_cb(event, type, result, result_count, msg, user_data);
+ ret = g_result_cb(event, type, result, result_count, msg, user_data);
#ifdef AUDIO_CREATE_ON_START
if (event == STTE_RESULT_EVENT_ERROR) {
- SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Destroy recorder");
- if (0 != sttd_recorder_destroy())
- SECURE_SLOG(LOG_WARN, TAG_STTD, "[Engine Agent] Fail to destroy recorder");
+ ecore_main_loop_thread_safe_call_async(__recorder_destroy_by_error_result, NULL);
}
#endif
- return STTD_ERROR_NONE;
+ return ret;
}
int sttd_engine_agent_send_error(stte_error_e error, const char* msg)
/* check uid */
int uid = stt_client_get_current_recognition();
- char* err_msg = strdup(msg);
- int ret = STTE_ERROR_NONE;
+ char* err_msg = NULL;
+ int ret = STTD_ERROR_NONE;
+
+
+ if (NULL != msg) {
+ err_msg = strdup(msg);
+ }
ret = sttdc_send_error_signal(uid, error, err_msg);
if (0 != ret) {
err_msg = NULL;
}
- g_error_cb(error, msg);
+ ret = g_error_cb(error, msg);
return ret;
}
int sttd_engine_agent_send_speech_status(stte_speech_status_e status, void* user_data)
{
+ int ret = STTD_ERROR_NONE;
if (false == g_agent_init) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Silence Callback : Not Initialized");
return STTD_ERROR_OPERATION_FAILED;
}
- g_speech_status_cb(status, user_data);
- return STTD_ERROR_NONE;
+ ret = g_speech_status_cb(status, user_data);
+ return ret;
}
bool __result_time_cb(int index, stte_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data)