From 5abb09628c82ea06e8b4000c413b41fb57a71e1d Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 16 Nov 2022 11:01:57 +0900 Subject: [PATCH] Add to set/get audio type on client side Cause: FFV callback was called, although audio type of sending audio was from Blutetooth. Solution: Provides a way to set audio type on client side. Change-Id: If9d2177cfe7aa61bba9fa0480ea750ea9c0d7ceb --- client/stt.c | 41 ++++++++++++++++++++- client/stt_client.c | 12 +++++- client/stt_client.h | 1 + client/stt_dbus.c | 3 +- client/stt_dbus.h | 2 +- common/stt_engine.c | 17 +++++++++ common/stt_engine.h | 2 + include/stt_internal.h | 53 ++++++++++++++++++++++++++ server/sttd_client_data.c | 51 +++++++++++++++++++++++++ server/sttd_client_data.h | 4 ++ server/sttd_dbus_server.c | 8 ++-- server/sttd_engine_agent.c | 16 ++++++++ server/sttd_engine_agent.h | 2 + server/sttd_recorder.c | 92 +++++++++++++++++++++++++++++++++++++--------- server/sttd_server.c | 9 ++++- server/sttd_server.h | 2 +- 16 files changed, 288 insertions(+), 27 deletions(-) diff --git a/client/stt.c b/client/stt.c index ebf0037..e8dee79 100644 --- a/client/stt.c +++ b/client/stt.c @@ -1441,7 +1441,7 @@ int stt_start(stt_h stt, const char* language, const char* type) } client->internal_state = STT_INTERNAL_STATE_STARTING; - ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid, client->credential); + ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid, client->credential, client->audio_id); if (0 != ret) { SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret)); //LCOV_EXCL_LINE client->internal_state = STT_INTERNAL_STATE_NONE; @@ -2386,4 +2386,43 @@ int stt_recover_system_volume(stt_h stt) return STT_ERROR_NONE; } + +int stt_set_audio_type(stt_h stt, const char *audio_id) +{ + stt_client_s* client = NULL; + int temp = __stt_check_precondition(stt, &client); + if (STT_ERROR_NONE != temp) + return temp; + + RETVM_IF(NULL == audio_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL"); + RETVM_IF(STT_STATE_CREATED != client->current_state && client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created' or 'Ready'", client->current_state); + + SLOG(LOG_INFO, TAG_STTC, "[INFO] Set audio type(%s)", audio_id); + + if (NULL != client->audio_id) { + free(client->audio_id); + client->audio_id = NULL; + } + + client->audio_id = strdup(audio_id); + + return STT_ERROR_NONE; +} + +int stt_get_audio_type(stt_h stt, char **audio_id) +{ + stt_client_s* client = NULL; + int temp = __stt_check_precondition(stt, &client); + if (STT_ERROR_NONE != temp) + return temp; + + RETVM_IF(NULL == audio_id, STT_ERROR_INVALID_PARAMETER, "[ERROR] Input parameter is NULL"); + RETVM_IF(STT_STATE_CREATED != client->current_state && client->current_state != STT_STATE_READY, STT_ERROR_INVALID_STATE, "[ERROR] Current state(%d) is not 'Created' or 'Ready'", client->current_state); + + *audio_id = strdup(client->audio_id); + SLOG(LOG_INFO, TAG_STTC, "[SUCCESS] Get audio type(%s)", *audio_id); + + return STT_ERROR_NONE; +} + //LCOV_EXCL_STOP diff --git a/client/stt_client.c b/client/stt_client.c index 9a07d52..1a3a39a 100644 --- a/client/stt_client.c +++ b/client/stt_client.c @@ -13,6 +13,7 @@ #include "stt_client.h" +#include "stt_internal.h" #define MUTEX_TIME 3 @@ -73,7 +74,11 @@ int stt_client_new(stt_h* stt) client->current_engine_id = NULL; client->credential = NULL; - +#ifdef TV_PRODUCT + client->audio_id = strdup(STT_AUDIO_ID_BLUETOOTH); +#else + client->audio_id = strdup(STT_AUDIO_ID_NONE); +#endif client->silence_supported = false; client->silence = STT_OPTION_SILENCE_DETECTION_AUTO; @@ -136,6 +141,11 @@ int stt_client_destroy(stt_h stt) data->credential = NULL; } + if (NULL != data->audio_id) { + free(data->audio_id); + data->audio_id = NULL; + } + free(data); free(stt); data = NULL; diff --git a/client/stt_client.h b/client/stt_client.h index 12a1b28..5748ca8 100644 --- a/client/stt_client.h +++ b/client/stt_client.h @@ -61,6 +61,7 @@ typedef struct { char* current_engine_id; char* credential; + char* audio_id; /* option */ bool silence_supported; diff --git a/client/stt_dbus.c b/client/stt_dbus.c index 7593bde..1c022a0 100644 --- a/client/stt_dbus.c +++ b/client/stt_dbus.c @@ -1560,7 +1560,7 @@ int stt_dbus_request_unset_stop_sound(unsigned int uid) return ret; } -int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential) +int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* audio_id) { if (NULL == lang || NULL == type || NULL == appid) { SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL"); //LCOV_EXCL_LINE @@ -1597,6 +1597,7 @@ int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, DBUS_TYPE_INT32, &silence, DBUS_TYPE_STRING, &appid, DBUS_TYPE_STRING, &temp, + DBUS_TYPE_STRING, &audio_id, DBUS_TYPE_INVALID); int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_START); diff --git a/client/stt_dbus.h b/client/stt_dbus.h index bba9fcd..980e301 100644 --- a/client/stt_dbus.h +++ b/client/stt_dbus.h @@ -57,7 +57,7 @@ int stt_dbus_request_set_stop_sound(unsigned int uid, const char* file); int stt_dbus_request_unset_stop_sound(unsigned int uid); -int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential); +int stt_dbus_request_start(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* audio_id); int stt_dbus_request_stop(unsigned int uid); diff --git a/common/stt_engine.c b/common/stt_engine.c index 8419313..9da475e 100644 --- a/common/stt_engine.c +++ b/common/stt_engine.c @@ -37,6 +37,7 @@ typedef struct { /* Stt engine */ static sttengine_s *g_engine = NULL; static bool g_is_from_lib = false; +static char* g_audio_type = NULL; /* Callback functions */ static stt_engine_result_cb g_result_cb = NULL; @@ -574,6 +575,17 @@ int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb priv return 0; } +int stt_engine_get_audio_type(char** audio_type) +{ + RETVM_IF(NULL == audio_type, STTE_ERROR_INVALID_PARAMETER, "[Engine ERROR] Invalid Parameter"); + + *audio_type = strdup(g_audio_type); + + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] get audio type(%s)", *audio_type); + + return 0; +} + int stt_engine_set_audio_type(const char* audio_type) { RETVM_IF(NULL == audio_type, STTE_ERROR_INVALID_PARAMETER, "[Engine ERROR] Invalid Parameter"); @@ -586,6 +598,11 @@ int stt_engine_set_audio_type(const char* audio_type) if (0 != ret) { SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set audio type, ret(%d)", ret); } + if (NULL != g_audio_type) { + free(g_audio_type); + g_audio_type = NULL; + } + g_audio_type = strdup(audio_type); } else { SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] There's no set audio function)"); } diff --git a/common/stt_engine.h b/common/stt_engine.h index dff60a5..f1fed01 100644 --- a/common/stt_engine.h +++ b/common/stt_engine.h @@ -95,6 +95,8 @@ int stt_engine_set_private_data_set_cb(stte_private_data_set_cb private_data_set int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb private_data_requested_cb, void* user_data); +int stt_engine_get_audio_type(char** audio_type); + int stt_engine_set_audio_type(const char* audio_type); int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data); diff --git a/include/stt_internal.h b/include/stt_internal.h index e84ff2b..01337a1 100644 --- a/include/stt_internal.h +++ b/include/stt_internal.h @@ -47,6 +47,12 @@ typedef enum { STT_SYSTEM_VOLUME_EVENT_RECOVER /**< Recover system volume event */ } stt_system_volume_event_e; +#define STT_AUDIO_ID_BLUETOOTH "STT_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */ + +#define STT_AUDIO_ID_WIFI "STT_AUDIO_ID_WIFI" /**< Wifi audio id */ + +#define STT_AUDIO_ID_NONE "STT_AUDIO_ID_NONE" /**< None audio id */ + /** * @brief Sets server STT. * @details Using this API, the application can set server STT with a @a key as a @a user_data @@ -182,6 +188,53 @@ int stt_change_system_volume(stt_h stt, stt_system_volume_event_e volume_event); */ int stt_recover_system_volume(stt_h stt); +/** + * @brief Sets a type of audio-in. + * @since_tizen 7.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] audio_id The audio type (e.g. #STT_AUDIO_ID_BLUETOOTH or #STT_AUDIO_ID_FFV) + * + * @return 0 on success, otherwise a negative error value + * @retval #STT_ERROR_NONE Successful + * @retval #STT_ERROR_NOT_SUPPORTED STT not supported + * @retval #STT_ERROR_PERMISSION_DENIED Permission denied + * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STT_ERROR_INVALID_STATE Invalid state + * @retval #STT_ERROR_OPERATION_FAILED Operation failure + * + * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY. + * + * @see stt_get_audio_type() + */ +int stt_set_audio_type(stt_h stt, const char *audio_id); + +/** + * @brief Gets a type of audio-in. + * @since_tizen 7.0 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @remarks audio_id must be released using free() when it is no longer required. + * + * @param[out] audio_id The audio id (e.g. #STT_AUDIO_ID_BLUETOOTH or USB device ID) + * + * @return 0 on success, otherwise a negative error value + * @retval #STT_ERROR_NONE Successful + * @retval #STT_ERROR_NOT_SUPPORTED STT not supported + * @retval #STT_ERROR_PERMISSION_DENIED Permission denied + * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STT_ERROR_INVALID_STATE Invalid state + * + * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY. + * + * @see stt_set_audio_type() + */ +int stt_get_audio_type(stt_h stt, char **audio_id); + #ifdef __cplusplus } #endif diff --git a/server/sttd_client_data.c b/server/sttd_client_data.c index 1ae94ca..21b6d05 100644 --- a/server/sttd_client_data.c +++ b/server/sttd_client_data.c @@ -479,3 +479,54 @@ bool stt_client_get_app_agreed(unsigned int uid) hnd = tmp->data; return hnd->app_agreed; } + +int sttd_client_get_audio_id(unsigned int uid, char** audio_id) +{ + if (NULL == audio_id) { + SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] audio_id is NULL"); + return STTD_ERROR_INVALID_PARAMETER; + } + + GSList *tmp = NULL; + client_info_s* hnd = NULL; + + tmp = __client_get_item(uid); + if (NULL == tmp) { + return STTD_ERROR_INVALID_PARAMETER; + } + + hnd = tmp->data; + if (NULL != hnd->audio_id) { + *audio_id = strdup(hnd->audio_id); + } else { + *audio_id = NULL; + } + + return 0; +} + +int sttd_client_set_audio_id(unsigned int uid, const char* audio_id) +{ + GSList *tmp = NULL; + client_info_s* hnd = NULL; + + tmp = __client_get_item(uid); + if (NULL == tmp) { + SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%u) is NOT valid", uid); + return STTD_ERROR_INVALID_PARAMETER; + } + + hnd = tmp->data; + if (NULL != hnd->audio_id) { + free(hnd->audio_id); + } + + if (NULL != audio_id) { + hnd->audio_id = strdup(audio_id); + SLOG(LOG_DEBUG, TAG_STTD, "[Client Data] Audio ID : %s", hnd->audio_id); + } else { + hnd->audio_id = NULL; + } + + return 0; +} \ No newline at end of file diff --git a/server/sttd_client_data.h b/server/sttd_client_data.h index 05eed26..0b1e2f0 100644 --- a/server/sttd_client_data.h +++ b/server/sttd_client_data.h @@ -34,6 +34,7 @@ typedef struct { unsigned int uid; char* start_beep; char* stop_beep; + char* audio_id; app_state_e state; /* Ecore_Timer* timer; */ @@ -95,6 +96,9 @@ int stt_client_set_app_agreed(unsigned int uid); bool stt_client_get_app_agreed(unsigned int uid); +int sttd_client_get_audio_id(unsigned int uid, char** audio_id); + +int sttd_client_set_audio_id(unsigned int uid, const char* audio_id); #ifdef __cplusplus } diff --git a/server/sttd_dbus_server.c b/server/sttd_dbus_server.c index 5dc1270..f90eee6 100644 --- a/server/sttd_dbus_server.c +++ b/server/sttd_dbus_server.c @@ -789,6 +789,7 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) char* appid; int silence; char* credential; + char* audio_id; int ret = STTD_ERROR_OPERATION_FAILED; dbus_message_get_args(msg, &err, @@ -798,6 +799,7 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) DBUS_TYPE_INT32, &silence, DBUS_TYPE_STRING, &appid, DBUS_TYPE_STRING, &credential, + DBUS_TYPE_STRING, &audio_id, DBUS_TYPE_INVALID); SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start"); @@ -807,9 +809,9 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg) dbus_error_free(&err); ret = STTD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) credential(%s)" - , uid, lang, type, silence, appid, credential); - ret = sttd_server_start(uid, lang, type, silence, appid, credential); + SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) credential(%s) audio_id(%s)" + , uid, lang, type, silence, appid, credential, audio_id); + ret = sttd_server_start(uid, lang, type, silence, appid, credential, audio_id); } if (0 <= ret) { diff --git a/server/sttd_engine_agent.c b/server/sttd_engine_agent.c index 2d4dc52..631ff48 100644 --- a/server/sttd_engine_agent.c +++ b/server/sttd_engine_agent.c @@ -1000,6 +1000,22 @@ static int __log_enginelist() return 0; } +int sttd_engine_agent_get_audio_type(char** audio_type) +{ + int tmp = __sttd_engine_agent_check_precondition(); + if (STTD_ERROR_NONE != tmp) + return tmp; + + SLOG(LOG_INFO, TAG_STTD, "[Server Info] Get audio type"); + + int ret; + ret = stt_engine_get_audio_type(audio_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] get audio type error(%d)", ret); + } + return ret; +} + int sttd_engine_agent_set_audio_type(const char* audio_type) { int tmp = __sttd_engine_agent_check_precondition(); diff --git a/server/sttd_engine_agent.h b/server/sttd_engine_agent.h index e77c206..d5992a0 100644 --- a/server/sttd_engine_agent.h +++ b/server/sttd_engine_agent.h @@ -120,6 +120,8 @@ int sttd_engine_agent_send_error(stte_error_e error, const char* msg); int sttd_engine_agent_send_speech_status(stte_speech_status_e status, void* user_data); +int sttd_engine_agent_get_audio_type(char** audio_type); + int sttd_engine_agent_set_audio_type(const char* audio_type); diff --git a/server/sttd_recorder.c b/server/sttd_recorder.c index 321e5d6..94ea042 100644 --- a/server/sttd_recorder.c +++ b/server/sttd_recorder.c @@ -76,8 +76,6 @@ static int g_buffer_count; static int g_stream_focus_id; -static bool g_is_set_audio_type = false; - #ifdef TV_FFV_MODE farfield_voice_h g_farfieldvoice_h = NULL; #endif @@ -133,9 +131,16 @@ static void _bt_hid_audio_data_receive_cb(bt_hid_voice_data_s *voice_data, void } if (NULL != g_audio_cb) { - if (false == g_is_set_audio_type) { - sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_BLUETOOTH); - g_is_set_audio_type = true; + char* audio_type = NULL; + int ret = sttd_engine_agent_get_audio_type(&audio_type); + if (STTD_ERROR_NONE == ret) { + if (0 != strncmp(audio_type, STTE_AUDIO_ID_BLUETOOTH, strlen(audio_type))) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder] BT callback is not mapped with audio_type(%s)", audio_type); + free(audio_type); + return; + } + free(audio_type); + audio_type = NULL; } if (0 != g_audio_cb((void*)voice_data->audio_buf, (unsigned int)voice_data->length)) { @@ -191,9 +196,16 @@ static void _ffv_audio_function_cb(void* data, unsigned int length, void* user_d return; } - if (false == g_is_set_audio_type) { - sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_FFV); - g_is_set_audio_type = true; + char* audio_type = NULL; + int ret = sttd_engine_agent_get_audio_type(&audio_type); + if (STTD_ERROR_NONE == ret) { + if (0 != strncmp(audio_type, STTE_AUDIO_ID_FFV, strlen(audio_type))) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder] FFV callback is not mapped with audio_type(%s)", audio_type); + free(audio_type); + return; + } + free(audio_type); + audio_type = NULL; } if (0 == g_buffer_count % 50) { @@ -297,9 +309,6 @@ int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interr g_farfieldvoice_h = farfield_voice_init(); if (NULL == g_farfieldvoice_h) { SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to init farfield_voice_init"); - } else { - SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Register farfield voice audio callback"); - farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL); } #endif @@ -339,6 +348,12 @@ int sttd_recorder_deinitialize() g_recorder = NULL; } + int ret = sttd_engine_agent_set_audio_type(NULL); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to set audio type(NULL)"); + return ret; + } + #ifdef __UNUSED_CODES__ /* Remove all recorder */ GSList *iter = NULL; @@ -430,11 +445,6 @@ int sttd_recorder_create(stte_audio_type_e type, int channel, unsigned int sampl SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to create audio handle : %d", ret); return STTD_ERROR_OPERATION_FAILED; } -#else - if (BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) { - SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()"); - return STTD_ERROR_OPERATION_FAILED; - } #endif stt_recorder_s* recorder; @@ -639,8 +649,55 @@ int sttd_recorder_start(unsigned int uid, const char* appid) if (STTD_RECORDER_STATE_RECORDING == g_recorder_state) return 0; + char* client_audio_id = NULL; + int ret = sttd_client_get_audio_id(uid, &client_audio_id); + if (STTD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret); + return ret; + } + + char* engine_audio_id = NULL; + ret = sttd_engine_agent_get_audio_type(&engine_audio_id); + if (STTD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret); + free(client_audio_id); + return ret; + } + + if (0 != strncmp(client_audio_id, engine_audio_id, strlen(client_audio_id))) { + ret = sttd_engine_agent_set_audio_type(client_audio_id); + if (STTD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to get audio id: %d", ret); + free(client_audio_id); + free(engine_audio_id); + return ret; + } + +#ifdef TV_FFV_MODE + if (0 == strncmp(client_audio_id, STTE_AUDIO_ID_FFV, strlen(client_audio_id))) { + if (NULL != g_farfieldvoice_h) { + SLOG(LOG_INFO, TAG_STTD, "[Recorder INFO] Register farfield voice audio callback"); + farfield_voice_register_audio_cb(g_farfieldvoice_h, _ffv_audio_function_cb, NULL); + } + } +#endif +#ifdef TV_BT_MODE + if (0 == strncmp(client_audio_id, STTE_AUDIO_ID_BLUETOOTH, strlen(client_audio_id))) { + if (BT_ERROR_NONE != bt_hid_set_audio_data_receive_cb(_bt_hid_audio_data_receive_cb, NULL)) { + SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail bt_hid_set_audio_data_receive_cb()"); + return STTD_ERROR_OPERATION_FAILED; + } + } +#endif + } + + free(client_audio_id); + free(engine_audio_id); + client_audio_id = NULL; + engine_audio_id = NULL; + #ifndef TV_BT_MODE - int ret = -1; + ret = -1; /* Check engine id is valid */ if (NULL == g_recorder) { SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid"); @@ -742,7 +799,6 @@ int sttd_recorder_stop() SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Enter critical section"); pthread_mutex_lock(&sttd_audio_in_handle_mutex); - g_is_set_audio_type = false; sttd_engine_agent_set_audio_type(STTE_AUDIO_ID_NONE); /* Check engine id is valid */ diff --git a/server/sttd_server.c b/server/sttd_server.c index 812aca3..b7cdc6d 100644 --- a/server/sttd_server.c +++ b/server/sttd_server.c @@ -1195,7 +1195,7 @@ static int __sttd_server_check_precondition_to_start(unsigned int uid, const cha return ret; } -int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential) +int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* audio_id) { if (NULL == lang || NULL == recognition_type) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL"); @@ -1226,6 +1226,13 @@ int sttd_server_start(unsigned int uid, const char* lang, const char* recognitio return ret; } + ret = sttd_client_set_audio_id(uid, audio_id); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to set audio_id(%s)", audio_id); + if (NULL != sound) free(sound); + return ret; + } + if (0 != stt_client_set_current_recognition(uid)) { SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Current STT is busy because of recording or processing"); if (NULL != sound) free(sound); diff --git a/server/sttd_server.h b/server/sttd_server.h index 413ca0c..114e4b7 100644 --- a/server/sttd_server.h +++ b/server/sttd_server.h @@ -70,7 +70,7 @@ int sttd_server_set_stop_sound(unsigned int uid, const char* file); int sttd_server_get_audio_volume(unsigned int uid, float* current_volume); -int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential); +int sttd_server_start(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* audio_id); int sttd_server_stop(unsigned int uid); -- 2.7.4