Grammars
Last Updated: 05-26-2011

A grammar defines the set of valid expressions that a user can say or type when interacting with a voice application. Each interactive dialog in an application references one or more grammars using one or more grammar elements.

<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
<form id="form1">
<field name="field1">
   <grammar>
      <!-- grammar goes here -->
   </grammar>
</field>
</form>
</vxml>

You can also use the link element to define commands that behave consistently within a VoiceXML document or throughout your application.

<vxml version="2.1"
 xmlns="http://www.w3.org/2001/vxml">
<link event="mycompany.myapp.myevent1">
   <grammar>
     <!-- grammar goes here -->
   </grammar>
</link>
</vxml>

The Tellme Platform provides you with several choices when integrating grammars into your voice application:

The 'builtin' grammars are provided for rapid prototyping. These grammars are not tuned, and Tellme does not recommend that you use them in your production applications.

For a guide to developing SRGS grammars, see the Tellme Speech Service Grammar Developer's Guide on MSDN. Also on MSDN is an article that describes the use of the Studio Scratchpad to test SRGS grammars: Testing SRGS 1.0 Grammars With Tellme Studio.

Traditional IVR applications support touch-tone input also known as DTMF input. The Tellme Voice Application Network supports both DTMF and voice input. When constructing grammars, you will get superior performance and compliance with the VoiceXML specification if you separate your DTMF from your voice grammars and set the mode attribute on the grammar element to voice or dtmf appropriately. The following example shows two simple SRGS grammars. The first allows the user to say the name of a department. The second allows the user to enter a digit representing the desired department.

<?xml version= "1.0"?>

<grammar mode="voice"
         type="application/srgs+xml"
         root="root_rule"
         tag-format="semantics/1.0"
         version="1.0"
         xml:lang="en-US"
         xmlns="http://www.w3.org/2001/06/grammar">
  <rule id="root_rule" scope="public">
    <one-of>
      <item>
        <one-of>
          <item>
            sales
          </item>
        </one-of>
        <tag>out.dept = "010";</tag>
      </item>
      <item>
        <one-of>
          <item>
            marketing
          </item>
        </one-of>
        <tag>out.dept = "020";</tag>
      </item>
      <item>
        <one-of>
          <item>
            engineering
          </item>
        </one-of>
        <tag>out.dept = "030";</tag>
      </item>
      <item>
        <one-of>
          <item>
            public relations
          </item>
          <item>
            p r
          </item>
        </one-of>
        <tag>out.dept = "040";</tag>
      </item>
    </one-of>
  </rule>

</grammar>

<?xml version= "1.0"?>

<grammar mode="dtmf"
         type="application/srgs+xml"
         root="root_rule"
         tag-format="semantics/1.0"
         version="1.0"
         xmlns="http://www.w3.org/2001/06/grammar">
  <rule id="root_rule" scope="public">
    <one-of>
      <item>
        <one-of>
          <item>
            1
          </item>
        </one-of>
        <tag>out.dept = "010";</tag>
      </item>
      <item>
        <one-of>
          <item>
            2
          </item>
        </one-of>
        <tag>out.dept = "020";</tag>
      </item>
      <item>
        <one-of>
          <item>
            3
          </item>
        </one-of>
        <tag>out.dept = "030";</tag>
      </item>
      <item>
        <one-of>
          <item>
            4
          </item>
        </one-of>
        <tag>out.dept = "040";</tag>
      </item>
    </one-of>
  </rule>

</grammar>

The type attribute indicates to the VoiceXML interpreter the format of the grammar. In the previous example, the value "application/srgs+xml" indicates that the grammar is in the XML form of SRGS. The mode attribute indicates to the VoiceXML interpreter if the grammar is a voice or DTMF grammar.

You can gain additional performance benefits by setting the inputmodes property to voice or dtmf. For example, if you have a field containing grammars that accept DTMF input only, set the inputmodes property to dtmf. Doing so allows the interpreter to avoid listening for audio input and passing that data to the voice recognizer for additional processing.

[24]7 Inc.| Terms of Service| Privacy Policy| General Disclaimers