static int g_max_text_size = -1;
+/* for repetition */
+static char* g_language = NULL;
+
+static int g_voice_type = -1;
+
+static int g_speed = -1;
+
+
/* Function definition */
static Eina_Bool __tts_notify_state_changed(void *data);
static Eina_Bool __tts_notify_error(void *data);
language, voice_type, data->default_voice_changed_user_data);
}
+ /* Check whether language is changed or not. If it is changed, make 'text_repeat' NULL */
+ if (0 != strncmp(before_lang, language, strlen(before_lang))) {
+ if (NULL != data->text_repeat) {
+ free(data->text_repeat);
+ data->text_repeat = NULL;
+ }
+ }
+
/* Next item */
iter = g_list_next(iter);
}
}
}
+ if (NULL != g_language) {
+ free(g_language);
+ g_language = NULL;
+ }
+
tts = NULL;
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
}
SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - text is '%s'", text);
+ /* save texts for repetition */
+ if (NULL != client->text_repeat) {
+ free(client->text_repeat);
+ client->text_repeat = NULL;
+ }
+
+ client->text_repeat = strdup(text);
+
+ if (NULL != g_language) {
+ free(g_language);
+ g_language = NULL;
+ }
+ if (NULL == language)
+ g_language = NULL;
+ else
+ g_language = strdup(language);
+
+ g_voice_type = voice_type;
+ g_speed = speed;
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] repeat: text(%s), language(%s), voice type(%d), speed(%d)", client->text_repeat, g_language, g_voice_type, g_speed);
+
/* change default language value */
char* temp = NULL;
return TTS_ERROR_NONE;
}
+
+int tts_repeat(tts_h tts, char** text_repeat, int* utt_id)
+{
+ if (0 != __tts_get_feature_enabled()) {
+ return TTS_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_INFO, TAG_TTSC, "@@@ Repeat TTS");
+
+ if (NULL == tts) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null.");
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == text_repeat || NULL == utt_id) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null.");
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ *text_repeat = NULL;
+ *utt_id = -1;
+
+ tts_client_s* client = tts_client_get(tts);
+
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid.");
+ SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (TTS_STATE_READY != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid. (%d)", client->current_state);
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ /* Clear the legacy and Add texts to be played repeatedly */
+ int ret = -1;
+ ret = tts_stop(tts);
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to clear the legacy");
+ return ret;
+ }
+
+ if (NULL != client->text_repeat) {
+ char* tmp_text = strdup(client->text_repeat);
+ char* tmp_lang = NULL;
+ if (NULL != g_language) {
+ tmp_lang = strdup(g_language);
+ }
+ ret = tts_add_text(tts, tmp_text, tmp_lang, g_voice_type, g_speed, utt_id);
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to add texts for repetition.");
+ if (NULL != tmp_text) {
+ free(tmp_text);
+ tmp_text = NULL;
+ }
+ if (NULL != tmp_lang) {
+ free(tmp_lang);
+ tmp_lang = NULL;
+ }
+ return ret;
+ }
+ *text_repeat = strdup(client->text_repeat);
+ SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] text to repeat(%s), utt_id(%d)", *text_repeat, *utt_id);
+ if (NULL != tmp_text) {
+ free(tmp_text);
+ tmp_text = NULL;
+ }
+ if (NULL != tmp_lang) {
+ free(tmp_lang);
+ tmp_lang = NULL;
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] There is no previous added texts. Please add texts");
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ /* Play added texts */
+ ret = tts_play(tts);
+ if (TTS_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to play texts for repetition.");
+ if (NULL != *text_repeat) {
+ free(*text_repeat);
+ *text_repeat = NULL;
+ }
+ *utt_id = -1;
+ return ret;
+ }
+
+ return TTS_ERROR_NONE;
+}