update phrase interface

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3901 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-01-03 16:43:59 +00:00
parent 57c0d4bdc9
commit 6aaedb918c
2 changed files with 63 additions and 20 deletions

View File

@ -678,57 +678,89 @@
<language name="en" sound_path="/snds" tts_engine="cepstral" tts_voice="david"> <language name="en" sound_path="/snds" tts_engine="cepstral" tts_voice="david">
<macro name="msgcount"> <macro name="msgcount">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="execute" data="sleep(1000)"/> <match>
<action function="play-file" data="vm-youhave.wav"/> <action function="execute" data="sleep(1000)"/>
<action function="say" data="$1" method="pronounced" type="items"/> <action function="play-file" data="vm-youhave.wav"/>
<action function="play-file" data="vm-messages.wav"/> <action function="say" data="$1" method="pronounced" type="items"/>
<!-- or --> <action function="play-file" data="vm-messages.wav"/>
<!--<action function="speak-text" data="you have $1 messages"/>--> <!-- or -->
<!--<action function="speak-text" data="you have $1 messages"/>-->
</match>
</input> </input>
</macro> </macro>
<macro name="saydate"> <macro name="saydate">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="say" data="$1" method="pronounced" type="current_date_time"/> <match>
<action function="say" data="$1" method="pronounced" type="current_date_time"/>
</match>
</input> </input>
</macro> </macro>
<macro name="timespec"> <macro name="timespec">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="say" data="$1" method="pronounced" type="time_measurement"/> <match>
<action function="say" data="$1" method="pronounced" type="time_measurement"/>
</match>
</input> </input>
</macro> </macro>
<macro name="ip-addr"> <macro name="ip-addr">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="say" data="$1" method="iterated" type="ip_address"/> <match>
<action function="say" data="$1" method="pronounced" type="ip_address"/> <action function="say" data="$1" method="iterated" type="ip_address"/>
<action function="say" data="$1" method="pronounced" type="ip_address"/>
</match>
</input> </input>
</macro> </macro>
<macro name="spell"> <macro name="spell">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="say" data="$1" method="pronounced" type="name_spelled"/> <match>
<action function="say" data="$1" method="pronounced" type="name_spelled"/>
</match>
</input> </input>
</macro> </macro>
<macro name="spell-phonetic"> <macro name="spell-phonetic">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="say" data="$1" method="pronounced" type="name_phonetic"/> <match>
<action function="say" data="$1" method="pronounced" type="name_phonetic"/>
</match>
</input> </input>
</macro> </macro>
<macro name="tts-timeleft"> <macro name="tts-timeleft">
<!-- The parser will visit each <input> tag and execute the actions in <match> or <nomatch> depending on the pattern param -->
<!-- If the function "break" is encountered all parsing will cease -->
<input pattern="(\d+):(\d+)"> <input pattern="(\d+):(\d+)">
<action function="speak-text" data="You have $1 minutes, $2 seconds remaining $strftime(%Y-%m-%d)"/> <match>
<action function="speak-text" data="You have $1 minutes, $2 seconds remaining $strftime(%Y-%m-%d)"/>
<action function="break"/>
</match>
<nomatch>
<action function="speak-text" data="That input was invalid."/>
</nomatch>
</input>
<input pattern="(\d+) min (\d+) sec">
<match>
<action function="speak-text" data="You have $1 minutes, $2 seconds remaining $strftime(%Y-%m-%d)"/>
</match>
<nomatch>
<action function="speak-text" data="That input was invalid."/>
</nomatch>
</input> </input>
</macro> </macro>
</language> </language>
<language name="fr" sound_path="/var/sounds/lang/fr/jean" tts_engine="cepstral" tts_voice="jean-pierre"> <language name="fr" sound_path="/var/sounds/lang/fr/jean" tts_engine="cepstral" tts_voice="jean-pierre">
<macro name="msgcount"> <macro name="msgcount">
<input pattern="(.*)"> <input pattern="(.*)">
<action function="play-file" data="tuas.wav"/> <match>
<action function="say" data="$1" method="pronounced" type="items"/> <action function="play-file" data="tuas.wav"/>
<action function="play-file" data="messages.wav"/> <action function="say" data="$1" method="pronounced" type="items"/>
<action function="play-file" data="messages.wav"/>
</match>
</input> </input>
</macro> </macro>
<macro name="timeleft"> <macro name="timeleft">
<input pattern="(\d+):(\d+)"> <input pattern="(\d+):(\d+)">
<action function="speak-text" data="il y a $1 minutes et de $2 secondes de restant"/> <match>
<action function="speak-text" data="il y a $1 minutes et de $2 secondes de restant"/>
</match>
</input> </input>
</macro> </macro>
</language> </language>

View File

@ -4414,6 +4414,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
switch_status_t status = SWITCH_STATUS_GENERR; switch_status_t status = SWITCH_STATUS_GENERR;
char *old_sound_prefix, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL; char *old_sound_prefix, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL;
switch_channel_t *channel; switch_channel_t *channel;
uint8_t done = 0;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
@ -4479,7 +4480,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
switch_channel_pre_answer(channel); switch_channel_pre_answer(channel);
while(input) { while(input && !done) {
char *pattern = (char *) switch_xml_attr(input, "pattern"); char *pattern = (char *) switch_xml_attr(input, "pattern");
if (pattern) { if (pattern) {
@ -4489,9 +4490,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
uint32_t len = 0; uint32_t len = 0;
char *odata = NULL; char *odata = NULL;
char *expanded = NULL; char *expanded = NULL;
switch_xml_t match = NULL;
if ((proceed = switch_perform_regex(data, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { if ((proceed = switch_perform_regex(data, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
for (action = switch_xml_child(input, "action"); action; action = action->next) { match = switch_xml_child(input, "match");
} else {
match = switch_xml_child(input, "nomatch");
}
if (match) {
for (action = switch_xml_child(match, "action"); action; action = action->next) {
char *adata = (char *) switch_xml_attr_soft(action, "data"); char *adata = (char *) switch_xml_attr_soft(action, "data");
char *func = (char *) switch_xml_attr_soft(action, "function"); char *func = (char *) switch_xml_attr_soft(action, "function");
@ -4522,6 +4530,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
if (!strcasecmp(func, "play-file")) { if (!strcasecmp(func, "play-file")) {
switch_ivr_play_file(session, NULL, odata, args); switch_ivr_play_file(session, NULL, odata, args);
} else if (!strcasecmp(func, "break")) {
done = 1;
break;
} else if (!strcasecmp(func, "execute")) { } else if (!strcasecmp(func, "execute")) {
const switch_application_interface_t *application_interface; const switch_application_interface_t *application_interface;
char *app_name = NULL; char *app_name = NULL;
@ -4568,7 +4579,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
} }
} }
} }
switch_clean_re(re); switch_clean_re(re);
switch_safe_free(expanded); switch_safe_free(expanded);
switch_safe_free(substituted); switch_safe_free(substituted);