#define TTS_TAG_ENGINE_CREDENTIAL "credential"
#define TTS_TAG_ENGINE_TEXT_SIZE "text-size"
-#define TTS_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice")
-#define TTS_HOME tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts")
-#define TTS_ENGINE_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice/tts/1.0")
-#define TTS_ENGINE_INFO tzplatform_mkpath(TZ_USER_SHARE, ".voice/tts/1.0/engine-info")
+#define TTS_TAG_VOICE_BASE "tts-voice"
+
+#define TTS_CONFIG_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice")
+#define TTS_HOME tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/tts")
+#define TTS_ENGINE_BASE tzplatform_mkpath(tzplatform_getid("TZ_USER_HOME"), "share/.voice/tts/1.0")
+#define TTS_ENGINE_INFO tzplatform_mkpath(tzplatform_getid("TZ_USER_SHARE"), ".voice/tts/1.0/engine-info")
+
+#define TTS_VOICE_INFO tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "voice/tts/1.0/tts-voice.xml")
#define TTS_GLOBAL_CONFIG_BASE "/etc/skel/share/.voice"
#define TTS_GLOBAL_HOME "/etc/skel/share/.voice/tts"
#define TTS_METADATA_TEXT_SIZE "http://tizen.org/metadata/tts-engine/text-size"
#define TTS_METADATA_PITCH_SUPPORT "http://tizen.org/metadata/tts-engine/pitch-support"
+#define TTS_MAX_TEXT_SIZE "2000"
+
/* Define Macro */
#define FREE(x) { if (NULL != x) { free(x); x = NULL; } }
#define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } }
const char *value;
} metadata;
+typedef struct {
+ char *lang;
+ char *type;
+} voice_info_s;
+
+typedef struct {
+ voice_info_s *voice_info;
+ int size;
+} voice_info_list_s;
+
static xmlDocPtr g_doc;
GumUser *g_guser = NULL;
uid_t g_uid = 301; // app_fw
char *g_dir_engine_base = NULL;
char *g_dir_engine_info = NULL;
+GSList *g_voice_info_list = NULL;
+
static int __create_engine_info_xml(const char *pkgid)
{
LOGD("@@@ Create engine info doc");
xmlAddChild(voices_node, voice_node);
voice = strsep(&tmp_lang, ",");
}
+
+ /* add extra voices */
+ LOGD("Add extra voices");
+ if (NULL != g_voice_info_list) {
+ GSList *iter;
+ voice_info_s *extra_voice = NULL;
+ for (iter = g_voice_info_list ; iter != NULL ; iter = g_slist_next(iter)) {
+ extra_voice = (voice_info_s*)iter->data;
+ if (NULL != extra_voice) {
+ lang = strdup(extra_voice->lang);
+ type = strdup(extra_voice->type);
+ LOGD("lang(%s), type(%s)", lang, type);
+
+ if (NULL != lang) {
+ voice_node = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_VOICE);
+ xmlSetProp(voice_node, (const xmlChar*)TTS_TAG_ENGINE_VOICE_TYPE, (const xmlChar*)type);
+ xmlNodeSetContent(voice_node, (const xmlChar*)lang);
+ xmlAddChild(voices_node, voice_node);
+ }
+
+ LOGD("Finish to add voice node");
+
+ if (NULL != lang) {
+ free(lang);
+ }
+ if (NULL != type) {
+ free(type);
+ }
+ LOGD("Memory release");
+
+ if (NULL != extra_voice->lang) {
+ free(extra_voice->lang);
+ }
+ if (NULL != extra_voice->type) {
+ free(extra_voice->type);
+ }
+ LOGD("Free extra_voice");
+ free(extra_voice);
+ extra_voice = NULL;
+ }
+ }
+
+ LOGD("Free voice info list");
+ g_slist_free(g_voice_info_list);
+ g_voice_info_list = NULL;
+ }
+
xmlAddChild(root, voices_node);
FREE(tmp_free)
}
+static int __get_voice_inxml()
+{
+ xmlDocPtr doc = NULL;
+ xmlNodePtr cur = NULL;
+
+ LOGD("TTS voice info xml (%s)", TTS_VOICE_INFO);
+
+ if (0 != access(TTS_VOICE_INFO, F_OK)) {
+ LOGD("There is no extra voice info.");
+ return 0;
+ } else {
+ doc = xmlParseFile(TTS_VOICE_INFO);
+ if (NULL == doc) {
+ LOGE("Fail to parse file");
+ return -1;
+ }
+
+ cur = xmlDocGetRootElement(doc);
+ if (NULL == cur) {
+ LOGE("Empty document");
+ xmlFreeDoc(doc);
+ return -1;
+ }
+
+ if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_VOICE_BASE)) {
+ LOGE("root node is NOT %s", TTS_TAG_VOICE_BASE);
+ xmlFreeDoc(doc);
+ return -1;
+ }
+
+ cur = cur->xmlChildrenNode;
+ if (NULL == cur) {
+ LOGE("<tts-voice> child NULL");
+ xmlFreeDoc(doc);
+ return -1;
+ }
+
+ xmlChar *attr = NULL;
+ xmlChar *key = NULL;
+// char lang[16];
+// char type[16];
+
+ while (NULL != cur) {
+ if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_VOICE_SET)) {
+ LOGD("<voices>");
+ xmlNodePtr voice_node = NULL;
+ voice_node = cur->xmlChildrenNode;
+
+ while (NULL != voice_node) {
+ if (0 == xmlStrcmp(voice_node->name, (const xmlChar *)TTS_TAG_ENGINE_VOICE)) {
+ voice_info_s *voice_info = (voice_info_s *)calloc(1, sizeof(voice_info_s));
+ if (NULL == voice_info) {
+ LOGE("Fail to allocate memory");
+ xmlFreeDoc(doc);
+ return -1;
+ }
+
+ LOGD("Get property and keys");
+ attr = xmlGetProp(voice_node, (const xmlChar *)TTS_TAG_ENGINE_VOICE_TYPE);
+ if (NULL != attr) {
+// strncpy(type, (char*)attr, strlen((char*)attr));
+ voice_info->type = strdup((char*)attr);
+ LOGD("type(%s)", voice_info->type);
+ xmlFree(attr);
+ attr = NULL;
+ } else {
+ LOGD("No voice type");
+ }
+
+ key = xmlNodeGetContent(voice_node);
+ if (NULL != key) {
+// strncpy(lang, (char*)key, strlen((char*)key));
+ voice_info->lang = strdup((char*)key);
+ LOGD("lang(%s)", voice_info->lang);
+ xmlFree(key);
+ key = NULL;
+ } else {
+ LOGD("No voice info");
+ }
+
+ g_voice_info_list = g_slist_append(g_voice_info_list, voice_info);
+ }
+
+ voice_node = voice_node->next;
+ }
+ } else {
+ LOGD("Unknown tag (%s)", (const char*)cur->name);
+ }
+
+ cur = cur->next;
+ }
+
+ xmlFreeDoc(doc);
+ }
+
+ return 0;
+}
+
static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *list)
{
GList *iter = NULL;
metadata *md = NULL;
+ bool isTextsize = false;
+
__create_engine_info_xml(pkgid);
xmlNodePtr root = NULL;
if (NULL != md && NULL != md->key) {
LOGD(" - key(%s) value(%s)", md->key, md->value);
if (!strcmp(md->key, TTS_METADATA_LANGUAGE)) {
+ __get_voice_inxml();
__insert_language_from_metadata(root, md->value);
} else if (!strcmp(md->key, TTS_METADATA_CREDENTIAL_REQUIRED)) {
cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_CREDENTIAL);
cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_TEXT_SIZE);
xmlNodeSetContent(cur, (const xmlChar*)md->value);
xmlAddChild(root, cur);
+ isTextsize = true;
} else if (!strcmp(md->key, TTS_METADATA_PITCH_SUPPORT)) {
cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_PITCH_SUPPORT);
xmlNodeSetContent(cur, (const xmlChar*)md->value);
iter = g_list_next(iter);
}
+ if (false == isTextsize) {
+ cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_TEXT_SIZE);
+ xmlNodeSetContent(cur, (const xmlChar*)TTS_MAX_TEXT_SIZE);
+ xmlAddChild(root, cur);
+ LOGD("[DEBUG] Max text size is set as %s.", TTS_MAX_TEXT_SIZE);
+ }
+
cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_ID);
xmlNodeSetContent(cur, (const xmlChar*)pkgid);
xmlAddChild(root, cur);
uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
if (globalapp_uid == g_uid) {
g_user_type = g_strdup("admin");
+ LOGD("[DEBUG] g_user_type: %s (%d)", g_user_type, globalapp_uid);
} else {
g_guser = gum_user_get_sync(g_uid, FALSE);
if (NULL == g_guser) {
g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
g_user_type = g_strdup(gum_user_type_to_string(g_ut));
+
+ LOGD("[DEBUG] g_user_type: %s (%d)", g_user_type, globalapp_uid);
}
if (NULL == g_user_type) {