[asterisk-users] How to make SpeechBackgroundkeepplayingifutterance doesn't match our grammar
Danny Nicholas
danny at debsinc.com
Tue Jan 26 08:14:15 CST 2010
AIR, the $GARBAGE sort of "forces" a match. The way I test a
grammar/background is something like this:
(this is longer because it uses Waitexten when no lumenvox license is
available)
[main-menu-select]
exten => s,1(start_menu),noop(select 0-9 except 8)
exten => s,n,Gotoif($["${usedtmf}" = "1"]?no-voice-menu)
exten => s,n,SpeechLoadGrammar(menu|/etc/asterisk/grammars/menu.gram)
exten => s,n,SpeechActivateGrammar(menu)
exten => s,n,Set(SPEECH_DTMF_MAXLEN=1)
exten =>
s,n(say_menu),SpeechBackground(${Playmenu}&${Playxfer}&${Pressxfer}&${Playns
f}&${Pressnsf}&${Playimg}&${Pressimg}&${Playpin}&${Presspin}&${Playmsg}&${Pr
essmsg}&${Opermsg}&${Selmsg}|10)
exten => s,n,noop(Verbose(speech results ${SPEECH(results)}))
exten => s,n,noop(Verbose(heard ${SPEECH_TEXT(0)} ))
exten => s,n,GotoIf($["${SPEECH(results)}" = "0"]?:repeat_menu)
exten => s,n,Playback(telbank/pleasesayagain)
exten => s,n,Goto(say_menu)
exten => s,n(repeat_menu),Set(TEXT=${SPEECH_TEXT(0)})
exten => s,n,noop(score is ${SPEECH_SCORE(0)})
exten => s,n,GotoIf($["${SPEECH_SCORE(0)}" <= "${THRESHOLD}"]?:spoke_menu)
exten => s,n,Gosub(bank-speech-confirm,s,1,(${SPEECH_TEXT(0)}))
exten => s,n,GotoIf($["${TEXT}" = "99"]?end-call|s|1)
exten => s,n,GotoIf($["${TEXT}" = "1"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "2"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "3"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "4"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "5"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "6"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "7"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "9"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "0"]?expect1)
exten => s,n,GotoIf($["${CONFIRM}" = "no"]?:spoke_menu)
exten => s,n,Goto(say_menu)
exten => s,n(spoke_menu),Set(SEL=${TEXT})
;test one
exten => s,n,GotoIf($["${TEXT}" = "99"]?end-call|s|1)
exten => s,n,GotoIf($["${TEXT}" = "1"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "2"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "3"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "4"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "5"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "4"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "5"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "6"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "7"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "9"]?expect1)
exten => s,n,GotoIf($["${TEXT}" = "0"]?expect1)
exten => s,n,Playback(pbx-invalid)
;exten => s,n,SayNumber(${TEXT})
exten => s,n,Goto(main-menu-select|s|1)
exten => s,n(expect1),noop(${TEXT})
exten => s,n,SpeechDeactivateGrammar(menu)
exten => s,n,SpeechUnloadGrammar(menu)
exten => s,n,Set(MENUPRESS=${TEXT})
exten => s,n,Goto(ffb|s|select-return)
exten =>
s,n(no-voice-menu),Background(${Playmenu}&${Playxfer}&${Pressxfer}&${Playnsf
}&${Pressnsf}&${Playimg}&${Pressimg}&${Playpin}&${Presspin}&${Playmsg}&${Pre
ssmsg}&${Opermsg}&${Selmsg}|3)
exten => s,n,WaitExten(3,m)
exten => s,n,Goto(main-menu-select|s|1)
exten => 0,1,Set(MENUPRESS=0)
exten => 0,n,Goto(ffb|s|select-return)
exten => 1,1,Set(MENUPRESS=1)
exten => 1,n,Goto(ffb|s|select-return)
exten => 2,1,Set(MENUPRESS=2)
exten => 2,n,Goto(ffb|s|select-return)
exten => 3,1,Set(MENUPRESS=3)
exten => 3,n,Goto(ffb|s|select-return)
exten => 4,1,Set(MENUPRESS=4)
exten => 4,n,Goto(ffb|s|select-return)
exten => 5,1,Set(MENUPRESS=5)
exten => 5,n,Goto(ffb|s|select-return)
exten => 6,1,Set(MENUPRESS=6)
exten => 6,n,Goto(ffb|s|select-return)
exten => 7,1,Set(MENUPRESS=7)
exten => 7,n,Goto(ffb|s|select-return)
exten => 9,1,Set(MENUPRESS=9)
exten => 9,n,Goto(ffb|s|select-return)
exten => i,1,Goto(main-menu-select|s|1)
exten => *,1,Goto(main-menu-select|s|1)
exten => t,1,Goto(main-menu-select|s|1)
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Quinn Weaver
Sent: Monday, January 25, 2010 5:33 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] How to make
SpeechBackgroundkeepplayingifutterance doesn't match our grammar
On Mon, Jan 25, 2010 at 2:56 PM, Danny Nicholas <danny at debsinc.com> wrote:
> Since you're "Perling" it, why not just put the $sb_retval in a while loop
> like this:
>
> - my $response_good=0;
> - my $sb_retval=undef;
> - while (! $response_good) {
> - my $tmp_retval = $c->agi->exec('SpeechBackground', $path);
> - if ($tmp_retval eq 'play_next') {
> $sb_retval=$tmp_retval;
> $response_good=1;
> }
> ...
> }
If we did that, we'd be replaying $path from the beginning every time
the user said something that didn't match the grammar. For a podcast
episode like a radio show, that's badyou don't want to be 30 seconds
or two minutes into the content and have to start over.
Also, as I said, it's always matching one of the rules in our
grammar--even if I literally say "goobledegook." So it's unclear how
we'd implement $response_good.
--
Quinn Weaver Consulting, LLC
Full-stack web design and development
http://quinnweaver.com/
510-520-5217
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list