From: sooyeon Date: Wed, 25 Sep 2024 06:28:17 +0000 (+0900) Subject: Add internal apis for setting engine_type of synthesized speech X-Git-Tag: accepted/tizen/unified/20241011.010647~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ed92186aa1993e9e24735acdb4621fd5b393d82;p=platform%2Fcore%2Fuifw%2Ftts.git Add internal apis for setting engine_type of synthesized speech Change-Id: Id144433609ea541de2509ef8242de2ef2f9f6104 Signed-off-by: sooyeon --- diff --git a/client/tts.c b/client/tts.c index 1edde0b5..05832947 100644 --- a/client/tts.c +++ b/client/tts.c @@ -1522,6 +1522,11 @@ int tts_synthesis_parameter_destroy(tts_synthesis_parameter_h parameter) parameter->ptts_id = NULL; } + if (parameter->engine_type) { + free(parameter->engine_type); + parameter->engine_type = NULL; + } + free(parameter); parameter = NULL; @@ -1633,6 +1638,23 @@ int tts_synthesis_parameter_set_background_volume_ratio(tts_synthesis_parameter_ return TTS_ERROR_NONE; } +int tts_synthesis_parameter_set_engine_type(tts_synthesis_parameter_h parameter, const char *engine_type) +{ + SLOG(LOG_INFO, TAG_TTSC, "@@@ Set engine_type to a synthesis parameter"); + RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED); + + RETVM_IF(NULL == parameter || NULL == engine_type, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input handle is null"); + + char *new_engine_type = strdup(engine_type); + RETVM_IF(NULL == new_engine_type, TTS_ERROR_OUT_OF_MEMORY, "[ERROR] Fail to allocate memory for engine_type"); + + free(parameter->engine_type); + parameter->engine_type = new_engine_type; + + SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set engine_type(%s) to a synthesis parameter", engine_type); + return TTS_ERROR_NONE; +} + int tts_get_pitch_range(tts_h tts, int* min, int* normal, int* max) { RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED); diff --git a/client/tts_main.h b/client/tts_main.h index 2de17462..6b2f2a88 100644 --- a/client/tts_main.h +++ b/client/tts_main.h @@ -49,6 +49,7 @@ struct tts_synthesis_parameter_s { int pitch; double volume; double background_volume_ratio; + char *engine_type; }; #ifdef __cplusplus diff --git a/client/tts_tidl.c b/client/tts_tidl.c index ccbcf9e3..fb2c7f63 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -770,8 +770,9 @@ int tts_tidl_request_add_text_with_synthesis_parameter(unsigned int uid, const c SLOG(LOG_DEBUG, TAG_TTSC, "parameter->pitch (%d)", parameter->pitch); SLOG(LOG_DEBUG, TAG_TTSC, "parameter->volume (%f)", parameter->volume); SLOG(LOG_DEBUG, TAG_TTSC, "parameter->background_volume_ratio (%f)", parameter->background_volume_ratio); + SLOG(LOG_DEBUG, TAG_TTSC, "parameter->engine_type(%s)", (parameter->engine_type) ? (parameter->engine_type) : "null"); - int ret = rpc_port_proxy_tts_invoke_add_text_with_synthesis_parameter(info->rpc_h, uid, text, language, ptts_id, parameter->voice_type, parameter->speed, parameter->pitch, parameter->volume, parameter->background_volume_ratio, uttid, not_null_credential); + int ret = rpc_port_proxy_tts_invoke_add_text_with_synthesis_parameter(info->rpc_h, uid, text, language, ptts_id, parameter->voice_type, parameter->speed, parameter->pitch, parameter->volume, parameter->background_volume_ratio, parameter->engine_type, uttid, not_null_credential); int exception = get_last_result(); if (RPC_PORT_ERROR_NONE != exception) { ret = __convert_and_handle_tidl_error(exception, info); diff --git a/include/tts_internal.h b/include/tts_internal.h index 30647077..54dca014 100644 --- a/include/tts_internal.h +++ b/include/tts_internal.h @@ -122,6 +122,23 @@ int tts_play_pcm(tts_h tts); */ int tts_stop_pcm(tts_h tts); + +/** + * @brief Sets the engine_type. + * @since_tizen 9.0 + * @param[in] parameter The TTS synthesis parameter handle + * @param[in] engine_type The TTS engine's type + * @return @c 0 on success, + * otherwise a negative error value + * @retval #TTS_ERROR_NONE Successful + * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported + * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #TTS_ERROR_OPERATION_FAILED Operation failure + * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory +*/ +int tts_synthesis_parameter_set_engine_type(tts_synthesis_parameter_h parameter, const char *engine_type); + + #ifdef __cplusplus } #endif diff --git a/include/ttse_internal.h b/include/ttse_internal.h new file mode 100755 index 00000000..9def9979 --- /dev/null +++ b/include/ttse_internal.h @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* 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 __TTSE_INTERNAL_H__ +#define __TTSE_INTERNAL_H__ + + +#include + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** +* @brief Called when the engine service user sets the engine_type of synthesized speech. +* @since_tizen 9.0 +* @remarks This callback function is optional and is registered using ttse_set_engine_type_set_cb(). +* @param[in] engine_type The engine_type of synthesized speech +* @param[in] user_data The user data to be passed to the callback function +* @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_engine_type_cb)(const char* engine_type, void* user_data); + + + + +/** +* @brief Sets a callback function to be called when the engine_type of synthesized speech is set. +* @since_tizen 9.0 +* @remarks The ttse_set_engine_type_cb() function is called when the engine service user sets the engine_type of synthesized speech. +* @param[in] callback ttse_set_engine_type_cb event callback function +* @param[in] user_data The user data passed from engine +* @return @c 0 on success, +* otherwise a negative error value +* @retval #TTSE_ERROR_NONE Successful +* @retval #TTSE_ERROR_NOT_SUPPORTED TTS NOT supported +* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTSE_ERROR_INVALID_STATE Not initialized +* @pre The ttse_main() function should be invoked before this function is called. +* @see ttse_set_engine_type_cb() +*/ +int ttse_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data); + + +#ifdef __cplusplus +} +#endif + + +/** + * @} + */ + + +#endif /* __TTSE_INTERNAL_H__ */ diff --git a/server/ttsd_data.cpp b/server/ttsd_data.cpp index 8c25dc28..fe1eb2a2 100644 --- a/server/ttsd_data.cpp +++ b/server/ttsd_data.cpp @@ -483,7 +483,7 @@ int ttsd_data_reset_used_voice(unsigned int uid, ttsd_used_voice_cb callback) return TTSD_ERROR_NONE; } -speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, bool is_silent, unsigned int duration_in_msec) +speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, const char* engine_type, int utt_id, bool is_silent, unsigned int duration_in_msec) { speak_data_s* speak_data = new speak_data_s(); if (nullptr == speak_data) { @@ -517,7 +517,13 @@ speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language speak_data->synth_parameter.speed = speed; speak_data->synth_parameter.pitch = pitch; speak_data->synth_parameter.volume = volume; - speak_data->synth_parameter.background_volume_ratio = background_volume_ratio; + speak_data->synth_parameter.background_volume_ratio = bg_volume; + if (engine_type == NULL) { + speak_data->synth_parameter.engine_type = nullptr; + SLOG(LOG_INFO, tts_tag(), "[DATA INFO] engine_type of synth_parameter is null"); + } else { + speak_data->synth_parameter.engine_type = strdup(engine_type); + } speak_data->utt_id = utt_id; speak_data->is_silent = is_silent; diff --git a/server/ttsd_data.h b/server/ttsd_data.h index 4205183f..80d09e00 100644 --- a/server/ttsd_data.h +++ b/server/ttsd_data.h @@ -48,6 +48,7 @@ typedef struct { int pitch; double volume; double background_volume_ratio; + char* engine_type; } synthesis_parameter_s; typedef struct { @@ -99,7 +100,7 @@ int ttsd_data_set_credential(unsigned int uid, const char* credential); char* ttsd_data_get_credential(unsigned int uid); /* speak data */ -speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, int utt_id, bool is_silent, unsigned int duration_in_msec); +speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, const char* engine_type, int utt_id, bool is_silent, unsigned int duration_in_msec); void ttsd_data_destroy_speak_data(speak_data_s* speak_data); diff --git a/server/ttsd_engine_agent.c b/server/ttsd_engine_agent.c index 1f0d4ce8..6f8e55da 100644 --- a/server/ttsd_engine_agent.c +++ b/server/ttsd_engine_agent.c @@ -193,6 +193,7 @@ static int __set_engine_callback(ttse_request_callback_s* callback, ttsengine_in engine_info->callbacks->private_data_requested = NULL; engine_info->callbacks->activated_mode_changed = NULL; engine_info->callbacks->set_personal_tts_id = NULL; + engine_info->callbacks->set_engine_type = NULL; SLOG(LOG_DEBUG, tts_tag(), "--- Valid Engine ---"); SLOG(LOG_DEBUG, tts_tag(), "Engine uuid : %s", engine_info->engine_uuid); @@ -885,6 +886,36 @@ int ttsd_engine_agent_set_personal_tts_id(const char* ptts_id) return TTSD_ERROR_NONE; } +int ttsd_engine_agent_set_engine_type(const char* engine_type) +{ + if (NULL == engine_type) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] engine_type 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; + } + + if (NULL == g_engine_info->callbacks->set_engine_type) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Setting engine_type is not supported. Fail to set engine_type."); + return TTSD_ERROR_NOT_SUPPORTED_FEATURE; + } + + void* data = g_engine_info->callbacks->set_engine_type_user_data; + ret = g_engine_info->callbacks->set_engine_type(engine_type, data); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set engine_type : engine_type(%s), result(%s)", + engine_type, __ttsd_get_engine_error_code(ret)); + return TTSD_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_INFO, tts_tag(), "[Engine Agent] Set engine_type(%s)", engine_type); + return TTSD_ERROR_NONE; +} + int ttsd_engine_agent_is_credential_needed(unsigned int uid, bool* credential_needed) { if (NULL == credential_needed) { @@ -1418,5 +1449,18 @@ int ttsd_engine_agent_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb cal g_engine_info->callbacks->set_personal_tts_id = callback; + return TTSD_ERROR_NONE; +} + +int ttsd_engine_agent_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data) +{ + if (false == __is_agent_initialized()) { + SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized"); + return TTSD_ERROR_INVALID_STATE; + } + + g_engine_info->callbacks->set_engine_type = callback; + g_engine_info->callbacks->set_engine_type_user_data = user_data; + return TTSD_ERROR_NONE; } \ No newline at end of file diff --git a/server/ttsd_engine_agent.h b/server/ttsd_engine_agent.h index 366ee388..a9033a3a 100644 --- a/server/ttsd_engine_agent.h +++ b/server/ttsd_engine_agent.h @@ -41,6 +41,7 @@ int ttsd_engine_agent_set_private_data_set_cb(ttse_private_data_set_cb callback) int ttsd_engine_agent_set_private_data_requested_cb(ttse_private_data_requested_cb callback); int ttsd_engine_agent_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback); int ttsd_engine_agent_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb callback); +int ttsd_engine_agent_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data); /** Unload current engine */ int ttsd_engine_agent_unload_current_engine(); @@ -63,6 +64,8 @@ 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_set_engine_type(const char* engine_type); + 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); diff --git a/server/ttsd_main.h b/server/ttsd_main.h index 68908f97..43287ff3 100644 --- a/server/ttsd_main.h +++ b/server/ttsd_main.h @@ -26,6 +26,7 @@ #include #include "ttse.h" +#include "ttse_internal.h" #include "tts_defs.h" #ifdef __cplusplus @@ -113,6 +114,8 @@ typedef struct { ttse_private_data_requested_cb private_data_requested; ttse_activated_mode_changed_cb activated_mode_changed; ttse_personal_tts_id_set_cb set_personal_tts_id; + ttse_set_engine_type_cb set_engine_type; + void* set_engine_type_user_data; } tts_engine_callback_s; diff --git a/server/ttsd_server.c b/server/ttsd_server.c index 51e83525..1ce662cb 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -187,7 +187,6 @@ static void __synthesis(unsigned int uid) __stop_and_send_ready_state(uid); } } else { - if (NULL == speak_data->voice.language || NULL == speak_data->text) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Current data is NOT valid"); __stop_and_send_ready_state(uid); @@ -200,8 +199,8 @@ static void __synthesis(unsigned int uid) SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------"); SLOG(LOG_INFO, tts_tag(), "ID : uid (%u), uttid(%d) ", g_utt.uid, g_utt.uttid); - SLOG(LOG_INFO, tts_tag(), "Voice : language(%s), type(%d), ptts_id(%s), speed(%d)", speak_data->voice.language, - speak_data->voice.type, speak_data->voice.ptts_id, speak_data->synth_parameter.speed); + SLOG(LOG_INFO, tts_tag(), "Voice : language(%s), type(%d), ptts_id(%s), speed(%d), engine_type(%s)", speak_data->voice.language, + speak_data->voice.type, speak_data->voice.ptts_id, speak_data->synth_parameter.speed, speak_data->synth_parameter.engine_type); SLOG(LOG_INFO, tts_tag(), "Text : %s", speak_data->text); SLOG(LOG_INFO, tts_tag(), "Credential : %s", credential); SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------"); @@ -218,6 +217,11 @@ static void __synthesis(unsigned int uid) SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set personal tts id !!!! * "); } + ret = ttsd_engine_agent_set_engine_type(speak_data->synth_parameter.engine_type); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set engine_type !!!! * "); + } + ret = ttsd_engine_start_synthesis(speak_data->voice.language, speak_data->voice.type, speak_data->voice.ptts_id, speak_data->text, speak_data->synth_parameter.speed, appid, credential, NULL); if (TTSD_ERROR_NONE != ret) { @@ -1127,7 +1131,7 @@ int ttsd_server_add_text(unsigned int uid, const char* text, const char* lang, i return TTSD_ERROR_INVALID_VOICE; } - speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, NULL, speed, 0, -1.0, -1.0, utt_id, false, 0); + speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, NULL, speed, 0, -1.0, -1.0, NULL, utt_id, false, 0); if (NULL == speak_data) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory"); if (NULL != temp_lang) { @@ -1205,7 +1209,7 @@ int ttsd_server_add_text(unsigned int uid, const char* text, const char* lang, i return TTSD_ERROR_NONE; } -int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, const char* credential) +int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int utt_id, const char* credential) { app_tts_state_e state = ttsd_data_get_client_state(uid); if (APP_STATE_NONE == state) { @@ -1239,7 +1243,7 @@ int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* return TTSD_ERROR_INVALID_VOICE; } - speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, ptts_id, speed, pitch, volume, background_volume_ratio, utt_id, false, 0); + speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, ptts_id, speed, pitch, volume, background_volume_ratio, engine_type, utt_id, false, 0); if (NULL == speak_data) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory"); if (NULL != temp_lang) { @@ -1254,7 +1258,7 @@ int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* return TTSD_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), uttid(%d), credential(%s)", lang, voice_type, speed, utt_id, credential); + SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), engine_type(%s), uttid(%d), credential(%s)", lang, voice_type, speed, (engine_type) ? engine_type : "NULL", utt_id, credential); /* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/ int ret = -1; @@ -1325,7 +1329,7 @@ int ttsd_server_add_silent_utterance(unsigned int uid, unsigned int duration_in_ return TTSD_ERROR_INVALID_PARAMETER; } - speak_data_s* speak_data = ttsd_data_create_speak_data(NULL, NULL, 0, NULL, 0, 0, -1.0, -1.0, utt_id, true, duration_in_msec); + speak_data_s* speak_data = ttsd_data_create_speak_data(NULL, NULL, 0, NULL, 0, 0, -1.0, -1.0, NULL, utt_id, true, duration_in_msec); if (NULL == speak_data) { SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory"); return TTSD_ERROR_OPERATION_FAILED; @@ -1685,6 +1689,16 @@ int ttsd_send_personal_voice(const char* language, const char* unique_id, const return ret; } +int ttsd_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data) +{ + int ret = ttsd_engine_agent_set_engine_type_set_cb(callback, user_data); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set engine_type set cb : ret(%d)", ret); + } + + return ret; +} + int ttsd_server_play_pcm(unsigned int uid) { app_tts_state_e state = ttsd_data_get_client_state(uid); diff --git a/server/ttsd_server.h b/server/ttsd_server.h index e4aa647f..39b5b4ad 100644 --- a/server/ttsd_server.h +++ b/server/ttsd_server.h @@ -19,6 +19,7 @@ #include #include "ttse.h" +#include "ttse_internal.h" #include "tts_ipc_method.h" #ifdef __cplusplus @@ -44,9 +45,10 @@ int ttsd_get_activated_mode(int* activated_mode); int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback); int ttsd_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb callback, void* user_data); - int ttsd_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name); +int ttsd_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data); + /* * Server API for client @@ -68,7 +70,7 @@ int ttsd_server_add_text(unsigned int uid, const char* text, const char* lang, i int ttsd_server_add_silent_utterance(unsigned int uid, unsigned int duration_in_msec, int utt_id, const char* credential); -int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, const char* credential); +int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int utt_id, const char* credential); int ttsd_server_play(unsigned int uid, const char* credential); diff --git a/server/ttsd_tidl.c b/server/ttsd_tidl.c index fcc2d5f6..4534d743 100644 --- a/server/ttsd_tidl.c +++ b/server/ttsd_tidl.c @@ -351,12 +351,12 @@ static int __add_silent_utterance_cb(rpc_port_stub_tts_context_h context, int ui return TTSD_ERROR_NONE; } -static int __add_text_with_synthesis_parameter_cb(rpc_port_stub_tts_context_h context, int uid, const char *text, const char* language, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int uttid, const char *credential, void *user_data) +static int __add_text_with_synthesis_parameter_cb(rpc_port_stub_tts_context_h context, int uid, const char *text, const char* language, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int uttid, const char *credential, void *user_data) { unsigned int u_uid = (unsigned int)uid; SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT WITH SYNTHESIS PARAMETER(%u)", u_uid); - int ret = ttsd_server_add_text_with_synthesis_parameter(u_uid, text, language, ptts_id, voice_type, speed, pitch, volume, background_volume_ratio, uttid, credential); + int ret = ttsd_server_add_text_with_synthesis_parameter(u_uid, text, language, ptts_id, voice_type, speed, pitch, volume, background_volume_ratio, engine_type, uttid, credential); if (TTSD_ERROR_NONE != ret) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS ADD TEXT WITH SYNTHESIS PARAMETER (%u) fail (%d/%s) <<<<<", u_uid, ret, get_error_message(ret)); return ret; diff --git a/server/ttse.c b/server/ttse.c index d67f54ec..2ccd2cd6 100755 --- a/server/ttse.c +++ b/server/ttse.c @@ -25,6 +25,7 @@ #include #include "ttse.h" +#include "ttse_internal.h" static int g_feature_enabled = -1; static bool g_is_terminated = false; @@ -388,3 +389,27 @@ int ttse_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb callback, void* return ret; } + +int ttse_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data) +{ + if (false == is_feature_enabled()) { + return TTSE_ERROR_NOT_SUPPORTED; + } + + if (NULL == callback) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter"); + return TTSE_ERROR_INVALID_PARAMETER; + } + + if (false == g_is_started) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Service engine is not started."); + return TTSE_ERROR_INVALID_STATE; + } + + int ret = ttsd_set_engine_type_set_cb(callback, user_data); + if (TTSD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set engine_type set cb. ret(%d/%s)", ret, get_error_message(ret)); + } + + return ret; +} \ No newline at end of file diff --git a/tidl/tts.tidl b/tidl/tts.tidl index 607f4283..533a5356 100644 --- a/tidl/tts.tidl +++ b/tidl/tts.tidl @@ -6,6 +6,7 @@ struct tts_synthesis_parameter_s { int pitch; double volume; double background_volume; + string engine_type; } interface tts { @@ -17,7 +18,7 @@ interface tts { int finalize(in int uid); int add_text(int uid, string text, string lang, int vctype, int speed, int uttid, string credential); int add_silent_utterance(int uid, int duration_in_msec, int uttid, string credential); - int add_text_with_synthesis_parameter(int uid, string text, string langauge, string ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume, int uttid, string credential); + int add_text_with_synthesis_parameter(int uid, string text, string langauge, string ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume, string engine_type, int uttid, string credential); int stop(in int uid); int pause(in int uid); int play_pcm(in int uid);