From 920e433fd413c6dcd37ee4d82b5596a0831badf9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 7 Apr 2008 20:22:38 +0000 Subject: [PATCH] less is more git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8054 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- conf/autoload_configs/ivr.conf.xml | 14 +++++---- src/include/switch_ivr.h | 12 ++------ src/switch_core_asr.c | 4 +-- src/switch_ivr_menu.c | 49 +++--------------------------- src/switch_ivr_play_say.c | 18 ++++++----- 5 files changed, 28 insertions(+), 69 deletions(-) diff --git a/conf/autoload_configs/ivr.conf.xml b/conf/autoload_configs/ivr.conf.xml index 6c3d964479..86d2bd7741 100644 --- a/conf/autoload_configs/ivr.conf.xml +++ b/conf/autoload_configs/ivr.conf.xml @@ -4,12 +4,12 @@ - + @@ -37,11 +37,13 @@ greet-short="say:Press 1 to join the conference, Press 2 to join the other conference" invalid-sound="say:invalid extension" exit-sound="say:exit sound" timeout ="15" - max-failures="3" - tts-voice="callie" tts-engine="cepstral"> + max-failures="3"> - - + + --> diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 625084aaa4..397255d287 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -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. diff --git a/src/switch_core_asr.c b/src/switch_core_asr.c index 3fd88f1463..c29e720e77 100644 --- a/src/switch_core_asr.c +++ b/src/switch_core_asr.c @@ -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; } diff --git a/src/switch_ivr_menu.c b/src/switch_ivr_menu.c index 2eae4c3470..9b20b20fb0 100644 --- a/src/switch_ivr_menu.c +++ b/src/switch_ivr_menu.c @@ -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; diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 14af1c8ab6..347a40183b 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -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;