| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<rule>, <one-of>, <item>, and <tag> elements <grammar type="text/gsl">
[ gimli aragorn legolas (frodo ?baggins) ]
</grammar> <grammar type="text/gsl">
<![CDATA[
[gimli] {<MySlot "dwarves">}
[aragorn] {<MySlot "men">}
[legolas] {<MySlot "elves">}
(frodo ?baggins) {<MySlot "hobbits">}
]]>
</grammar>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="author" content="J. R. R. Tolkein"/>
<meta name="copyright" content="2004 voxeo corporation"/>
<meta name="maintainer" content="YourEmailAddress@here.com"/>
<form id="F1">
<field name="F_1">
<prompt> who is the coolest character in the Lord Of The Rings saga? </prompt>
<grammar src="XMLGrammar.xml" type="application/grammar-xml"/>
<filled>
<prompt>
you said
<value expr="lastresult$.utterance"/>
from the race of
<value expr="F_1$.interpretation.F_1"/>
is the coolest character. I would have to agree.
</prompt>
</filled>
</field>
</form>
</vxml>
<meta> tag (not the author's self aggrandizing namestamp, but the 'maintainer'). If you have done your homework, you will remember that adding this tag will enable debugging via email, which is a super-handy thing to have in the event your application decides to detonate due to a coding error. Get in the habit of doing this in all of your VXML documents, and you will be very glad that you did. Trust us on this one.
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US" root = "MYRULE">
<rule id="MYRULE" scope="public">
<one-of>
<item> gimli </item>
<item> aragorn </item>
<item> legolas </item>
<item> frodo baggins </item>
<item> rosie o donnell </item>
</one-of>
</rule>
</grammar>
<grammar> element and define the xml namespace with the 'xmlns' attribute. For this, we will always want to point to the w3c sanctioned namespace for XML grammars. The definition for 'xml:lang' is entirely optional, but we include it here for the sake of completeness. If you make a habit of defining this attribute, always make sure the value is set to 'en-US'.<grammar> element is an absolute requirement -- the definition of our Root Rule. GSL grammars also require a top-level (or root) rule as well, but the syntax is slightly different when using grXML grammars. Immediately beneath this final declaration, we define our rule within, (surprise!), the <rule> element. It is also a good idea to declare the 'scope' of the rule as well, so you have a finer granularity of control regarding whether or not our grammar can be referenced from any other existing XML grammars. When set to 'public,' any other grammar can reference the rule(s) contained therein via the <ruleref> element. However, when set to 'private,' the rule in question is only available from the grammar file in which it is located.item tags. Nothing at all to fancy about that.
<grammar type="text/gsl"> [ gimli aragorn legolas (frodo ?baggins) ] </grammar>
<item> element, and do some creative nesting of our tags:
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US" root = "MYRULE">
<rule id="MYRULE" scope="public">
<one-of>
<item>
<!-- optional utterance prefixes go here -->
<!-- <item repeat="0-1">(some utterance)</item> -->
<one-of>
<item> gimli </item>
<item> aragorn </item>
<item> legolas </item>
<item> frodo </item>
<item> rosie </item>
</one-of>
<!-- optional utterance suffixes go here -->
<item repeat="0-1"> baggins </item>
<item repeat="0-1"> o donnell </item>
</item>
</one-of>
</rule>
</grammar>
<one-of/item> tags. As we are accounting for an utterance suffix in this case (for last names), we have placed these optional utterances so they are below the required utterances (first names). If we wanted to add an utterance prefix, we would want to add them so they are just above the required utterances. Even an Uru'kai could figure that one out! Also, make note of the fact that we have added the aforementioned 'repeat' attribute to these utterances, and specified they can be said either once, or not at all.
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US" root = "MYRULE">
<rule id="MYRULE" scope="public">
<one-of>
<item>
<!-- optional utterance prefixes go here -->
<!-- <item repeat="0-1">(some utterance)</item> -->
<one-of>
<item> gimli <tag> <![CDATA[ <F_1 "dwarves"> ]]> </tag> </item>
<item> aragorn <tag> <![CDATA[ <F_1 "men"> ]]> </tag> </item>
<item> legolas <tag> <![CDATA[ <F_1 "elves"> ]]> </tag> </item>
<item> frodo <tag> <![CDATA[ <F_1 "hobbits"> ]]> </tag> </item>
<item> rosie <tag> <![CDATA[ <F_1 "cave trolls"> ]]> </tag> </item>
</one-of>
<!-- optional utterance suffixes go here -->
<item repeat="0-1"> baggins </item>
<item repeat="0-1"> o donnell </item>
</item>
</one-of>
</rule>
</grammar>
<tag> element within the <item> element holding the utterance. Within this <tag>, we will need to make sure the return value and the slot definition is enclosed in CDATA tags, ensuring non-parseable characters (such as Shelob), will not bring our journey to a screeching halt. Nested within the CDATA element, we define our slot (which, you will note, matches up with the fieldname we defined in the VXML document) within angle brackets:<F_1><F_1 "frodo">| ANNOTATIONS: EXISTING POSTS |
darrenj
|
|
| Riddle me this Batman. Int this tutorial:
1. The document references the grammar as XMLGrammar.cfm instead of XMLGrammar.xml. 2. It seems from looking at it that the optional utterances will be accepted for each declared utterance. This is in fact the case when tested. This begs the question. Would I associate the optional utterance of baggins with just the utterance of frodo like: <item> frodo <tag> <![CDATA[ <F_1 "hobbits"> ]]> </tag> <one-of> <item repeat="0-1"> baggins </item> </one-of> </item> AND Why doesn't this work with o donnel like this? <item> rosie <tag> <![CDATA[ <F_1 "cave trolls"> ]]> </tag> <one-of> <item repeat="0-1"> o donnel </item> </one-of> </item> |
|
MattHenry
|
|
|
Hiya Darren, I'd be happy to help clarify for you. Regarding the .cfm grammar reference, this is an artifact from my original test code, (I use .cfm cache headers when working on code to make sure I'm not getting a stale copy of my code when testing). In any case, I got this fixed in our internal Build of the dcos, which is set to be updated sometime in the next week or two. On to your second question: A) The optioanl utterances wqould indeed work for all grammar values; I didnt recall Rosie Baggins, or Frodo O Donnel having any speaking roles in the trilogy, so I thought it was a fairly safe bet that these wouldn't be encountered by anyone. I think you are close on your syntax; hard to tell exactly how you have your stuff nested from the code fragments, but for the edification of our developers, I'll post a full-blown sample that further subdivides the 'optionals' on a per-entry basis: --------------------------------------- <?xml version= "1.0"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="INTRO"> <rule id="INTRO"> <one-of> <!-- ************* --> <item> <one-of> <item> erik </item> </one-of> <tag> <![CDATA[ <MySlot "Ponch"> ]]> </tag> <item repeat="0-1"> estrada </item> </item> <!-- ************* --> <item> <one-of> <item> jon </item> </one-of> <tag> <![CDATA[ <MySlot "bon jovi"> ]]> </tag> <item repeat="0-1"> bon jovi </item> </item> </one-of> </rule> </grammar> --------------------------------------- B) This is kind of difficult to diagnose why this snippet isn't working, but I suspect that we aren't nesting our values properly in one-of/item tags one more level up. Hope this helps clear things up! ~Matthew Henry |
|
draftbeer80
|
|
| Hi everbody!
I'm starting to play with external xml grammar. And I need a little assistance. First I'm gonna post the code of my test app (XMLGramTest.xml): <?xml version="1.0" encoding="UTF-8"?> <vxml version = "2.1" > <form id="main"> <field name="F_1"> <prompt>Speak.</prompt> <grammar src="testGram.xml" type="application/grammar-xml"/> <noinput>Nothing heard.<reprompt/></noinput> <nomatch>No match found.<reprompt/></nomatch> </field> <filled> <prompt> You said. <value expr="F_1$.interpretation.MySlot"/><break time="2000"/> </prompt> </filled> </form> </vxml> And here's the code for the external grammar (testGram.xml): <?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="TOPLEVEL"> <rule id="TOPLEVEL" scope="public"> <one-of> <item><ruleref uri="#LOWLEVEL"/><tag><![CDATA[<MySlot $return>]]></tag></item> </one-of> </rule> <rule id="LOWLEVEL"> <one-of> <item>hello<tag>return ("hi!")</tag></item> </one-of> </rule> </grammar> As you can see in the grammar code we have two rules. The toplevel rule references the lowlevel rule. Now, what I really want to happen is simple. I want the string "hi" which was returned after a match is found will be returned to the main rule and put into the MySlot slot. That way, it will be passed to the application using the grammar. I know there's something wrong with it. And i've been trying to figure it out for hours. I think it's time for me to ask for help from the geniuses. Hahah. Thanks Chris ;-D |
|
MattHenry
|
|
|
Cris, Can you please let me know which VXML platform that you are using to test this grammar? I don't want to spend time working on a solution that may not apply to the VXML version that you are using, (Voxeo-Motorola VXML vs. Prophecy-Voicecenter 7.0 VXML). ~Matt |
|
draftbeer80
|
|
| Hi Mat!
I am testing that application with Prophecy Voice Platform 7.0. I installed it in my computer and I pointed it to a local webserver. I hope that helped. ;-D |
|
VoxeoTony
|
|
| Hello Chris,
With what you sent in for platform we were able to test run some code with modifications for you. In the grammar section we updated the code to better define a slot than the method you were using. Matt wanted me to get this new snipped to you. <item>hello<tag><![CDATA[ <mySlot "hi"> ]]></tag></item> In addition, with your main page you listed the line $.interpretation.MySlot But it is not needed for your code. Without it the code worked fine. Please give it a try and let us know your thoughts. Regards, Tony |
|
draftbeer80
|
|
| Hi!
I've tried the above suggestion. I'm sorry, But it doesn't work. At least, not the way I wanted it to. If you re-examine the code above that I have posted, what I really wanted to happen is that, if the user says "hello" then the main program should say "You said HI". Instead of saying "You said HELLO". Because in my repeated trial-and-error, I always come up with that result. By the way, in the above grammar I posted, what does $return put into the MySlot slot? Because I get the result "You said UNDEFINED". Isn't $result supposed to have the value "hi"? I appreciate so much your patience. Thanks. ;-D Chris |
|
prasanthmadala
|
|
| Hi Support,
I have a critical requirement where i want to take continuous alphabets as input. This for accepting the names and asking user to spell his name. I choose this way bcoz, it is very difficult to put all the U.S people name in a single grammar file. Example: computer: Please spell your first name? user: J H O N Can any one guide me to write grammar for this? |
|
voxeoJeffK
|
|
| Hello,
Attached is an alphabetic grammar to get you started. Note that spelling grammars can be difficult to implement while providing a positive user experience. We do offer Targus name and address grammars. There is a fee associated with lookups using this solution, but it is most certainly worth it for the accuracy and ease of use. If you would like more information on using the Targus solution our sales team at sales@voxeo.com can provide more information. regards, Jeff Kustermann Voxeo Support |
|
prasanthmadala
|
|
| Hi,
Iam sorry, i was not able to find the attachment to start. Can you paste me the link/path here? Thanks, -Madala |
|
voxeoblehn
|
|
| Hello Madala,
I have gone ahead and attached the alpha numberic grammar example again for you, please let us know if it does not come through. Best Regards, Brian Lehnen Voxeo Support |
|
eddyteddypp
|
|
| Hello everybody
Well first of all congrats to people who are active to amke this place a heaven to learn the vxml. Now coming up to my doubt. Well I am making a program that requires the user to spell his name that will be stored in the database. My program the spells the spelling spoken by user is as follow <?xml version = "1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id = "namerec"> <field name ="alpha" slot = "alpha"> <grammar xml:lang="en-US" version="1.0" root="root"> <rule id="root" scope="public"> <one-of> <item repeat="0-30"> <ruleref uri="#nameis"/> </item> </one-of> </rule> <rule id = "nameis" scope="public"> <one-of> <item>a</item> <item>b</item> <item>c</item> <item>d</item> <item>e</item> <item>f</item> <item>g</item> <item>h</item> <item>i</item> <item>j</item> <item>k</item> <item>l</item> <item>m</item> <item>n</item> <item>o</item> <item>p</item> <item>q</item> <item>r</item> <item>s</item> <item>t</item> <item>u</item> <item>v</item> <item>w</item> <item>x</item> <item>y</item> <item>z</item> </one-of> </rule> </grammar> <prompt> Spell your name. </prompt> </field> <filled namelist = "alpha"> <prompt> Spelling of your name is <value expr="alpha"/> </prompt> </filled> </form> </vxml> In this program i am asking the the user to spell his name that will be respelled by the program. The problem is that when user say "b" the program interprets it as "e" or "d". In some cases like "w" or "o" program interprets is correctly. Is there any flaw in my program.. Or, is there any better way to accomplish the task ??? Thankx and Regards :) |
|
eddyteddypp
|
|
| Hello everybody
Well first of all congrats to people who are active to amke this place a heaven to learn the vxml. Now coming up to my doubt. Well I am making a program that requires the user to spell his name that will be stored in the database. My program the spells the spelling spoken by user is as follow <?xml version = "1.0" encoding="UTF-8"?> <vxml version="2.1"> <form id = "namerec"> <field name ="alpha" slot = "alpha"> <grammar xml:lang="en-US" version="1.0" root="root"> <rule id="root" scope="public"> <one-of> <item repeat="0-30"> <ruleref uri="#nameis"/> </item> </one-of> </rule> <rule id = "nameis" scope="public"> <one-of> <item>a</item> <item>b</item> <item>c</item> <item>d</item> <item>e</item> <item>f</item> <item>g</item> <item>h</item> <item>i</item> <item>j</item> <item>k</item> <item>l</item> <item>m</item> <item>n</item> <item>o</item> <item>p</item> <item>q</item> <item>r</item> <item>s</item> <item>t</item> <item>u</item> <item>v</item> <item>w</item> <item>x</item> <item>y</item> <item>z</item> </one-of> </rule> </grammar> <prompt> Spell your name. </prompt> </field> <filled namelist = "alpha"> <prompt> Spelling of your name is <value expr="alpha"/> </prompt> </filled> </form> </vxml> In this program i am asking the the user to spell his name that will be respelled by the program. The problem is that when user say "b" the program interprets it as "e" or "d". In some cases like "w" or "o" program interprets is correctly. Is there any flaw in my program.. Or, is there any better way to accomplish the task ??? Thankx and Regards :) |
|
VoxeoDustin
|
|
| Hello Eddy,
Thanks for the kind words. We're always glad to be of service. Regarding your questions about alphanumeric input, this will always be somewhat difficult to achieve via telephone, because many letters sound quite similar (examples: 3, B, C, D, E, G, P, T, V, & Z, and A, H, J, K, & 8). Even with human listeners this proves difficult, which is why you see military and law enforcement agencies using call signs for alphanumeric readback over the radio and phone - e.g. whiskey tango foxtrot, etc. However, we do have some in-depth documentation that details the pros and cons of alphanumeric voice recognition, along with tested sample code that you can download and implement. I would think that you should be able to plug in the sample code in the links below without too much effort, but in the event that the samples are not suitable to your dialog design and need any retro-fitting, please let me know, and we would be happy to help. http://blogs.voxeo.com/voxeodeveloperscorner/2008/05/05/certified-tech-tip-alpha-numeric-voice-recognition-grammars-part-one/ http://blogs.voxeo.com/voxeodeveloperscorner/2008/05/20/certified-tech-tip-alpha-numeric-voice-recognition-grammars-part-two/ Regards, Dustin Hayre Solutions Engineer Voxeo Corporation |
|
korte
|
|
| HelloĦĦ
I want to make you one question. I´m working with Nuance 8.5 ASR and I have to use tag-format="nuance". I´m writting a grammar that recognize numbers by voice. One of my rules is: <rule id="from_100_to_999" scope="public"> <item> <item> <ruleref uri="#100_s"/> <tag>assign(m $return)</tag> </item> <item repeat="0-1"> <ruleref uri="#from_1_to_99"/> <tag>assign(n $return)</tag> </item> </item> <tag><![CDATA[<mislot $n?? +?? $m??>]]></tag> </rule> How I add $m and $n in last tag (<tag><![CDATA[<mislot $n?? +?? $m??>]]></tag>)? Thanks. |
|
VoxeoDustin
|
|
| Hello,
Are you using Nuance 8.5 with the Prophecy platform? If so, the Nuance tag format is not necessary. Prophecy implements a grammar translator that automatically converts your grammars to the format the recognizer expects. As such, you can use the W3C spec SISR tag format with grammars even when using Nuance 8.5: <item> <ruleref uri="#100_s"/> <tag>out.m = rules.RULENAME.slot </tag> </item> Regards, Dustin Hayre Solutions Engineer Voxeo Corporation |
| login |
|