]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
prefer text attribute over file attribute and tag body for speak and say
authorRaymond Chandler <intralanman@gmail.com>
Tue, 15 Jan 2013 23:43:38 +0000 (18:43 -0500)
committerRaymond Chandler <intralanman@gmail.com>
Tue, 15 Jan 2013 23:43:38 +0000 (18:43 -0500)
src/mod/applications/mod_httapi/mod_httapi.c

index 8d0b2ae294d0e74e0854759ac1f07472d28e0a68..a756ff497838d91bc20040daae2694bb36610d25 100644 (file)
@@ -396,6 +396,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
        const char *say_gender = NULL;
        const char *sp_engine = NULL;
        const char *sp_grammar = NULL;
+       const char *text = NULL;
        char *free_string = NULL;
 
        if (!strcasecmp(tag_name, "say")) {
@@ -403,8 +404,17 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
                say_type = switch_xml_attr(tag, "type");
                say_method = switch_xml_attr(tag, "method");
                say_gender = switch_xml_attr(tag, "gender");
+               text = switch_xml_attr(tag, "text");
                
-               if (zstr(say_lang) || zstr(say_type) || zstr(say_method) || zstr(body)) {
+               if (zstr(text)) {
+                       if (!zstr(file)) {
+                               text = file;
+                       } else if (!zstr(body)) {
+                               text = body;
+                       }
+               }
+
+               if (zstr(say_lang) || zstr(say_type) || zstr(say_method) || zstr(text)) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "speak: missing required attributes or text! (language) (type) (method) \n");
                        return SWITCH_STATUS_FALSE;
                }
@@ -414,6 +424,15 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
        } else if (!strcasecmp(tag_name, "speak")) {
                tts_engine = switch_xml_attr(tag, "engine");
                tts_voice = switch_xml_attr(tag, "voice");
+               text = switch_xml_attr(tag, "text");
+
+               if (zstr(text)) {
+                       if (!zstr(file)) {
+                               text = file;
+                       } else if (!zstr(body)) {
+                               text = body;
+                       }
+               }
 
                if (zstr(tts_engine)) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "speak: missing engine attribute!\n");
@@ -556,9 +575,9 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
 
        do {
                if (speak) {
-                       status = switch_ivr_speak_text(client->session, tts_engine, tts_voice, (char *)file, args);
+                       status = switch_ivr_speak_text(client->session, tts_engine, tts_voice, (char *)text, args);
                } else if (say) {
-                       status = switch_ivr_say(client->session, body, say_lang, say_type, say_method, say_gender, args);
+                       status = switch_ivr_say(client->session, (char *)text, say_lang, say_type, say_method, say_gender, args);
                } else if (play) {
                        status = switch_ivr_play_file(client->session, NULL, file, args);
                } else if (speech) {