#define TTS_TAG_ENGINE_VOICE "voice"
#define TTS_TAG_ENGINE_VOICE_TYPE "type"
#define TTS_TAG_ENGINE_PITCH_SUPPORT "pitch-support"
+#define TTS_TAG_ENGINE_TEXT_SIZE "text-size"
#define TTS_TAG_CONFIG_BASE_TAG "tts-config"
#define TTS_TAG_CONFIG_ENGINE_ID "engine"
#define TTS_TAG_VOICE_TYPE_MALE "male"
#define TTS_TAG_VOICE_TYPE_CHILD "child"
+#define TTS_MAX_TEXT_SIZE 2000
extern char* tts_tag();
return -1;
}
+ bool isTextsize = false;
xmlDocPtr doc = NULL;
xmlNodePtr cur = NULL;
xmlChar *key = NULL;
temp->voices = NULL;
temp->setting = NULL;
temp->pitch_support = false;
+ temp->text_size = 0;
while (cur != NULL) {
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_NAME)) {
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_PITCH_SUPPORT);
}
+ } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_TEXT_SIZE)) {
+ isTextsize = true;
+ key = xmlNodeGetContent(cur);
+ if (NULL != key) {
+ temp->text_size = atoi((char*)key);
+ xmlFree(key);
+ } else {
+ SLOG(LOG_INFO, tts_tag(), "[INFO] text size is unlimited.");
+ temp->text_size = 0;
+ }
}
cur = cur->next;
}
+ if (false == isTextsize) {
+ temp->text_size = TTS_MAX_TEXT_SIZE;
+ }
+
xmlFreeDoc(doc);
doc = NULL;
- if (NULL == temp->name || NULL == temp->uuid) {
+ if (NULL == temp->uuid) {
/* Invalid engine */
SECURE_SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid engine : %s", path);
tts_parser_free_engine_info(temp);
SLOG(LOG_ERROR, tts_tag(), " Voice is NONE");
}
- SLOG(LOG_DEBUG, tts_tag(), "=====================");
+ SLOG(LOG_DEBUG, tts_tag(), "@@@");
return 0;
}
if (TTS_RETRY_COUNT == retry_count) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_CONFIG);
- xmlCleanupParser();
- return -1;
+ doc = xmlParseFile(TTS_DEFAULT_CONFIG);
+ if (NULL == doc) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", TTS_DEFAULT_CONFIG);
+ xmlCleanupParser();
+ return -1;
+ }
+ is_default_open = true;
+ break;
}
}
}
g_config_doc = doc;
if (true == is_default_open) {
- int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
- if (0 > ret) {
- SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
- }
+ int retry_count = 0;
+ int ret = -1;
+ do {
+ ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+ if (0 < ret)
+ break;
+ retry_count++;
+ usleep(10000);
+
+ if (TTS_RETRY_COUNT == retry_count) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ return -1;
+ }
+ } while (0 != ret);
/* Set mode */
- if (0 > chmod(TTS_CONFIG, 0666)) {
+ if (0 > chmod(TTS_CONFIG, 0600)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret);
}
int ret = xmlSaveFile(destination, doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", destination);
}
/* Set mode */
- if (0 > chmod(destination, 0666)) {
+ if (0 > chmod(destination, 0600)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret);
}
int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
}
return 0;
while (cur != NULL) {
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
xmlNodeSetContent(cur, (const xmlChar *)language);
- }
+ }
if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
switch (type) {
int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
}
return 0;
int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
}
return 0;
int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
}
return 0;
snprintf(temp, 10, "%d", value);
xmlNodeSetContent(cur, (const xmlChar *)temp);
break;
- }
+ }
cur = cur->next;
}
int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
if (0 > ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+ } else {
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
}
return 0;
return 0;
}
+
+int tts_parser_reset()
+{
+ SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Reset g_config_doc as %s", TTS_DEFAULT_CONFIG);
+
+ if (NULL != g_config_doc) {
+ xmlFreeDoc(g_config_doc);
+ g_config_doc = NULL;
+ }
+
+ g_config_doc = xmlParseFile(TTS_DEFAULT_CONFIG);
+ if (NULL == g_config_doc) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse %s", TTS_DEFAULT_CONFIG);
+ return -1;
+ }
+
+ int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+ if (0 > ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save %s", TTS_CONFIG);
+ }
+
+ return 0;
+}