From 3463a64df2477bb90322f0f044e10ac4bee7faf2 Mon Sep 17 00:00:00 2001 From: "sungwook79.park" Date: Fri, 3 May 2024 08:12:01 +0900 Subject: [PATCH] Add tts engine api for synthesis parameter instead of changing ttsd_engine_start_synthesis api Change-Id: I1da7268eb24a71dadc89a91548a9bf1ccc334328 Signed-off-by: sungwook79.park --- include/ttse.h | 20 +++++++++++++++--- server/ttsd_engine_agent.c | 52 +++++++++++++++++++++++++++++++++++----------- server/ttsd_engine_agent.h | 4 +++- server/ttsd_main.h | 1 + server/ttsd_server.c | 15 +++++++++++-- 5 files changed, 74 insertions(+), 18 deletions(-) diff --git a/include/ttse.h b/include/ttse.h index 62ee3df..1e5b0a4 100755 --- a/include/ttse.h +++ b/include/ttse.h @@ -208,6 +208,21 @@ typedef int (*ttse_set_pitch_cb)(int pitch); /** +* @brief Called when the engine service user sets the personal tts id of TTS engine. +* @since_tizen 9.0 +* @remarks This callback function is mandatory and must be registered using ttse_main(). +* @param[in] ptts_id The personal tts id +* @return @c 0 on success, +* otherwise a negative error value +* @retval #TTSE_ERROR_NONE Successful +* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTSE_ERROR_INVALID_STATE Not initialized +* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure +*/ +typedef int (*ttse_set_personal_tts_id)(const char* ptts_id); + + +/** * @brief Called when the engine service user requests to load the corresponding voice type for the first time. * @since_tizen 3.0 * @remarks This callback function is mandatory and must be registered using ttse_main(). @@ -291,9 +306,7 @@ typedef bool (*ttse_need_app_credential_cb)(void); * For example, "ko_KR" for Korean, "en_US" for American English * @param[in] type The voice type * @param[in] text Texts -* @param[in] ptts_id The id of personal TTS * @param[in] speed The speed of speaking -* @param[in] pitch The pitch of speaking * @param[in] appid The Application ID * @param[in] credential The credential granted to the application * @param[in] user_data The user data which must be passed to ttse_send_result() @@ -311,7 +324,7 @@ typedef bool (*ttse_need_app_credential_cb)(void); * @see ttse_cancel_synthesis_cb() * @see ttse_need_app_credential_cb() */ -typedef int (*ttse_start_synthesis_cb)(const char* language, int type, const char* text, const char* ptts_id, int speed, int pitch, const char* appid, const char* credential, void* user_data); +typedef int (*ttse_start_synthesis_cb)(const char* language, int type, const char* text, int speed, const char* appid, const char* credential, void* user_data); /** @@ -419,6 +432,7 @@ typedef struct { ttse_foreach_supported_voices_cb foreach_voices; /**< Called when the engine service user gets the whole supported voice list */ ttse_is_valid_voice_cb is_valid_voice; /**< Called when the engine service user checks whether the voice is valid or not in TTS engine */ ttse_set_pitch_cb set_pitch; /**< Called when the engine service user sets the default pitch of TTS engine */ + ttse_set_personal_tts_id set_personal_tts_id; /**< Called when the engine service user sets the personal tts of TTS engine */ ttse_load_voice_cb load_voice; /**< Called when the engine service user requests to load the corresponding voice type for the first time */ ttse_unload_voice_cb unload_voice; /**< Called when the engine service user requests to unload the corresponding voice type or to stop using voice */ diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c index a1999ae..169c96d 100644 --- a/server/ttsd_engine_agent.c +++ b/server/ttsd_engine_agent.c @@ -43,6 +43,7 @@ typedef struct _ttsengine_info { int default_vctype; int default_speed; int default_pitch; + char* ptts_id; } ttsengine_info_s; typedef struct { @@ -277,6 +278,11 @@ int ttsd_engine_agent_release() g_engine_info->default_lang = NULL; } + if (NULL != g_engine_info->ptts_id) { + free(g_engine_info->ptts_id); + g_engine_info->ptts_id = NULL; + } + if (NULL != g_engine_info->engine_uuid) { free(g_engine_info->engine_uuid); g_engine_info->engine_uuid = NULL; @@ -805,6 +811,36 @@ int ttsd_engine_agent_set_default_pitch(int pitch) return TTSD_ERROR_NONE; } +int ttsd_engine_agent_set_personal_tts_id(const char* ptts_id) +{ + if (NULL == ptts_id) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] ptts_id is NULL"); + return TTSD_ERROR_INVALID_PARAMETER; + } + + int ret = __check_engine_initialized_and_loaded(); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Precondition is not met(%s)", get_error_message(ret)); + return ret; + } + + ret = g_engine_info->callbacks->set_personal_tts_id(ptts_id); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set personal tts id : ptts_id(%s), result(%s)", + ptts_id, __ttsd_get_engine_error_code(ret)); + return TTSD_ERROR_OPERATION_FAILED; + } + + if (NULL != g_engine_info->ptts_id) { + free(g_engine_info->ptts_id); + g_engine_info->ptts_id = NULL; + } + g_engine_info->ptts_id = strdup(ptts_id); + + SLOG(LOG_INFO, tts_tag(), "[Engine Agent] Set personal tts id(%s)", ptts_id); + return TTSD_ERROR_NONE; +} + int ttsd_engine_agent_is_credential_needed(unsigned int uid, bool* credential_needed) { if (NULL == credential_needed) { @@ -932,7 +968,7 @@ int ttsd_engine_unload_voice(const char* lang, const int vctype) return TTSD_ERROR_NONE; } -int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, const char* ptts_id, int speed, int pitch, const char* appid, const char* credential, void* user_param) +int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* appid, const char* credential, void* user_param) { if (NULL == lang || NULL == text) { SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid parameter"); @@ -956,8 +992,8 @@ int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, } return TTSD_ERROR_INVALID_VOICE; } else { - SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), ptts_id(%s), speed(%d), pitch(%d), text(%s), credential(%s)", - (NULL == temp_lang) ? "NULL" : temp_lang, temp_type, (NULL == ptts_id) ? "NULL" : ptts_id, speed, pitch, (NULL == text) ? "NULL" : text, (NULL == credential) ? "NULL" : credential); + SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), speed(%d), text(%s), credential(%s)", + (NULL == temp_lang) ? "NULL" : temp_lang, temp_type, speed, (NULL == text) ? "NULL" : text, (NULL == credential) ? "NULL" : credential); } int temp_speed; @@ -968,16 +1004,8 @@ int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, temp_speed = speed; } - int temp_pitch; - - if (0 == pitch) { - temp_pitch = g_engine_info->default_pitch; - } else { - temp_pitch = pitch; - } - /* synthesize text */ - ret = g_engine_info->callbacks->start_synth(temp_lang, temp_type, text, ptts_id, temp_speed, temp_pitch, appid, credential, user_param); + ret = g_engine_info->callbacks->start_synth(temp_lang, temp_type, text, temp_speed, appid, credential, user_param); if (0 != ret) { SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] ***************************************"); SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] * synthesize error : %s *", __ttsd_get_engine_error_code(ret)); diff --git a/server/ttsd_engine_agent.h b/server/ttsd_engine_agent.h index f435c5f..1376a3e 100644 --- a/server/ttsd_engine_agent.h +++ b/server/ttsd_engine_agent.h @@ -60,6 +60,8 @@ int ttsd_engine_agent_set_default_speed(int speed); int ttsd_engine_agent_set_default_pitch(int pitch); +int ttsd_engine_agent_set_personal_tts_id(const char* ptts_id); + int ttsd_engine_agent_is_credential_needed(unsigned int uid, bool* credential_needed); int ttsd_engine_set_private_data(const char* key, const char* data); @@ -78,7 +80,7 @@ int ttsd_engine_load_voice(const char* lang, int vctype); int ttsd_engine_unload_voice(const char* lang, int vctype); -int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, const char* ptts_id, int speed, int pitch, const char* appid, const char* credential, void* user_param); +int ttsd_engine_start_synthesis(const char* lang, int vctype, const char* text, int speed, const char* appid, const char* credential, void* user_param); int ttsd_engine_cancel_synthesis(); diff --git a/server/ttsd_main.h b/server/ttsd_main.h index b834494..7fa915a 100644 --- a/server/ttsd_main.h +++ b/server/ttsd_main.h @@ -100,6 +100,7 @@ typedef struct { ttse_foreach_supported_voices_cb foreach_voices; ttse_is_valid_voice_cb is_valid_voice; ttse_set_pitch_cb set_pitch; + ttse_set_personal_tts_id set_personal_tts_id; ttse_load_voice_cb load_voice; ttse_unload_voice_cb unload_voice; diff --git a/server/ttsd_server.c b/server/ttsd_server.c index 6640634..ea6c746 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -200,8 +200,19 @@ static void __synthesis(unsigned int uid) SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------"); ttsd_data_set_synth_control(TTSD_SYNTHESIS_CONTROL_DOING); - ret = ttsd_engine_start_synthesis(speak_data->voice.language, speak_data->voice.type, speak_data->text, speak_data->voice.ptts_id, - speak_data->synth_parameter.speed, speak_data->synth_parameter.pitch, appid, credential, NULL); + + ret = ttsd_engine_agent_set_default_pitch(speak_data->synth_parameter.pitch); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set pitch !!!! * "); + } + + ret = ttsd_engine_agent_set_personal_tts_id(speak_data->voice.ptts_id); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set personal tts id !!!! * "); + } + + ret = ttsd_engine_start_synthesis(speak_data->voice.language, speak_data->voice.type, speak_data->text, + speak_data->synth_parameter.speed, appid, credential, NULL); if (TTSD_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * "); -- 2.7.4