| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<grammar src="MyGrammarFile.gsl#MYRULENAME" type="text/gsl"/>
MYRULE [
[ cheddar ] { <F_1 "Cheese"> }
]
| Markup | Explanation |
MYRULE |
(Top Level Rulename) This is the sub-file that the grammar src references |
[cheddar] |
(User Utterance) The expected phrase from the caller that a grammar will get a valid match upon |
F_1 |
(Slot Name) The field or slot in the application that the return result will be sent to upon a match |
"cheese" |
(Returned Result) A user-defined value to be returned upon a successful recognition |
<dtmf> element and define your DTMF grammars within the <grammar> element in order to be more cross-platform portable.<grammar src="MyGrammarFile.gsl#MYRULENAME" type="text/gsl"/>
MYRULE
[
( doctor strangelove ) ] { <F_1 "Kubrick"> }
]
[ hunka burnin love ]( hunka burnin love ) ( ?hunka burnin love )( +hunka burnin love ) ( *hunka burnin love )
MYRULE [
[ ?new car ] { <CarShopping "NewCar"> }
]
;GSL2.0
SENT
[
( see spot run )
( SENT and SENT )
]
<link> tag in the application root document. Links, unlike grammars, cannot declare a scope, and are always considered to be document/application scoped.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE vxml PUBLIC "-//W3C//DTD VOICEXML 2.1//EN" "http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.dtd">
<vxml version="2.1">
<!-- Document level grammar result for the result form -->
<var name="doc_result" />
<form id="frm_main">
<!-- this is a document level grammar -->
<grammar type="text/gsl" scope="document">
<![CDATA[
[
( [one dtmf-1] ) { <doc "one"> }
( [two dtmf-2] ) { <doc "two"> }
( [exit dtmf-0] ) { <doc "term"> }
]
]]>
</grammar>
<!-- Our document level grammar has been filled
send the user to the next form -->
<filled namelist="doc">
<assign name="doc_result" expr="doc" />
<goto next="#frm_doc_filled" />
</filled>
<!-- Get some input for the local grammar field -->
<field name="field1" >
<!-- This is a local grammar -->
<grammar type="text/gsl">
<![CDATA[
[
( [three dtmf-3] ) { <field1 "three"> }
( [four dtmf-4] ) { <field1 "four"> }
]
]]>
</grammar>
<!-- This is the main menu prompt -->
<prompt>
This is field 1
Press one or two for the document level grammar to answer
Enter three or four for the dialog or local level grammar to answer
If you press zero the document level grammar will say goodbye and hangup
</prompt>
</field>
<!-- our local grammar has been filled -->
<filled namelist="field1">
<prompt>
You said <value expr="field1" />
<break time="1000ms" />
</prompt>
<!-- Loop Back to main -->
<goto next="#frm_main" />
</filled>
<!-- Set up an empty field to grab the document level grammar data -->
<field name="doc" />
</form>
<!-- Create a new form for the filled document scope grammar -->
<form id="frm_doc_filled">
<block>
<prompt>
This is the document level grammar answering
You said <value expr="doc_result" />
</prompt>
<!-- Check to see if we got a 0 for hangup -->
<if cond="doc_result == 'term'">
<prompt>
Goodbye
</prompt>
<!-- Exit the application -->
<exit />
<else />
<prompt>
Going back to the main form
</prompt>
<goto next="#frm_main" />
</if>
</block>
</form>
</vxml>
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<field name="F_1">
[(cheddar) (?monteray jack) (+stinky french cheese) ]
<prompt>
what is your favorite cheese?
</prompt>
<filled>
<prompt>
You said <value expr="F_1"/>
</prompt>
</filled>
</field>
</form>
</vxml>
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<field name="F_1">
<grammar type="text/gsl">
<![CDATA[
MYRULE
[
( cheddar ) { <F_1 "cheddar cheese"> }
( ?monteray jack ) { <F_1 "jack cheese"> }
( +stinky french cheese ) { <F_1 "stinky cheese"> }
]
]]>
</grammar>
<prompt>
what is your favorite cheese?
</prompt>
<filled>
<prompt>
You said <value expr="F_1$.interpretation.F_1"/>
</prompt>
</filled>
</field>
</form>
</vxml>
; External GSL Grammar
; External GSL grammars are almost exactly the same as an inline grammar,
; just in a different file and no "CDATA" tag! :-P
;Define our rule
MYRULE
[
; user says at least: "cheddar"
( cheddar ?cheese ) { <type_cheese "cheddar cheese"> }
; user says at least: "jack"
( ?monteray jack ?cheese ) { <type_cheese "jack cheese"> }
; user says at least: "stinky french"
; and/or cheese
( +stinky french ?cheese ) { <type_cheese "stinky cheese"> }
]
<grammar> tag. The main difference between an inline <grammar> and an external <grammar> tag is that you must declare your top level rule name. For example:<grammar src="external_grammar.gsl#MYRULE" type="text/gsl" />
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//W3C//DTD VOICEXML 2.1//EN" "http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.dtd">
<vxml version="2.1"
xmlns="http://www.w3.org/2001/vxml"
xmlns:voxeo="http://community.voxeo.com/xmlns/vxml">
<form id="frm_main">
<field name="f_cheese" slot="type_cheese">
<!-- Define our external grammar -->
<grammar src="external_grammar.gsl" type="text/gsl" />
<!-- prompt the user to say their favorite type of cheese -->
<prompt>
Hi there!
i am curious
What is your favorite type of cheese?
</prompt>
<!-- the user did not match one of the cheeses in the grammar -->
<catch event="nomatch noinput">
<prompt>
i'm sorry, i don't know what kind of cheese that is
<reprompt />
</prompt>
</catch>
<!-- a cheese was recognized! -->
<filled>
<prompt>
That's amazing!
<value expr="lastresult$.interpretation.type_cheese" /> is my favorite type of cheese too!
<break time="300ms" />
i'll talk to you soon
bye!
</prompt>
<exit />
</filled>
</field>
</form>
</vxml>
| ACCOUNT LOGIN |
| ANNOTATIONS: EXISTING POSTS |
eosmann
|
|
| The link at the top of this page that says "Nuance Grammar Guide" and opens the page http://community.voxeo.com/docs/grammar/grammar-gsl.pdf doesn't work! Did it move? | |
steve.sax
|
|
| Hi Eric,
The GSL grammar guide didn't move, but it did take a short vacation. However, I have called it, and asked it to get back on the job. Wisecracks aside, if you try the link again, it should come up for you, assuming you have a PDF reader. Steve Sax |
|
dodgly
|
|
| It seems the PDF link on the page that was fixed back in November is once again dead.
http://community.voxeo.com/vxml/docs/nuance20/grammar.pdf |
|
steve.sax
|
|
| Sorry about that folks. The Nuance grammar guide link has been fixed, for your viewing enjoyment..
Steve Sax |
|
jeckhouse
|
|
| Looks to be broken again. | |
MattHenry
|
|
|
Hello Justin, If you are referring to the link above at: http://community.voxeo.com/vxml/docs/nuance20/grammar.pdf I am not having any problems reaching this PDF guide....please advise. ~Matt |
|
gregzh
|
|
| Hi,
I am little lost here about planing grammar, so post this basic question. There is a target sentence, something like "Your room number is 5503", my program need to fetch two kind of things here, One is "room number", the other is "5503". HOw to prepare the grammar. Thanks. greg |
|
MattHenry
|
|
|
Hello Greg, This is a pretty broad question for me to address within the confines of a doc annotation, but I'll do my best. For any complex utterance values you wish to accept in your application, you will likely want to design a multi-rule subgrammar using either GSL or SRGS grammar formats. As this is a complex task, I very strongly advise that you start off with the following: - review our GSL subgrammar tutorial - review all documentation in this section dealing with GSL subgrammars - review all grXML/SRGS subgrammar documentation - download and review the 'grammar.zip' file from the below URL, and use if for reference: http://community.voxeo.com/library/grammar/library.jsp Best of luck! ~Matthew Henry |
|
hemanthvasa
|
|
| Hi
I am new to this grammars i don't have much experience on this can u please tell me how to build grammar for the following sentence "Always ask my Pin" Thanks HemanthVasa |
|
sidvoxeo
|
|
| Hi Hemanth,
There are a lot of ways to write grammars,both GSL and GRXML grammars. If you are using inline GSL grammar it would be some thing like <grammar type="text/gsl">[WHAT EVER GRAMMAR YOU WANT TO BUILT]</grammar> If you are using external grammar it could be some thing like this <grammar src="digits.gsl#MAIN"/> where digit.gsl is an external gsl grammar and MAIN is the toplevel of the grammar. If you look through the documentation , there are lot of examples to help you with this. Thanks Sid |
|
Marquet
|
|
| Hi,
I'm a beginner in voicexml and one of the questions i have is: I suppose that when using your browser, the speaker will speak the words in english. What do i have to do if I want the speaker to understand that he has to speak spanish? Or even more, what do i have to do if I want to talk in spanish and be understood by the application? I mean, is there any option in the Motorola browser that allows me to work using other languages? Maybe it's impossible and I must use another one, do you know any of them? Thanks and excuse my english, si'l vous plait. Marc |
|
MattHenry
|
|
|
Hi there, If you want to recognize a foreign language utterance, then you will have to set the ASR to use a recognition engine to the appropriate locale. At present, our US customers only have the option for English, and Spanish, (so you are in luck!). You can use the following code sample below, which is annotated for your convenience to start developing a Spanish application. Note that this is available only for the Voicecenter 5.5 release, and is *not* supported in the Prophecy/Voicecenter 7.0 platform: <?xml version="1.0" encoding="UTF-8"?> <!-- ****************************************** --> <!-- xml:lang attribute invokes the Spanish ASR --> <!-- ****************************************** --> <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml" xmlns:voxeo="http://community.voxeo.com/xmlns/vxml" xml:lang="es-MX"> <!-- ******************************* --> <!-- sets the rhetorical spanish TTS --> <!-- ******************************* --> <property name="nuance.core.tts.ResourceName" value="es-MX.F023" /> <form id="F1"> <field name="F_1" type="digits?length=3"> <prompt bargein="true"> hola senor. </prompt> <filled> <value expr="F_1"/> <log expr="'**********INTERP*************' + F_1$.interpretation.F_1" /> <log expr="'**********UTTERANCE*************' + F_1$.utterance" /> <log expr="'**********CONFIDENCE*************' + F_1$.confidence" /> <log expr="'**********INPUTMODE*************' + F_1$.inputmode" /> </filled> </field> </form> </vxml> Regards, ~Matthew henry |
|
SSA_42Entertainment
|
|
| Hi, I have a very simple inline grammar:
<grammar type="text/gsl"> [ (one) (two) (three) (four) (five) (six) (seven) (eight) (nine) (ten) ] </grammar> The goal is to have the user say a number between one and ten. However numbers like eleven, fourteen, etc. are matched as well. How come? |
|
VoxeoDante
|
|
| Hello 42Entertainment,
Do you have a field with a type="digits" in your application? A field type="digits" will invoke the builtin digits grammar. This builtin grammar will allow for a wide range of numbers, including anything up to 16 digits long. If this is not the case, I would like to see the xml for the document exhibiting this behavior. If you do not want to post the code here in a public forum, please feel free to open a private account ticket, and reference this thread in that ticket. If there is something I am missing here, or if there is anything else I can do, please let me know. All the best, Dante Vitulano Voxeo Corporation |
|