Using the SRGS Grammar Format

SRGS (Speech Recognition Grammar Specification) is a W3C standard. The following URL links to the current version of that standard: http://www.w3.org/TR/speech-grammar/.

Unified CCX support only W3C XML grammar for speech recognition with Nuance adapter. The following XML and regular expression (regex) grammars are supported:

  • Nuance extensions for XML grammar.

  • regex grammar for DTMF input.

Note

The following are two example SRGS grammars. Each goes in a separate file. That is because an SRGS grammar can be either Voice mode or DTMF mode, but not both. Since voice is the default mode, it is does not need to be specified explicitly. Note, however, that it is possible to have both of these grammars active at the same time during recognition with a compound grammar. For further information on this topic, see Compound Grammar in the Cisco Unified Contact Center Express Scripting and Development Series: Volume 1, Getting Started with Scripts.

Two Example SRGS Grammars

<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xml:lang="en-US" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar"
root="main">
<rule id="main" scope="public">
<one-of>
<item>
hi
<tag>tag="hi"</tag>
</item>
<item>
joy
<tag>tag="lg"</tag>
</item>
</one-of>
</rule>
</grammar>
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xml:lang="en-US" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar"
root="main"
mode="dtmf">
<rule id="main" scope="public">
<one-of>
<item>
*
<tag>tag="bye"</tag>
</item>
<item>
4
<tag>tag="4"</tag>
</item>
</one-of>
</rule>

Nuance does not follow the W3C SRGS specification exactly. The SRGS specification allows vendor specific tag formats and Nuance uses their own specific tag formats. Nuance also requires a slightly different placement of the <tag> element. The following is a copy of the preceding two grammars for use with Nuance:

Two Example SRGS Grammars from Nuance

<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xml:lang="en-US" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar"
tag-format="nuance"
root="main">
root="main">
<rule id="main" scope="public">
<one-of>
<item>
hi
</item>
<tag><![CDATA[<tag hi>]]></tag>
<item>
joy
</item>
<tag><![CDATA[<tag lg>]]></tag>
</one-of>
</rule>
</grammar>
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar xml:lang="en-US" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar"
tag-format="nuance"
root="main"
mode="dtmf">
<rule id="main" scope="public">
<one-of>
<item>
*
</item>
<tag><![CDATA[<tag bye>]]></tag>
<item>
4
</item>
<tag><![CDATA[<tag 4>]]></tag>
</one-of>
</rule>
</grammar>
Note

By specifying tag-format in the SRGS header, Nuance programmers are able to use their Nuance proprietary syntax for representing semantic interpretation in the <tag> element. Note also that this Nuance syntax requires the use of CDATA to enclose the text in the <tag> element because the syntax uses syntactic elements that are also used by XML (that is < > ). CDATA tells the XML parser to ignore these syntactic elements until it sees the end of the CDATA enclosure ( ]]> ). This is described in the Extensible Markup Language (XML) specification at the following URL: http://www.w3.org/TR/REC-xml/. In particular, see the section: http://www.w3.org/TR/REC-xml/#sec-cdata-sect.