From 9d26075cda1ba702f89fbf6a072c1118f6f88f4d Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Wed, 24 Jul 2024 16:38:53 +0900 Subject: [PATCH] Add ttse_send_personal_voice API for saving personal voice information When TTS Engine calls ttse_send_personal_voice(), it save the personal voice information which is parameter of ttse_send_personal_voice. This api is finding xml file with engine name, and saves the language, unique_id, display_name, device_name. Change-Id: Ie2650d9c281607b286a458608ee4661e478ec0b4 --- common/tts_config_mgr.c | 52 +++++++ common/tts_config_mgr.h | 2 + common/tts_config_parser.c | 356 +++++++++++++++++++++++++++++++++++++++++++++ common/tts_config_parser.h | 16 ++ common/tts_defs.h | 1 + include/ttse.h | 2 + packaging/tts.spec | 3 + server/ttsd_config.c | 17 +++ server/ttsd_config.h | 2 + server/ttsd_server.c | 12 ++ server/ttsd_server.h | 2 + server/ttse.c | 12 ++ 12 files changed, 477 insertions(+) diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c index a16ee6f..1b2b99b 100644 --- a/common/tts_config_mgr.c +++ b/common/tts_config_mgr.c @@ -1329,6 +1329,16 @@ int tts_config_mgr_initialize(unsigned int uid, tts_config_client_type_e client_ } } + if (0 != access(TTS_DOWNLOAD_PERSONAL_INFO, F_OK)) { + if (0 != mkdir(TTS_DOWNLOAD_PERSONAL_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to make directory : %s", TTS_DOWNLOAD_PERSONAL_INFO); + release_config_client(uid); + return TTS_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "Success to make directory : %s", TTS_DOWNLOAD_PERSONAL_INFO); + } + } + SLOG(LOG_INFO, TAG_TTSCONFIG, "Client type : %d", client_type); g_client_type |= client_type; @@ -2371,3 +2381,45 @@ int tts_config_mgr_set_instant_reprepare_client(const unsigned int uid) return ret; } + +int tts_config_mgr_update_personal_voice(const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name) +{ + char* default_engine = get_default_engine_app_id(); + // tts_engine_info_s *engine_info = __get_engine_info(default_engine); + // free(default_engine); + // if (NULL == engine_info) { + // SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] engine info is NULL"); + // return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND; + // } + + engine_id = strdup(default_engine); + + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] engine id = %s", engine_id); + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] language(%s), unique_id(%s), display_name(%s), device_name(%s)", language, unique_id, display_name, device_name); + if (NULL == engine_id || NULL == language || NULL == unique_id || NULL == display_name || NULL == device_name) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Input Parameter is null"); + return TTS_CONFIG_ERROR_INVALID_PARAMETER; + } + + char filepath[512] = {'\0',}; + + memset(filepath, '\0', 512); + snprintf(filepath, 512, "%s/%s-%s", TTS_DOWNLOAD_PERSONAL_INFO, engine_id, "personal.xml"); + + SECURE_SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[CONFIG] Filepath(%s)", filepath); + + if (0 != tts_parser_update_personal_info(filepath, engine_id, language, unique_id, display_name, device_name)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to update personal info xml"); + return -1; + } + + 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; + } + + return 0; +} diff --git a/common/tts_config_mgr.h b/common/tts_config_mgr.h index a387d48..3f6f694 100644 --- a/common/tts_config_mgr.h +++ b/common/tts_config_mgr.h @@ -129,6 +129,8 @@ int tts_config_mgr_get_instant_reprepare_client(unsigned int *uid); int tts_config_mgr_set_instant_reprepare_client(const unsigned int uid); +int tts_config_mgr_update_personal_voice(const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name); + #ifdef __cplusplus } diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index e9cf157..374db73 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "tts_config_parser.h" #include "tts_defs.h" @@ -44,6 +45,15 @@ #define TTS_TAG_VOICE_TYPE_MALE "male" #define TTS_TAG_VOICE_TYPE_CHILD "child" +#define TTS_TAG_PERSONAL_BASE_TAG "tts-personal-voice" +#define TTS_TAG_PERSONAL_VOICE_SET "personal-voices" +#define TTS_TAG_PERSONAL_VOICE "personal-voice" +#define TTS_TAG_PERSONAL_VOICE_LANGUAGE "language" +#define TTS_TAG_PERSONAL_VOICE_UNIQUE_ID "unique-id" +#define TTS_TAG_PERSONAL_VOICE_DISPLAY_NAME "display-name" +#define TTS_TAG_PERSONAL_VOICE_DEVICE_NAME "device-name" +#define TTS_TAG_PERSONAL_VOICE_ENGINE_ID "id" + #define TTS_MAX_TEXT_SIZE 2000 #define VOLUME_BASE_VALUE 100.0 @@ -52,10 +62,356 @@ char g_engine_id[128] = {0,}; char g_setting[128] = {0,}; char g_language[128] = {0,}; +static xmlDocPtr g_personal_info_doc = NULL; + static tts_config_s* g_config_info = NULL; static pthread_mutex_t g_config_info_mutex = PTHREAD_MUTEX_INITIALIZER; +int __create_personal_info_xml(const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name) +{ + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "@@@ Create personal info doc"); + g_personal_info_doc = xmlNewDoc((xmlChar*)"1.0"); + if (NULL == g_personal_info_doc) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to new doc"); + return -1; + } + xmlNodePtr root = NULL; + xmlNodePtr cur = NULL; + + root = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_BASE_TAG); + if (NULL == root) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to get new node"); + return -1; + } + + xmlDocSetRootElement(g_personal_info_doc, root); + + xmlNodePtr node = NULL; + xmlNodePtr personal_voice_node = NULL; + + node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_SET); + + personal_voice_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE); + + cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_LANGUAGE); + xmlNodeSetContent(cur, (const xmlChar*)language); + xmlAddChild(personal_voice_node, cur); + + cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_UNIQUE_ID); + xmlNodeSetContent(cur, (const xmlChar*)unique_id); + xmlAddChild(personal_voice_node, cur); + + cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_DISPLAY_NAME); + xmlNodeSetContent(cur, (const xmlChar*)display_name); + xmlAddChild(personal_voice_node, cur); + + cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_DEVICE_NAME); + xmlNodeSetContent(cur, (const xmlChar*)device_name); + xmlAddChild(personal_voice_node, cur); + + xmlAddChild(node, personal_voice_node); + xmlAddChild(root, node); + + node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_ENGINE_ID); + xmlNodeSetContent(node, (const xmlChar*)engine_id); + xmlAddChild(root, node); + + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] Finish to create personal voice info"); + + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "@@@"); + return 0; +} + +int tts_parser_update_personal_info(const char* path, const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name) +{ + if (NULL == path) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Input parameter is NULL"); + return -1; + } + + if (0 == access(path, F_OK)) { + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] Success to access to %s", path); + + xmlNodePtr cur = NULL; + + g_personal_info_doc = xmlParseFile(path); + if (g_personal_info_doc == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to parse xml file"); + return -1; + } + cur = xmlDocGetRootElement(g_personal_info_doc); + if (cur == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document. doc path(%s, %p)", path, g_personal_info_doc); + xmlFreeDoc(g_personal_info_doc); + g_personal_info_doc = NULL; + return -1; + } + + if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_PERSONAL_BASE_TAG)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] The wrong type, root node is NOT 'tts-personal-info'. doc path(%s, %p)", path, g_personal_info_doc); + xmlFreeDoc(g_personal_info_doc); + g_personal_info_doc = NULL; + return -1; + } + + cur = cur->xmlChildrenNode; // TTS_TAG_PERSONAL_VOICE_SET + if (cur == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document. doc path(%s, %p)", path, g_personal_info_doc); + xmlFreeDoc(g_personal_info_doc); + g_personal_info_doc = NULL; + return -1; + } + + while (cur != NULL) { + if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_SET)) { + xmlNodePtr personal_voice_node = NULL; + personal_voice_node = xmlNewNode(NULL, (const xmlChar *)TTS_TAG_PERSONAL_VOICE); + + xmlNodePtr info_node = NULL; + info_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_LANGUAGE); + xmlNodeSetContent(info_node, (const xmlChar*)language); + xmlAddChild(personal_voice_node, info_node); + + info_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_UNIQUE_ID); + xmlNodeSetContent(info_node, (const xmlChar*)unique_id); + xmlAddChild(personal_voice_node, info_node); + + info_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_DISPLAY_NAME); + xmlNodeSetContent(info_node, (const xmlChar*)display_name); + xmlAddChild(personal_voice_node, info_node); + + info_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_PERSONAL_VOICE_DEVICE_NAME); + xmlNodeSetContent(info_node, (const xmlChar*)device_name); + xmlAddChild(personal_voice_node, info_node); + + xmlAddChild(cur, personal_voice_node); + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] Finish to add personal voice info"); + // break; + } + cur = cur->next; + } + } else { + switch (errno) { + case ENOENT: + SLOG(LOG_INFO, TAG_TTSCONFIG, "[INFO] No such file or directory. Create new personal info."); + int ret = __create_personal_info_xml(engine_id, language, unique_id, display_name, device_name); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to create new personal info"); + return -1; + } + SLOG(LOG_INFO, TAG_TTSCONFIG, "[INFO] Success to create new personal info"); + break; + default: + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to access to %s (%d)", path, errno); + return -1; + } + } + + int ret = xmlSaveFormatFile(path, g_personal_info_doc, 1); + SLOG(LOG_ERROR, TAG_TTSCONFIG, "xmlSaveFile to path(%s) (%d)", path, ret); + if (0>ret) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Save result : %d", ret); + } else { + static FILE* pFile; + pFile = fopen(path, "r"); + int fd = -1; + if (NULL == pFile) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to open file %s", path); + } else { + fd = fileno(pFile); + fsync(fd); + fclose(pFile); + SLOG(LOG_INFO, TAG_TTSCONFIG, "[DEBUG] Success to fsync %s", path); + } + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[DEBUG] Success to save %s", path); + } + + /* Set mode */ + if (0 > chmod(path, 0664)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to change file mode : %d", ret); + } + + if (NULL != g_personal_info_doc) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] doc path(%p)", g_personal_info_doc); + xmlFreeDoc(g_personal_info_doc); + g_personal_info_doc = NULL; + } + + return 0; +} + +int tts_parser_get_personal_info(const char* path, tts_personal_info_s** personal_info) +{ + if (NULL == path || NULL == personal_info) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Input parameter is NULL"); + return -1; + } + + xmlDocPtr doc = NULL; + xmlNodePtr cur = NULL; + + if (0 == access(path, F_OK)) { + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] Success to access to %s", path); + doc = xmlParseFile(path); + if (doc == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to parse xml file. errno(%d)", errno); + return -1; + } + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Fail to access to %s (%d)", path, errno); + return -1; + } + + cur = xmlDocGetRootElement(doc); + if (cur == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document. doc path(%s, %p)", path, doc); + xmlFreeDoc(doc); + doc = NULL; + return -1; + } + + if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_PERSONAL_BASE_TAG)) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] The wrong type, root node is NOT 'tts-personal-voice'. doc path(%s, %p)", path, doc); + xmlFreeDoc(doc); + doc = NULL; + return -1; + } + + cur = cur->xmlChildrenNode; // tts_tag_personal_voice_set + if (cur == NULL) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Empty document. doc path(%s, %p)", path, doc); + xmlFreeDoc(doc); + doc = NULL; + return -1; + } + + /* alloc personal info */ + tts_personal_info_s* temp; + temp = (tts_personal_info_s*)calloc(1, sizeof(tts_personal_info_s)); + if (NULL == temp) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Out of memory. doc path(%s, %p)", path, doc); + xmlFreeDoc(doc); + doc = NULL; + return -1; + } + + temp->engine_id = NULL; + temp->personal_voices = NULL; + + while (cur != NULL) { + if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_SET)) { + xmlNodePtr personal_voice_node = NULL; + personal_voice_node = cur->xmlChildrenNode; + + while (NULL != personal_voice_node) { + if (0 == xmlStrcmp(personal_voice_node->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE)) { + xmlNodePtr info_node = NULL; + info_node = personal_voice_node->xmlChildrenNode; + + tts_config_personal_s* temp_personal_voice = (tts_config_personal_s*)calloc(1, sizeof(tts_config_personal_s)); + if (NULL == temp_personal_voice) { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Out of memory"); + break; + } + + while (NULL != info_node) { + if (0 == xmlStrcmp(info_node->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_LANGUAGE)) { + xmlChar *key = xmlNodeGetContent(info_node); + if (NULL != key) { + if (NULL != temp_personal_voice->language) { + free(temp_personal_voice->language); + temp_personal_voice->language = NULL; + } + temp_personal_voice->language = strdup((char*)key); + xmlFree(key); + key = NULL; + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] <%s> has no content", TTS_TAG_PERSONAL_VOICE_LANGUAGE); + } + } else if (0 == xmlStrcmp(info_node->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_UNIQUE_ID)) { + xmlChar *key = xmlNodeGetContent(info_node); + if (NULL != key) { + if (NULL != temp_personal_voice->unique_id) { + free(temp_personal_voice->unique_id); + temp_personal_voice->unique_id = NULL; + } + temp_personal_voice->unique_id = strdup((char*)key); + xmlFree(key); + key = NULL; + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] <%s> has no content", TTS_TAG_PERSONAL_VOICE_UNIQUE_ID); + } + } else if (0 == xmlStrcmp(info_node->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_DISPLAY_NAME)) { + xmlChar *key = xmlNodeGetContent(info_node); + if (NULL != key) { + if (NULL != temp_personal_voice->display_name) { + free(temp_personal_voice->display_name); + temp_personal_voice->display_name = NULL; + } + temp_personal_voice->display_name = strdup((char*)key); + xmlFree(key); + key = NULL; + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] <%s> has no content", TTS_TAG_PERSONAL_VOICE_DISPLAY_NAME); + } + } else if (0 == xmlStrcmp(info_node->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_DEVICE_NAME)) { + xmlChar *key = xmlNodeGetContent(info_node); + if (NULL != key) { + if (NULL != temp_personal_voice->device_name) { + free(temp_personal_voice->device_name); + temp_personal_voice->device_name = NULL; + } + temp_personal_voice->device_name = strdup((char*)key); + xmlFree(key); + key = NULL; + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] <%s> has no content", TTS_TAG_PERSONAL_VOICE_DEVICE_NAME); + } + } + info_node = info_node->next; + } + + temp->personal_voices = g_slist_append(temp->personal_voices, temp_personal_voice); + } + personal_voice_node = personal_voice_node->next; + } + } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_PERSONAL_VOICE_ENGINE_ID)) { + xmlChar *key = xmlNodeGetContent(cur); + if (NULL != key) { + if (NULL != temp->engine_id) { + free(temp->engine_id); + temp->engine_id = NULL; + } + temp->engine_id = strdup((char*)key); + xmlFree(key); + key = NULL; + } else { + SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] <%s> has no content", TTS_TAG_PERSONAL_VOICE_ENGINE_ID); + } + } + cur = cur->next; + } + + if (NULL != doc) { + SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] doc path(%s, %p)", path, doc); + xmlFreeDoc(doc); + doc = NULL; + } + + if (NULL == temp->engine_id) { + /* Invalid engine */ + SECURE_SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Invalid engine : %s", path); + // free personal info + return -1; + } + + *personal_info = temp; + + return 0; + +} + int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info) { if (NULL == path || NULL == engine_info) { diff --git a/common/tts_config_parser.h b/common/tts_config_parser.h index a39d935..db59b2a 100644 --- a/common/tts_config_parser.h +++ b/common/tts_config_parser.h @@ -57,6 +57,18 @@ typedef struct { double bg_volume_ratio; } tts_config_s; +typedef struct { + char* language; + char* unique_id; + char* display_name; + char* device_name; +} tts_config_personal_s; + +typedef struct { + char* engine_id; + GSList* personal_voices; +} tts_personal_info_s; + /* Get engine information */ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info); @@ -91,6 +103,10 @@ int tts_parser_copy_xml(const char* original, const char* destination); int tts_parser_reset(); +int tts_parser_update_personal_info(const char* path, const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name); + +int tts_parser_get_personal_info(const char* path, tts_personal_info_s** personal_info); + #ifdef __cplusplus } #endif diff --git a/common/tts_defs.h b/common/tts_defs.h index 18a300d..0f6953e 100644 --- a/common/tts_defs.h +++ b/common/tts_defs.h @@ -111,6 +111,7 @@ extern "C" { #define TTS_HOME tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts") #define TTS_DOWNLOAD_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts/engine-info") +#define TTS_DOWNLOAD_PERSONAL_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_GLOBALUSER_DATA"), ".voice/tts/personal-info") diff --git a/include/ttse.h b/include/ttse.h index df897fa..ca92981 100755 --- a/include/ttse.h +++ b/include/ttse.h @@ -719,6 +719,8 @@ int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback); */ int ttse_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback); +int ttse_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data); + #ifdef __cplusplus } diff --git a/packaging/tts.spec b/packaging/tts.spec index 1d2bdac..bd5126b 100644 --- a/packaging/tts.spec +++ b/packaging/tts.spec @@ -199,9 +199,12 @@ mkdir -p -m 0775 %{TZ_SYS_GLOBALUSER_DATA}/.voice chsmack -t %{TZ_SYS_GLOBALUSER_DATA}/.voice chsmack -a "User::App::Shared" %{TZ_SYS_GLOBALUSER_DATA}/.voice mkdir -p %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/engine-info +mkdir -p -m 0775 %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/personal-info chsmack -a "User::App::Shared" %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts chsmack -t %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/engine-info +chsmack -t %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/personal-info chsmack -a "User::App::Shared" %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/engine-info +chsmack -a "User::App::Shared" %{TZ_SYS_GLOBALUSER_DATA}/.voice/tts/personal-info chown -R ui_fw:users %{TZ_SYS_GLOBALUSER_DATA}/.voice %postun -p /sbin/ldconfig diff --git a/server/ttsd_config.c b/server/ttsd_config.c index 3743d53..3530106 100644 --- a/server/ttsd_config.c +++ b/server/ttsd_config.c @@ -260,3 +260,20 @@ int ttsd_config_set_instant_reprepare_client(const unsigned int uid) return TTSD_ERROR_NONE; } + +int ttsd_config_update_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data) +{ + char* engine_id = NULL; + // if (0 != tts_config_mgr_get_engine(&engine_id)) { + // SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to get engine id"); + // return TTSD_ERROR_OPERATION_FAILED; + // } + + int ret = tts_config_mgr_update_personal_voice(engine_id, language, unique_id, display_name, device_name); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to update personal voice to xml"); + return TTSD_ERROR_OPERATION_FAILED; + } + + return 0; +} diff --git a/server/ttsd_config.h b/server/ttsd_config.h index b1a8bb6..70097e0 100644 --- a/server/ttsd_config.h +++ b/server/ttsd_config.h @@ -58,6 +58,8 @@ int ttsd_config_get_instant_reprepare_client(unsigned int *uid); int ttsd_config_set_instant_reprepare_client(const unsigned int uid); +int ttsd_config_update_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data); + #ifdef __cplusplus } #endif diff --git a/server/ttsd_server.c b/server/ttsd_server.c index c1c91e4..d39621d 100644 --- a/server/ttsd_server.c +++ b/server/ttsd_server.c @@ -1621,6 +1621,18 @@ int ttsd_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback) return ret; } +int ttsd_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data) +{ + SLOG(LOG_DEBUG, tts_tag(), "[Server] Set private data requested cb"); + + int ret = ttsd_config_update_personal_voice(language, unique_id, display_name, device_name, NULL); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to update personal voice"); + } + + 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 ea20c7b..d7d9afe 100644 --- a/server/ttsd_server.h +++ b/server/ttsd_server.h @@ -45,6 +45,8 @@ int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback); int ttsd_set_personal_tts_id_set_cb(ttse_set_personal_tts_id_cb callback); +int ttsd_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data); + /* * Server API for client diff --git a/server/ttse.c b/server/ttse.c index 67a159b..2472ce4 100755 --- a/server/ttse.c +++ b/server/ttse.c @@ -121,6 +121,18 @@ static bool __is_test_app() return is_test_app; } +int ttse_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data) +{ + SLOG(LOG_INFO, tts_tag(), "[INFO] TTS Engine send personal voices list : language(%s), unique_id(%s), display_name(%s), device_name(%s)", language, unique_id, display_name, device_name); + + int ret = ttsd_send_personal_voice(language, unique_id, display_name, device_name, NULL); + if (0 != ret) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to send personal voice"); + } + + return TTSE_ERROR_NONE; +} + int ttse_main(int argc, char** argv, ttse_request_callback_s *callback) { if (false == is_feature_enabled()) { -- 2.7.4