less is more

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8054 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-04-07 20:22:38 +00:00
parent 13b7fd9695
commit 920e433fd4
5 changed files with 28 additions and 69 deletions

View File

@ -4,12 +4,12 @@
<!-- demo IVR, Main Menu -->
<menu name="demo_ivr"
greet-long="phrase:demo_ivr_main_menu"
greet-short="phrase:demo_ivr_main_menu_short""
greet-short="phrase:demo_ivr_main_menu_short"
invalid-sound="voicemail/vm-hello.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout ="15"
max-failures="3">
<entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswtich.org"/>
<entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswitch.org"/>
<entry action="menu-call-transfer" digits="2" param="9996"/> <!-- FS echo -->
<entry action="menu-call-transfer" digits="3" param="9999"/> <!-- MOH -->
<entry action="menu-sub" digits="4" param="demo_ivr_submenu"/> <!-- demo sub menu -->
@ -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">
<entry action="menu-exit" digits="*"/>
<entry action="menu-say-text" digits="1" param="You pressed 1"/>
<entry action="menu-call-transfer" digits="2" param="1000"/>
<entry action="menu-playback" digits="1" param="say:You pressed 1"/>
<entry action="menu-call-transfer" digits="2" param=
"1000"/>
<entry action="menu-call-transfer" digits="3" param="1001"/>
</menu>
-->

View 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.

View 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;
}

View 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;

View 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;