VoiceXML 2.1 Development Guide Home  |  Frameset Home

  Inline grXML Subgrammars  |  TOC  |  K: Custom Features  

Nuance Extension Grammars

As detailed in the VoiceXML specification, there are many very common built in grammars that can be included by simply specifying the name in the 'field type' element/attribute:


<field name="F_1" type="digits?length=3">


The Nuance 8 ASR has taken this a step further, and added their own library of prebuilt field type grammars, which are available when using the Motorola browser. Note that these grammars are not to be considered a part of the w3c specification, and are proprietary to the Nuance platform, hence the prefix 'x-nuance'. Don't let this 'extension' status scare you however.........these grammars are extremely useful, (especially the 'namespelling' grammars).

Acessing Extension Grammars

As these builtin grammars are part of the 'core' ASR, we won't reference them like other builtin grammars. Instead, we have to jump through a hoop or two to make this happen. First off, let's take a look at the VXML code, as it bears on how we access these cool grammars:


<field name="MyField">
<grammar src="MyXMLWrapper.xml" type="application/grammar-xml"/>
...


You'll doubtlessly notice that we are referencing an external grammar file, which we will create in a moment, Mister Pushypants. It's important to recognize the fact that we gotta make this construct to be able to use the x-nuance grammars, and it's definitely important to notice our field name itself, as this will be important when coding our grammar wrapper. And of course, we *always* have to specify the grammar 'type' attribute, but you knew that already, didn't you? Of course you did, that's why we get along so well. Now let's look at our grammar wrapper itself:


<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
        xml:lang="en-US"
        root="MYRULE">

  <rule id="MYRULE">
      <one-of>
        <item>
          <ruleref uri="builtin:x-nuance-firstnamespelling"/>
          <tag><![CDATA[ <MyField $return> ]]> </tag> 
        </item>   
      </one-of>
    </rule>
</grammar>


This isn't the place to cover basic grXML syntax, so if you haven't already done so, skip back a few pages and familiarize yourself with it. We have only two things that might trip you up in this wrapper, so we highlighted the 'moving parts' for you Because We Care. We reference the x-nuance grammar in question within the <ruleref> tag; take special note of the fact that this needs a prefix of 'builtin:' before the grammar name itself. Also note that within the <tag> return value, we use the same slot value as our <field>. This is very important; if this isn't followed to the letter, then you will likely see problems when attempting to access the returned values. Now that we have the XML Wrapper syntax committed to memory, let's take a look at all the cool grammars that we can plug into this, shall we? A listing of these new additions with a brief description follows:

Extension Grammar
x-nuance-strictboolean

Details: This field type specifies only absolute utterances, 'filler' phrases such as 'please' and 'thanks' will not be recognized. This field type sends back a boolean, (true|false), grammar return.



Extension Grammar
x-nuance-strictphone

Details: The 'strictphone' field type will accept only absolute digit strings as utterances, an input of 'one eight hundred...' will not be accepted at all.


Extension Grammar
x-nuance-strictnumber

Details: This field type will accept only whole numbers such as 'four hundred twenty'; the utterance of 'four twenty' will result in a 'nomatch' condition.

Extension Grammar
x-nuance-currency-10m

Details: This built in extension grammar allows the caller to specify a US currency amount of up to 9,999,999 dollars


Extension Grammar
x-nuance-currency-100k

Details: This built in extension grammar allows the caller to specify a US currency amount of up to 999,999 dollars.


Extension Grammar
x-nuance-currency-10k

Details: This built in extension grammar allows the caller to specify a US currency amount of up to 99,999 dollars.


Extension Grammar
x-nuance-currency-1k

Details: This built in extension grammar allows the caller to specify a US currency amount of up to 9,999 dollars.


Extension Grammar
x-nuance-militaryalphabet

Details: The 'militaryalphabet' extension grammar will accept alphabetical utterances from the standard military alphabet; for instance, the utterance of 'a b c' would not be accepted, but 'alpha bravo charlie' would be a valid match.


Extension Grammar
x-nuance-namespelling

Details: This remarkably accurate SayAnything™ grammar allows the caller to spell out a name naturally, without the need for the military alphabet syantax of speech. The utterance of 'm-a-t-t-h-e-w' would be considered a valid, and recognizable utterance.

Extension Grammar
x-nuance-firstnamespelling

Details: A variant of the above 'namespelling' grammar, this built-in construct is geared towards recognizing a first name that the caller has spelled out naturally.


Extension Grammar
x-nuance-lastnamespelling

Details: Essentially the same as the above two grammars, this field type will accept spelled utterances, and is geared towards recognizing the more common last names.


Extension Grammar
x-nuance-creditcardaccount

Details: This useful built-in grammar allows a user to enter a 15 to 16 string numeric input as a credit card number, either by voice or via DTMF.


Extension Grammar
x-nuance- creditcardexpiration

Details: Specifies a credit card expiration date. DTMF grammars support 3-digit (1/02), 4-digit (01/02), 5-digit (1/2002), and 6-digit (01/2002) entries.


Extension Grammar
x-nuance-percentage

Details: This grammar recognizes whole percent values, such as 'forty two percent'. However, do note that a few ratio-based phrases are accepted as well, such as 'half', 'one third', and 'a quarter'.


Extension Grammar
x-nuance-socialsecurity

Details: This grammar allows for a nine-digit numeric string to be recognized, (either by voice or by DTMF input).


Extension Grammar
x-nuance-zipcode

Details: This built-in extension allows the caller to specify a 5 digit (only) zip code value to the application, either by voice or by dtmf.


Extension Grammar
x-nuance-stockprice

Details: The 'stockprice' grammar recognizes and returns common stock prices, and returns a decimal string. For example, "one fifty-six and three eighths dollars per share" returns a string value of 156.375.


Extension Grammar
x-nuance-countries

Details: This common grammar will recognize and return the more common world countries.


Extension Grammar
x-nuance-us-states

Details: Rather self-explanatory; this grammar will recognize and return any state in the US.


Extension Grammar
x-nuance-us-cities

Details: This grammar is geared towards recognizing the more common US cities. So, while it will likely catch 'New York City' as an utterance, your chances are slim for an expected match from  an utterance of 'Podunkville'.


Extension Grammar
x-nuance-world-cities

Details: This counterpart to the above grammar allows for non-US cities to be recognized. Again, major cities such as Hamburg or Normandy will get a valid match, but an obscure hamlet in Europe or Africa will likely not be recognized.


Extension Grammar
x-nuance-cities

Details: This extension grammar is an amalgamation of the above two entries; it allows the speaker to specify a US city, or a world city as a valid utterance.


Extension Grammar
x-nuance-duration-days

Details: This grammmar is used to specify a unit of time, measured in days or weeks. The grammar will return whichever value was specified in the days format; i.e., user input of 'a week and 3 days' will get the grammar return of '10'.


Extension Grammar
x-nuance-duration-minutes

Details: This grammar will accept time input in either minutes or hours. The utterance will always be returned in the 'minutes' format; 'a half hour' will get a return of '30'.







  ANNOTATIONS: EXISTING POSTS
moshe
6/7/2004 12:09 PM (EDT)
"And of course, we *always* have to specify the grammar 'type' attribute, but you knew that already, didn't you?"

If that's true, why doesn't the example "MyRule" have the 'type' attribute declared? And what would the 'type' be for these external built-in grammars?
MattHenry
6/7/2004 12:22 PM (EDT)
Moshe..

The grammar type is inherently determined when the XML grammar wrapper is hit. To explain:

-The grammar is declared to be of type 'application/grammar-xml' within the vxml document itself....this validates the statement that 'type' needs to be declared

- The builtin x-nuance grammar that is referenced returns a simple slot value to this XML grammar wrapper, nothing more. As such, there isn't any need to define the grammar type within the XML grammar file itself


In short, i don't think that this is a documentation error at all, but a misinterpretation of the docs themselves. The code listed in the above section does indeed work as-is, and does not require anything else for the developer to add.

~Matt
moshe
6/7/2004 1:43 PM (EDT)
Ah, I see it now:

<grammar src="MyXMLWrapper.xml" type="application/grammar-xml"/>

contains the required 'type' declaration, and the grammar following it, MYRULE, is the content of the file MyXMLWrapper.xml -- and doesn't need a declaration of 'type.'

I thought the sentence about requiring a type was a forward reference to MYRULE, not a backwards reference to <grammar 'src=...'>.

Thanks!
DaveMorris
3/16/2006 9:32 PM (EST)
x-nuance-creditcardaccount says 14 to 15 digit credit card numbers.  Is there such a thing as a 14 digit credit card number?  What about the majority of cards that are 16 digits?
MattHenry
3/17/2006 11:46 AM (EST)


Hiya Dave,

That's a typo on my part, that should read as "15-16 digit credit card numbers". Thanks for catching that; I'll correct this in our next bulid of the dcos.

~Matt
movoco
9/19/2006 1:50 PM (EDT)
Is it possible to use a built-in gramamr within a mixed-initiative dialog?

Ideally, I'd like to collect the city and state from a caller within a single dialog.

thanks
mikethompson
9/19/2006 5:30 PM (EDT)
Greetings Movoco,

I have not done this myself, but in theory, it should work.  The W3C specification actually has a nice example of exactly what you are looking to accomplish (minus the builtin grammars) here:

http://www.w3.org/TR/voicexml20/#dml2.1.5

Now, you can easily swap the grammar sources to use nuance extension grammars.  Just make sure you are referencing your grammars with a grXML wrapper as noted at the top of the tutorial.  Also make sure both the State and City extension grammars are required in a single <item> (as you want to capture this in one user utterance).  Lastly, make sure you are returning each match to the correct field (x-nuance-us-states returns to the state field). 

For example:

<ruleref uri="builtin:x-nuance-us-states"/>
          <tag><![CDATA[ <MyStateField $return> ]]>


I hope this helps get you started with mixed initiative dialogs referencing builtin nuance extension grammars.  I should also mention, these extension grammars are not available on our Prophecy platform, but our hosted environment has this readily accessible.

Best,
Mike Thompson
Voxeo Corporation
arjunpatel
4/27/2007 2:10 AM (EDT)
plese send me an vxml example link that take voice input from uesr like users name like arjun or methuee but these fields not have to be satatic, i mean if i say "hellow:" it return me "hellow" but i dont wants to specify these name in grammer field like [arjun hello]

i need an build-in grammer that return me anything whatever i spell

arjunpatel
4/27/2007 2:14 AM (EDT)
plese send me any simple example that uese the bild-in grammer and also write the instructions that how to upload and run this example
jbassett
4/27/2007 8:34 AM (EDT)
Here is an example of a vxml file referencing an external grammar.

XML file:

<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.0" >
<form>
<field name="MyField">
<grammar src="mygrammar.xml" type="application/grammar-xml"/>
<prompt bargein="false">
this is a test of the namespelling grammar you can begin now
</prompt>
</field>
</form>
</vxml>



mygrammar.xml

<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
        xml:lang="en-US"
        root="MYRULE">

  <rule id="MYRULE">
      <one-of>
        <item>
          <ruleref uri="builtin:x-nuance-namespelling"/>
          <tag><![CDATA[ <MyField $return> ]]> </tag>
        </item> 
      </one-of>
    </rule>
</grammar>

To figure out how to upload these files and test, please check out our quick start guide.

http://evolution.voxeo.com/docs/quickStart.jsp

Thanks
Jesse Bassett
Voxeo Support

login

  Inline grXML Subgrammars  |  TOC  |  K: Custom Features  

© 2003-2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site