]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
less is more
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Apr 2008 20:22:38 +0000 (20:22 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Apr 2008 20:22:38 +0000 (20:22 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8054 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/autoload_configs/ivr.conf.xml
src/include/switch_ivr.h
src/switch_core_asr.c
src/switch_ivr_menu.c
src/switch_ivr_play_say.c

index 6c3d9644790f235782a8d3da7f194fd9f4963c93..86d2bd77415e8bdd805eaed338499dce19bf7d82 100644 (file)
@@ -4,12 +4,12 @@
     <!-- demo IVR, Main Menu -->\r
     <menu name="demo_ivr"\r
           greet-long="phrase:demo_ivr_main_menu"\r
-          greet-short="phrase:demo_ivr_main_menu_short""\r
+          greet-short="phrase:demo_ivr_main_menu_short"\r
           invalid-sound="voicemail/vm-hello.wav"\r
           exit-sound="voicemail/vm-goodbye.wav"\r
           timeout ="15"\r
           max-failures="3">\r
-      <entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswtich.org"/>\r
+      <entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswitch.org"/>\r
       <entry action="menu-call-transfer" digits="2" param="9996"/>    <!-- FS echo -->\r
       <entry action="menu-call-transfer" digits="3" param="9999"/>    <!-- MOH -->\r
       <entry action="menu-sub" digits="4" param="demo_ivr_submenu"/>  <!-- demo sub menu -->\r
           greet-short="say:Press 1 to join the conference, Press 2 to join the other conference"\r
           invalid-sound="say:invalid extension"\r
           exit-sound="say:exit sound" timeout ="15"\r
-          max-failures="3"\r
-          tts-voice="callie" tts-engine="cepstral">\r
+          max-failures="3">\r
       <entry action="menu-exit" digits="*"/>\r
-      <entry action="menu-say-text" digits="1" param="You pressed 1"/>\r
-      <entry action="menu-call-transfer" digits="2" param="1000"/>\r
+      <entry action="menu-playback" digits="1" param="say:You pressed 1"/>\r
+      <entry action="menu-call-transfer" digits="2" param=\r
+\r
+\r
+"1000"/>\r
       <entry action="menu-call-transfer" digits="3" param="1001"/>\r
     </menu>\r
 -->\r
index 625084aaa4fa3a7b5823dbc3e30228878cb5fae1..397255d287b5d99c99eccf85697426f1d3a32cd0 100644 (file)
@@ -618,11 +618,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
                 SWITCH_IVR_ACTION_EXECMENU,    /* Goto another menu in the stack. */
                 SWITCH_IVR_ACTION_EXECAPP,     /* Execute an application.         */
                 SWITCH_IVR_ACTION_PLAYSOUND,   /* Play a sound.                   */
-                SWITCH_IVR_ACTION_SAYTEXT,     /* say text.                       */
-                SWITCH_IVR_ACTION_SAYPHRASE,   /* say a phrase macro.                       */
                 SWITCH_IVR_ACTION_BACK,        /* Go back 1 menu.                 */
                 SWITCH_IVR_ACTION_TOMAIN,      /* Go back to the top level menu.  */
-                SWITCH_IVR_ACTION_TRANSFER,    /* Transfer caller to another ext. */
                 SWITCH_IVR_ACTION_NOOP /* No operation                    */
         } switch_ivr_action_t;
         struct switch_ivr_menu;
@@ -640,9 +637,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
  *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops.
  *\param exit_sound Optional pointer to a sound to play upon exiting the menu.
  *\param invalid_sound Optional pointer to a sound to play after invalid input.
- *\param tts_engine Text To Speech engine name.
- *\param tts_voice Text To Speech engine voice name.
- *\param phrase_lang the language to use for the phrase macros.
  *\param timeout A number of milliseconds to pause before looping.
  *\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
  *\param pool memory pool (NULL to create one).
@@ -655,9 +649,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
                                                                                                         const char *short_greeting_sound,
                                                                                                         const char *exit_sound,
                                                                                                         const char *invalid_sound,
-                                                                                                        const char *tts_engine,
-                                                                                                        const char *tts_voice,
-                                                                                                        const char *phrase_lang, int timeout, int max_failures, switch_memory_pool_t *pool);
+                                                                                                        int timeout, 
+                                                                                                        int max_failures, 
+                                                                                                        switch_memory_pool_t *pool);
 
 /*!
  *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
index 3fd88f1463799311b61a7befbc4521485f3f4750..c29e720e77477a3a6d79d8fa9738326e3b4957ff 100644 (file)
@@ -47,9 +47,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
        char buf[256] = "";
        char *param = NULL;
 
-       if (strchr(module_name, ':')) {
+       if (strchr(module_name, '@')) {
                switch_set_string(buf, module_name);
-               if ((param = strchr(buf, ':'))) {
+               if ((param = strchr(buf, '@'))) {
                        *param++ = '\0';
                        module_name = buf;
                }
index 2eae4c347002d421b897c613e09aa38f36040589..9b20b20fb0326639e9fe9eea0d3c65be06be2232 100644 (file)
@@ -40,9 +40,6 @@ struct switch_ivr_menu {
        char *short_greeting_sound;
        char *invalid_sound;
        char *exit_sound;
-       char *tts_engine;
-       char *tts_voice;
-       char *phrase_lang;
        char *buf;
        char *ptr;
        int max_failures;
@@ -93,8 +90,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
                                                                                                         const char *short_greeting_sound,
                                                                                                         const char *invalid_sound,
                                                                                                         const char *exit_sound,
-                                                                                                        const char *tts_engine,
-                                                                                                        const char *tts_voice, const char *phrase_lang, int timeout, int max_failures,
+                                                                                                        int timeout, int max_failures,
                                                                                                         switch_memory_pool_t *pool)
 {
        switch_ivr_menu_t *menu;
@@ -138,18 +134,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
                menu->exit_sound = switch_core_strdup(menu->pool, exit_sound);
        }
 
-       if (!switch_strlen_zero(tts_engine)) {
-               menu->tts_engine = switch_core_strdup(menu->pool, tts_engine);
-       }
-
-       if (!switch_strlen_zero(tts_voice)) {
-               menu->tts_voice = switch_core_strdup(menu->pool, tts_voice);
-       }
-
-       if (!switch_strlen_zero(phrase_lang)) {
-               menu->phrase_lang = switch_core_strdup(menu->pool, phrase_lang);
-       }
-
        menu->max_failures = max_failures;
 
        menu->timeout = timeout;
@@ -259,17 +243,8 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me
                args.buf = ptr;
                args.buflen = len;
 
-               if (strlen(sound) > 4 && strncasecmp(sound, "say:", 4) == 0) {
-                       if (menu->tts_engine && menu->tts_voice) {
-                               status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, sound + 4, &args);
-                       } else {
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
-                       }
-               } else if (strlen(sound) > 7 && strncasecmp(sound, "phrase:", 7) == 0) {
-                       status = switch_ivr_phrase_macro(session, sound + 7, "", menu->phrase_lang, &args);
-               } else {
-                       status = switch_ivr_play_file(session, NULL, sound, &args);
-               }
+               status = switch_ivr_play_file(session, NULL, sound, &args);
+
                
                if (need) {
                        menu->ptr += strlen(menu->buf);
@@ -360,16 +335,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
                                        case SWITCH_IVR_ACTION_PLAYSOUND:
                                                status = switch_ivr_play_file(session, NULL, aptr, NULL);
                                                break;
-                                       case SWITCH_IVR_ACTION_SAYTEXT:
-                                               status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, aptr, NULL);
-                                               break;
-                                       case SWITCH_IVR_ACTION_SAYPHRASE:
-                                               status = switch_ivr_phrase_macro(session, aptr, "", menu->phrase_lang, NULL);
-                                               break;
-                                       case SWITCH_IVR_ACTION_TRANSFER:
-                                               switch_ivr_session_transfer(session, aptr, NULL, NULL);
-                                               running = 0;
-                                               break;
                                        case SWITCH_IVR_ACTION_EXECMENU:
                                                reps = -1;
                                                status = switch_ivr_menu_execute(session, stack, aptr, obj);
@@ -523,11 +488,8 @@ static struct iam_s {
        { "menu-sub", SWITCH_IVR_ACTION_EXECMENU},
        { "menu-exec-app", SWITCH_IVR_ACTION_EXECAPP}, 
        { "menu-play-sound", SWITCH_IVR_ACTION_PLAYSOUND}, 
-       { "menu-say-text", SWITCH_IVR_ACTION_SAYTEXT}, 
-       { "menu-say-phrase", SWITCH_IVR_ACTION_SAYPHRASE}, 
        { "menu-back", SWITCH_IVR_ACTION_BACK}, 
        { "menu-top", SWITCH_IVR_ACTION_TOMAIN}, 
-       { "menu-call-transfer", SWITCH_IVR_ACTION_TRANSFER},
        { NULL, 0}
 };
 
@@ -604,9 +566,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
                const char *greet_short = switch_xml_attr(xml_menu, "greet-short");     // if the attr doesn't exist, return NULL
                const char *invalid_sound = switch_xml_attr(xml_menu, "invalid-sound"); // if the attr doesn't exist, return NULL
                const char *exit_sound = switch_xml_attr(xml_menu, "exit-sound");       // if the attr doesn't exist, return NULL
-               const char *tts_engine = switch_xml_attr(xml_menu, "tts-engine");       // if the attr doesn't exist, return NULL
-               const char *tts_voice = switch_xml_attr(xml_menu, "tts-voice"); // if the attr doesn't exist, return NULL
-               const char *phrase_lang = switch_xml_attr(xml_menu, "phrase-lang");     // if the attr doesn't exist, return NULL
                const char *timeout = switch_xml_attr_soft(xml_menu, "timeout");        // if the attr doesn't exist, return ""
                const char *max_failures = switch_xml_attr_soft(xml_menu, "max-failures");      // if the attr doesn't exist, return ""
                switch_ivr_menu_t *menu = NULL;
@@ -618,7 +577,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
                                                                          greet_long,
                                                                          greet_short,
                                                                          invalid_sound,
-                                                                         exit_sound, tts_engine, tts_voice, phrase_lang, atoi(timeout) * 1000, atoi(max_failures), xml_menu_ctx->pool);
+                                                                         exit_sound, atoi(timeout) * 1000, atoi(max_failures), xml_menu_ctx->pool);
                // set the menu_stack for the caller
                if (status == SWITCH_STATUS_SUCCESS && *menu_stack == NULL) {
                        *menu_stack = menu;
index 14af1c8ab663fe1b8ab5882d5fcac69dd87cae59..347a40183b3fec388bef9bf54e618ef710245f8c 100644 (file)
@@ -706,15 +706,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 
                if (!strncasecmp(file, "phrase:", 7)) {
                        char *arg = NULL;
-                       char *lang = NULL;
+                       const char *lang = switch_channel_get_variable(channel, "language");
                        alt = file + 7;
                        dup = switch_core_session_strdup(session, alt);
 
-                       if ((lang = strchr(dup, ':'))) {
-                               *lang++ = '\0';
-                               if ((arg = strchr(lang, ':'))) {
-                                       *arg++ = '\0';
-                               }
+                       if ((arg = strchr(dup, ':'))) {
+                               *arg++ = '\0';
                        }
                        
                        if (dup) {
@@ -736,7 +733,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                }
                        }
                        if (engine && voice && text) {
-                               return switch_ivr_speak_text(session, engine, voice, dup, args);
+                               return switch_ivr_speak_text(session, engine, voice, text, args);
+                       } else if (engine && !(voice && text)) {
+                               text = engine;
+                               engine = (char *)switch_channel_get_variable(channel, "tts_engine");
+                               voice = (char *)switch_channel_get_variable(channel, "tts_voice");
+                               if (engine && text) {
+                                       return switch_ivr_speak_text(session, engine, voice, text, args);
+                               }
                        } else {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Args\n");
                                return SWITCH_STATUS_FALSE;