]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5773 --resolve mod_ssml: allow rendering of documents if TTS is not configured
authorChris Rienzo <chris.rienzo@grasshopper.com>
Tue, 15 Oct 2013 19:50:45 +0000 (15:50 -0400)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Tue, 15 Oct 2013 19:51:04 +0000 (15:51 -0400)
src/mod/formats/mod_ssml/mod_ssml.c

index cb29c5e79d5435c63852d6c91910a2c932e1332d..8b172721c7462f08f6a8c0cd6776f7e90fabf478 100644 (file)
@@ -692,11 +692,14 @@ static int get_file_from_macro(struct ssml_parser *parsed_data, char *to_say)
 static int get_file_from_voice(struct ssml_parser *parsed_data, char *to_say)
 {
        struct ssml_node *cur_node = parsed_data->cur_node;
-       char *file = switch_core_sprintf(parsed_data->pool, "%s%s", cur_node->tts_voice->prefix, to_say);
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding <%s>: \"%s\"\n", cur_node->tag_name, file);
-       parsed_data->files[parsed_data->num_files].name = file;
-       parsed_data->files[parsed_data->num_files++].prefix = NULL;
-       return 1;
+       if (cur_node->tts_voice) {
+               char *file = switch_core_sprintf(parsed_data->pool, "%s%s", cur_node->tts_voice->prefix, to_say);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding <%s>: \"%s\"\n", cur_node->tag_name, file);
+               parsed_data->files[parsed_data->num_files].name = file;
+               parsed_data->files[parsed_data->num_files++].prefix = NULL;
+               return 1;
+       }
+       return 0;
 }
 
 /**
@@ -708,7 +711,7 @@ static int process_cdata_tts(struct ssml_parser *parsed_data, char *data, size_t
        if (!len) {
                return IKS_OK;
        }
-       if (cur_node && cur_node->tts_voice && parsed_data->num_files < parsed_data->max_files) {
+       if (cur_node && parsed_data->num_files < parsed_data->max_files) {
                int i = 0;
                int empty = 1;
                char *to_say;
@@ -728,7 +731,9 @@ static int process_cdata_tts(struct ssml_parser *parsed_data, char *data, size_t
                to_say[len] = '\0';
                if (!cur_node->say_macro || !get_file_from_macro(parsed_data, to_say)) {
                        /* use voice instead */
-                       get_file_from_voice(parsed_data, to_say);
+                       if (!get_file_from_voice(parsed_data, to_say)) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No TTS voices available to render text!\n");
+                       }
                }
                free(to_say);
                return IKS_OK;