[asterisk-speech-rec] Grammar Question

Kevin Bednar kevin at k2kmb.org
Thu Apr 22 08:02:00 CDT 2010


Thanks Adam, I saw that, but I was actually asking Stephen how that 
could be done in the grammar itself. :)

Kevin

Adam Robins wrote:
> That is what the
>
> exten => s,1,Set(SPEECH_DTMF_MAXLEN=1)
>
> is for.  It will proceed after the specified maximum input length.
>
> -----Original Message-----
> From: asterisk-speech-rec-bounces at lists.digium.com [mailto:asterisk-speech-rec-bounces at lists.digium.com] On Behalf Of Kevin Bednar
> Sent: Wednesday, April 21, 2010 7:37 PM
> To: Use of speech recognition in Asterisk
> Subject: Re: [asterisk-speech-rec] Grammar Question
>
> Stephen,
>  Is there a way to have a grammar stop accepting further input and
> return immediately after X number of characters? Like using the digits
> grammar and making it return right away after 4 digits instead of
> waiting for the timeout value? Thanks.
>
> Kevin
>
> Stephen Keller wrote:
>   
>>> The speech engine does not handle DTMF, Asterisk does that.  The following code handles yes/no both verbally and DTMF:
>>>
>>>       
>> Actually, a better way to do this is to just build your grammar such that it returns a number, that way you can handle both cases with the same logic in the dialplan.
>>
>> So let's say you used the following yes/no grammar:
>>
>> root $yesno;
>> $yesno = ($yes | $no) {out=rules.latest()};
>> $yes = (yes [please] | yeah | yup) {out="1"};
>> $no = (no [thanks] | nope) {out="2"};
>>
>> Assuming your prompt says "Say 'yes' or press 1, or say 'no' and press 2" then the dialplan can be:
>>
>> exten => s,1,Set(SPEECH_DTMF_MAXLEN=1)                              ; Set max # DTMF digits to accept per transaction
>> exten => s,n,SpeechCreate
>> exten => s,n,SpeechLoadGrammar(yesno,pathtoyesnogrammar)
>> exten => s,n,SpeechActivateGrammar(yesno)
>> exten => s,n,SpeechBackground(is-this-john-smith|5)                 ; Ask your question and wait 5 sec for reply
>> exten => s,n,SpeechDeactivateGrammar(yesno)
>> exten => s,n,GotoIf($["${SPEECH_TEXT(0)}" = "0"]?oper)              ; caller pressed "0" - go to Operator handler (not shown)
>> exten => s,n,GotoIf($["${SPEECH_TEXT(0)}" = "1"]?score)             ; caller pressed "1" or said "yes"
>> exten => s,n,GotoIf($["${SPEECH_TEXT(0)}" = "2"]?score)             ; caller pressed "2" or said "no"
>> exten => s,n,Goto(invalid)                                          ; unexpected response - go to retry logic (not shown)
>> exten => s,n(score),GotoIf($[${SPEECH_SCORE(0)} > 650]?proceed)     ; if speech engine was 65+% confident then accept response (not shown)
>> exten => s,n,Goto(nocomp)                                           ; confidence too low - go to "didn't understand" logic (not shown)
>>
>> Obviously both cases will work, but it can be a good idea to always get in the habit of normalizing your speech and DTMF outputs, such that you don't need to know which was used.
>>
>> Thanks,
>>
>> Stephen Keller
>> Project Manager
>> LumenVox
>> P: 1-877-977-0707 - just say, "Support"
>> P: +1-858-707-7700
>> F: +1-858-707-7072
>> support at LumenVox.com
>> www.LumenVox.com
>>
>>
>>
>>
>>     
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-speech-rec mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-speech-rec
>
> The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
>
>   




More information about the asterisk-speech-rec mailing list