For executing add_text_with_synthesis_parameter, it needs some checking points.
First, it adds some logic for checking personal voice information as voice_list in ttsd_engine_select_valid_voice.
Then, it needs to create speak data with personal voice information.
For that, ttsd_engine_start_synthesis API also needs ptts_id as parameter.
Change-Id: I5348fd761693759c7867493b675c5ea35842bc8c
}
SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] Finish update personal info");
- tts_personal_info_s* info = NULL;
- int ret = tts_parser_get_personal_info(filepath, &info);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get personal info");
- return -1;
- }
+
+ __tts_config_mgr_print_personal_info(engine_id);
return 0;
}
*/
#define TTSE_VOICE_TYPE_CHILD 3
+#define TTSE_VOICE_TYPE_PERSONAL 4
+
/**
* @brief Called when TTS engine informs the engine service user about whole supported language and voice type list.
* @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
static ttsd_config_screen_reader_changed_cb g_sr_callback;
+static ttsd_config_supported_personal_voice_cb g_personal_voice_cb;
+
void __ttsd_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, int voice_type, bool auto_voice, bool need_credential, void* user_data)
{
/* Need to check engine is valid */
return 0;
}
+
+bool __ttsd_config_personal_voices(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data)
+{
+ if (NULL == g_personal_voice_cb) {
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get g_personal_voice_callback");
+ return false;
+ }
+
+ g_personal_voice_cb(language, unique_id, user_data);
+ return true;
+}
+
+int ttsd_config_get_personal_voices_list(ttsd_config_supported_personal_voice_cb personal_voice_cb, void* user_data)
+{
+ if (NULL == personal_voice_cb) {
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] No personal voice callback parameter");
+ return -1;
+ }
+
+ g_personal_voice_cb = personal_voice_cb;
+
+ char* current_engine = NULL;
+ int ret = tts_config_mgr_get_engine(¤t_engine);
+ if (0 != ret || NULL == current_engine) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get current engine : %d", ret);
+ return ret;
+ }
+
+ ret = tts_config_mgr_get_personal_voice_list(current_engine, __ttsd_config_personal_voices, user_data);
+ if (TTS_CONFIG_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[Config ERROR] Fail to get persoanl voice list. ret(%d)", ret);
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ return TTSD_ERROR_NONE;
+}
typedef void (*ttsd_config_screen_reader_changed_cb)(bool value);
+typedef bool (*ttsd_config_supported_personal_voice_cb)(const char* language, const char* unique_id, void* user_data);
+
int ttsd_config_initialize(ttsd_config_changed_cb config_cb);
int ttsd_config_finalize();
int ttsd_config_update_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data);
+int ttsd_config_get_personal_voices_list(ttsd_config_supported_personal_voice_cb personal_voice_cb, void* user_data);
+
#ifdef __cplusplus
}
#endif
static inline void destroy_speak_data(speak_data_s* speak_data)
{
- SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d)",
- speak_data->utt_id, speak_data->text == nullptr ? "NULL" : speak_data->text, speak_data->voice.language == nullptr ? "NULL" : speak_data->voice.language, speak_data->voice.type, speak_data->synth_parameter.speed);
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] utt(%d), text(%s), lang(%s), vctype(%d) speed(%d) ptts_id(%s)",
+ speak_data->utt_id, speak_data->text == nullptr ? "NULL" : speak_data->text, speak_data->voice.language == nullptr ? "NULL" : speak_data->voice.language, speak_data->voice.type, speak_data->synth_parameter.speed, speak_data->voice.ptts_id == nullptr ? "NULL" : speak_data->voice.ptts_id);
free(speak_data->text);
speak_data->text = nullptr;
return TTSD_ERROR_NONE;
}
-speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, 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 background_volume_ratio, int utt_id, bool is_silent, unsigned int duration_in_msec)
{
speak_data_s* speak_data = new speak_data_s();
if (nullptr == speak_data) {
speak_data->voice.language = strdup(language);
}
- speak_data->voice.ptts_id = nullptr;
+ if (ptts_id == NULL) {
+ speak_data->voice.ptts_id = nullptr;
+ SLOG(LOG_INFO, tts_tag(), "[DATA INFO] ptts_id of speak_data for silent generation is null");
+ } else {
+ speak_data->voice.ptts_id = strdup(ptts_id);
+ }
+
speak_data->voice.type = voice_type;
speak_data->synth_parameter.speed = speed;
return TTSD_ERROR_OUT_OF_MEMORY;
}
- SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), text(%s), lang(%s), vctype(%d), speed(%d)",
- data, data->utt_id, data->text, data->voice.language, data->voice.type, data->synth_parameter.speed);
+ SLOG(LOG_ERROR, tts_tag(), "[DATA][%p] utt_id(%d), text(%s), lang(%s), vctype(%d), speed(%d), ptts_id(%s)",
+ data, data->utt_id, data->text, data->voice.language, data->voice.type, data->synth_parameter.speed, data->voice.ptts_id == nullptr ? "NULL" : data->voice.ptts_id);
if (1 == data->utt_id)
app_data->utt_id_stopped = 0;
i = 0;
for (auto& speakData : app_data->m_speak_data) {
- SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s)",
+ SLOG(LOG_DEBUG, tts_tag(), "[%dth][%p] lang(%s), vctype(%d), speed(%d), uttid(%d), text(%s), ptts_id(%s)",
i, speakData, speakData->voice.language, speakData->voice.type, speakData->synth_parameter.speed,
- speakData->utt_id, speakData->text);
+ speakData->utt_id, speakData->text, speakData->voice.ptts_id == nullptr ? "NULL" : speakData->voice.ptts_id);
i++;
}
fprintf(fp, "---------------------");
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, 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, int utt_id, bool is_silent, unsigned int duration_in_msec);
void ttsd_data_destroy_speak_data(speak_data_s* speak_data);
/** Callback function for voice list */
static bool __supported_voice_cb(const char* language, int type, void* user_data);
+static bool __supported_personal_voice_cb(const char* language, const char* unique_id, void* user_data);
/** Free voice list */
static void __free_voice_list(GList* voice_list);
return false;
}
-bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, int* out_type)
+bool ttsd_engine_select_valid_voice(const char* lang, int type, const char* ptts_id, char** out_lang, int* out_type, char** out_ptts_id)
{
if (NULL == lang || NULL == out_lang || NULL == out_type) {
return false;
return false;
}
- SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Select voice : input lang(%s), input type(%d), default lang(%s), default type(%d)",
- (NULL == lang) ? "NULL" : lang, type, (NULL == g_engine_info->default_lang) ? "NULL" : g_engine_info->default_lang, g_engine_info->default_vctype);
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Select voice : input lang(%s), input type(%d), input ptts_id(%s), default lang(%s), default type(%d)",
+ (NULL == lang) ? "NULL" : lang, type, (NULL == ptts_id) ? "NULL" : ptts_id, (NULL == g_engine_info->default_lang) ? "NULL" : g_engine_info->default_lang, g_engine_info->default_vctype);
/* case 1 : Both are default */
if (0 == strncmp(lang, "default", strlen(lang)) && 0 == type) {
}
*out_type = g_engine_info->default_vctype;
+ *out_ptts_id = NULL;
return true;
}
return false;
}
+ if (type == TTSE_VOICE_TYPE_PERSONAL) {
+ SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] voice type is personal");
+ ret = ttsd_config_get_personal_voices_list(__supported_personal_voice_cb, &voice_list);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] No supported personal voice");
+ return false;
+ }
+ }
+
bool result;
result = false;
voice = iter->data;
if (0 == strncmp(voice->language, lang, strlen(lang)) && voice->type == type) {
+ if (type == TTSE_VOICE_TYPE_PERSONAL && NULL!= ptts_id) {
+ if (0 != strncmp(voice->ptts_id, ptts_id, strlen(voice->ptts_id))) {
+ iter = g_list_next(iter);
+ continue;
+ }
+ *out_ptts_id = strdup(voice->ptts_id);
+ } else {
+ *out_ptts_id = NULL;
+ }
*out_lang = strdup(voice->language);
*out_type = voice->type;
result = true;
iter = g_list_next(iter);
}
- } else if (0 != strncmp(lang, "default", strlen("default")) && 0 == type) {
+ } else if (0 != strncmp(lang, "default", strlen("default")) && 0 == type) { // default type != personal_type
/* Only type is default */
if (0 == strncmp(lang, g_engine_info->default_lang, strlen(g_engine_info->default_lang))) {
*out_lang = strdup(g_engine_info->default_lang);
*out_type = g_engine_info->default_vctype;
+ *out_ptts_id = NULL;
result = true;
} else {
voice_s* voice_selected = NULL;
if (NULL != voice_selected) {
*out_lang = strdup(voice_selected->language);
*out_type = voice_selected->type;
+ *out_ptts_id = NULL;
result = true;
}
}
} else if (0 == strncmp(lang, "default", strlen("default")) && 0 != type) {
/* Only lang is default */
- if (type == g_engine_info->default_vctype) {
+ if (type == g_engine_info->default_vctype) { // default type != personal_type
*out_lang = strdup(g_engine_info->default_lang);
*out_type = g_engine_info->default_vctype;
+ *out_ptts_id = NULL;
result = true;
} else {
voice_s* voice_selected = NULL;
if (0 == strncmp(voice->language, g_engine_info->default_lang, strlen(g_engine_info->default_lang))) {
voice_selected = voice;
if (voice->type == type) {
+ if (type == TTSE_VOICE_TYPE_PERSONAL && NULL != ptts_id) {
+ if (0 != strncmp(voice->ptts_id, ptts_id, strlen(voice->ptts_id))) {
+ iter = g_list_next(iter);
+ continue;
+ }
+ }
voice_selected = voice;
break;
}
if (NULL != voice_selected) {
*out_lang = strdup(voice->language);
*out_type = voice_selected->type;
+ if (type == TTSE_VOICE_TYPE_PERSONAL && NULL != voice->ptts_id) {
+ *out_ptts_id = strdup(voice->ptts_id);
+ } else {
+ *out_ptts_id = NULL;
+ }
result = true;
}
}
}
if (true == result) {
- SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
+ if (NULL != ptts_id)
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d), ptts_id(%s)", *out_lang, *out_type, *out_ptts_id);
+ else
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Selected voice : lang(%s), type(%d)", *out_lang, *out_type);
}
__free_voice_list(voice_list);
return TTSD_ERROR_NONE;
}
-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_start_synthesis(const char* lang, int vctype, const char* ptts_id, 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");
/* select voice for default */
char* temp_lang = NULL;
int temp_type;
- if (true != ttsd_engine_select_valid_voice(lang, vctype, &temp_lang, &temp_type)) {
+ char* temp_ptts_id = NULL;
+ if (true != ttsd_engine_select_valid_voice(lang, vctype, ptts_id, &temp_lang, &temp_type, &temp_ptts_id)) {
SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to select default voice");
if (NULL != temp_lang) {
free(temp_lang);
}
return TTSD_ERROR_INVALID_VOICE;
} else {
- 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);
+ SECURE_SLOG(LOG_DEBUG, tts_tag(), "[Engine Agent] Start synthesis : language(%s), type(%d), ptts_id(%s), speed(%d), text(%s), credential(%s)",
+ (NULL == temp_lang) ? "NULL" : temp_lang, temp_type, (NULL == temp_ptts_id) ? "NULL" : temp_ptts_id, speed, (NULL == text) ? "NULL" : text, (NULL == credential) ? "NULL" : credential);
}
int temp_speed;
}
voice->language = strdup(language);
voice->type = type;
+ voice->ptts_id = NULL;
+
+ *voice_list = g_list_append(*voice_list, voice);
+
+ return true;
+}
+
+bool __supported_personal_voice_cb(const char* language, const char* unique_id, void* user_data)
+{
+ GList** voice_list = (GList**)user_data;
+
+ if (NULL == voice_list) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Input parameter is NULL in voice list callback!!!!");
+ return false;
+ }
+
+ voice_s* voice = calloc(1, sizeof(voice_s));
+ if (NULL == voice) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to allocate memory");
+ return false;
+ }
+
+ voice->language = strdup(language);
+ voice->type = TTSE_VOICE_TYPE_PERSONAL;
+ voice->ptts_id = strdup(unique_id);
*voice_list = g_list_append(*voice_list, voice);
free(data->language);
data->language = NULL;
}
+ if (NULL != data->ptts_id) {
+ free(data->ptts_id);
+ data->ptts_id = NULL;
+ }
free(data);
data = NULL;
}
/** Get state of current engine to need network */
bool ttsd_engine_agent_need_network();
-bool ttsd_engine_select_valid_voice(const char* lang, int type, char** out_lang, int* out_type);
+bool ttsd_engine_select_valid_voice(const char* lang, int type, const char* ptts_id, char** out_lang, int* out_type, char** out_ptts_id);
bool ttsd_engine_agent_is_same_engine(const char* engine_id);
int ttsd_engine_unload_voice(const char* lang, int vctype);
-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_start_synthesis(const char* lang, int vctype, const char* ptts_id, const char* text, int speed, const char* appid, const char* credential, void* user_param);
int ttsd_engine_cancel_synthesis();
char* temp_lang = NULL;
int temp_type;
- if (true != ttsd_engine_select_valid_voice(speak_data->voice.language, speak_data->voice.type, &temp_lang,
- &temp_type)) {
+ char* temp_ptts_id = NULL;
+ if (true != ttsd_engine_select_valid_voice(speak_data->voice.language, speak_data->voice.type, NULL, &temp_lang,
+ &temp_type, &temp_ptts_id)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select default voice");
} else {
char value_buffer[2048] = {0, };
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), speed(%d)", speak_data->voice.language,
- speak_data->voice.type, speak_data->synth_parameter.speed);
+ 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(), "Text : %s", speak_data->text);
SLOG(LOG_INFO, tts_tag(), "Credential : %s", credential);
SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------");
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,
+ 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) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to start SYNTHESIS !!!! * ");
char* out_lang = NULL;
int out_type;
+ char* temp_ptts_id = NULL;
int ret = -1;
- if (true == ttsd_engine_select_valid_voice(str_param, int_param, &out_lang, &out_type)) {
+ if (true == ttsd_engine_select_valid_voice(str_param, int_param, NULL, &out_lang, &out_type, &temp_ptts_id)) {
SLOG(LOG_ERROR, tts_tag(), "[Server] valid language : lang(%s), type(%d)", out_lang, out_type);
ret = ttsd_engine_agent_set_default_voice(out_lang, out_type);
if (0 != ret)
/* check valid voice */
char* temp_lang = NULL;
int temp_type;
- if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, &temp_lang, &temp_type)) {
+ char* temp_ptts_id = NULL;
+ if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, NULL, &temp_lang, &temp_type, &temp_ptts_id)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select valid voice");
if (NULL != temp_lang) {
free(temp_lang);
return TTSD_ERROR_INVALID_VOICE;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, 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, utt_id, false, 0);
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
if (NULL != temp_lang) {
/* check valid voice */
char* temp_lang = NULL;
+ char* temp_ptts_id = NULL;
int temp_type;
- if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, &temp_lang, &temp_type)) {
+ if (true != ttsd_engine_select_valid_voice((const char*)lang, voice_type, ptts_id, &temp_lang, &temp_type, &temp_ptts_id)) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to select valid voice");
if (NULL != temp_lang) {
free(temp_lang);
return TTSD_ERROR_INVALID_VOICE;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, 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, utt_id, false, 0);
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
if (NULL != temp_lang) {
return TTSD_ERROR_INVALID_PARAMETER;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(NULL, NULL, 0, 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, 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;