grammar Element
Specifies the highest level container for an XML grammar definition.
This element is required to make a valid grammar.
<grammar
version = "1.0"
mode = (voice | dtmf)
root = string
tag-format = semantics-ms/1.0
xml:lang = (en-US | es-US | fr-CA)
xml:base = grammarBaseUri
xmlns = "http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
</grammar>
Attributes
version
Required. Specifies the XML Speech Recognition Grammar Format version used. The only accepted value is 1.0.mode
Optional. Specifies the mode of the contained or referenced grammar. The mode can be one of the following values.- voice for spoken input
- dtmf for DTMF input
If omitted, the default value is voice.
root
Required. Specifies the name of the default grammar rule. If omitted, the grammar will compile, but will not trigger recognition.tag-format
Required. Specifies the content type of all tag elements contained within a grammar. If specified, the value is semantics-ms/1.0 for newly created grammars. If omitted, grammar processor handling of tags is undefined.xml:lang
Required if the value of the mode attribute is voice, optional if the value of the mode attribute is dtmf. The language identifier for the grammar or language contained by the document, and can optionally indicate a country/region or other variation. The accepted language identifiers include:- en-US for English (United States)
- es-US for Spanish (United States)
- fr-CA for French (Canada)
xml:base
Optional. Specifies a grammar document's base Uniform Resource Identifier (URI).xmlns
Required. Specifies the XML namespace for W3C speech recognition grammar. The XML namespace is http://www.w3.org/2001/06/grammar.xmlns:xsi
Optional. Defines a namespace prefix. Required only when the grammar uses the sapi:dynamic attribute of the rule element, or the sapi:pron attribute of the token element. When used, attribute and value must appear as follows: xmlns:sapi=https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions
Example
<!-- Language ID = United States English -->
<grammar version="1.0" mode="voice" root="HelloWorld"
tag-format="semantics-ms/1.0" xml:lang="en-US"
xml:base="https://www.contoso.com/"
xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<rule id="HelloWorld">
<!-- when the user says the following pronunciation, "hello" will be displayed -->
<item>hello</item>
</rule>
</grammar>