Speech Recognition Grammar Specification
Appearance
Speech Recognition Grammar Specification (SRGS) is an W3C recommendation that defines syntax for representing grammars for use in speech recognition so that developers can specify the words and patterns of words to be listened for by a speech recognizer. There are two main forms of grammers. There is the Augmented BNF format and the XML.
Example of the Augmented BNF form:
#ABNF 1.0 ISO-8859-1; // Default grammar language is US English language en-US; // Single language attachment to tokens // Note that "fr-CA" (Canadian French) is applied to only // the word "oui" because of precedence rules $yes = yes | oui!fr-CA; // Single language attachment to an expansion $people1 = (Michel Tremblay | André Roy)!fr-CA; // Handling language-specific pronunciations of the same word // A capable speech recognizer will listen for Mexican Spanish and // US English pronunciations. $people2 = Jose!en-US; | Jose!es-MX; /** * Multi-lingual input possible * @example may I speak to André Roy * @example may I speak to Jose */ public $request = may I speak to ($people1 | $people2);
This is an example of the XML from:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd"> <grammar xmlns="http://www.w3.org/2001/06/grammar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd" xml:lang="en-US" version="1.0"> <rule id="yes"> <one-of> <item>yes</item> <item xml:lang="fr-CA">oui</item> </one-of> </rule> <rule id="people1"> <one-of xml:lang="fr-CA"> <item>Michel Tremblay</item> <item>André Roy</item> </one-of> </rule> <rule id="people2"> <one-of> <item xml:lang="en-US">Jose</item> <item xml:lang="es-MX">Jose</item> </one-of> </rule> <rule id="request" scope="public"> <example> may I speak with André Roy </example> <example> may I speak with Jose </example> may I speak with <one-of> <item> <ruleref uri="#people1"/> </item> <item> <ruleref uri="#people2"/> </item> </one-of> </rule> </grammar>