developer.com
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
New
 
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




See The Winners!




Developer Jobs

Be a Commerce Partner














 


Developer News -
Sun Releases NetBeans 6.7 IDE for Java, PHP    June 29, 2009
Why Firefox Doesn't Take Google Chrome Features    June 26, 2009
First Major PHP Update in Years Coming Soon    June 25, 2009
Red Hat CEO Calls on Oracle to Keep Java Open    June 25, 2009
Free Tech Newsletter -

VoiceXML 2.0 Grammars, Part I
By Jonathan Eisenzopf

Go to page: Prev  1  2  

Grammar Headers

ABNF and XML grammar files must contain specific header information; otherwise, the VoiceXML interpreter will fail to recognize the grammar properly. The elements of a grammar file are:

  • grammar declaration
  • language/locale
  • mode
  • root grammar
ABNF
# ABNF 1.0 ISO-8859-1;
language en;
mode voice;
root $topRule;
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar version="1.0" 
  xmlns="http://www.w3.org/2001/06/grammar"
  xml:lang="en" mode="voice" root="topRule">
...

Grammar declaration

The grammar declaration specifies the grammar version and optionally, the character encoding scheme that should be used. The grammar version should always be set to 1.0. The character encoding specifies the character symbols that will be used for the grammar. For example, ISO-8859-1 is usually the character encoding used for English. Asian languages including Japanese and Chinese (Big5 or Mandarine) would use a different encoding scheme. In ABNF grammars, this is the first line. In XML, the encoding scheme is defined by the encoding attribute of the XML declaration (the first line of any XML file). 

ABNF
# ABNF 1.0 ISO-8859-1;
language en;
mode voice;
root $topRule;
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar version="1.0" 
  xmlns="http://www.w3.org/2001/06/grammar"
  xml:lang="en" mode="voice" root="topRule">
...

The grammar version in an XML grammar is defined by the version attribute of the <grammar> element.

Language

Unless the grammar is a DTMF grammar, a language must be specified in the grammar header. For ABNF grammars, the language parameter defines the language (in this example, US English):

ABNF
# ABNF 1.0 ISO-8859-1;
language en;
mode voice;
root $topRule;
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar version="1.0" 
  xmlns="http://www.w3.org/2001/06/grammar"
  xml:lang="en" mode="voice" root="topRule">
...

The language in an XML grammar is specified by the xml:lang attribute of the <grammar> element.

Mode

Grammars can be scoped for speech input (voice) or touch-tone input (dtmf) based on the value of the mode parameter. The default mode is voice. If the grammar is scoped dtmf, then speech input will not be recognized. VoiceXML 2.0 grammars do not allow mixed mode grammars. That means that a voice scoped grammar cannot include a dtmf scoped grammar or vice versa. In cases where we may want an application to accept both voice and DTMF input, two separate grammars can be defined within a given VoiceXML scope so long as they aren't combined into a single grammar in any way.

ABNF
# ABNF 1.0 ISO-8859-1;
language en;
mode voice;
root $topRule;
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar version="1.0" 
  xmlns="http://www.w3.org/2001/06/grammar"
  xml:lang="en" mode="dtmf" root="topRule">
...

Root grammar 

When grammars contain many sub-grammar rules in a single file, it's important to identify the root grammar, or main the grammar that will be executed when a VoiceXML dialog calls the grammar file. 

ABNF
# ABNF 1.0 ISO-8859-1;
language en;
mode voice;
root $topRule;
XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<grammar version="1.0" 
  xmlns="http://www.w3.org/2001/06/grammar"
  xml:lang="en" mode="voice" root="topRule">
...

Filename Extensions

The filename extension for ABNF grammars is .gram and .grxml for XML grammars. This is the recommended (but not required) filename extension format for grammar files.

About Jonathan Eisenzopf

Jonathan is a member of The Ferrum Group, LLC which specializes in Voice Web consulting and training. Feel free to send an email to eisen@ferrumgroup.com regarding questions or comments about this or any article.

Go to page: Prev  1  2  

Next article: VoiceXML 2.0 Grammars, Part II


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Voice Archives






internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs