SRGS Grammar XML Reference
System.Speech supports grammar files that use Extensible Markup Language (XML) elements and attributes, as specified in the World Wide Web Consortium (W3C) Speech Recognition Grammar Specification (SRGS) Version 1.0. These XML elements and attributes represent the rule structures that define the words or phrases (commands) recognized by speech recognition engines.
This section documents the elements and attributes of the SRGS specification, as implemented by System.Speech. Note that support for XML-format grammars in System.Speech differs from the SRGS specification in some areas. These differences are described in the topics of the elements to which they apply.
SRGS Grammar Elements
The following table describes the XML elements from the SRGS specification, and extensions by Microsoft, listed in alphabetical order.
Element |
Description |
Required/Optional |
Attributes |
---|---|---|---|
Specifies sample phrases that a user can say to match the containing rule. This element is illustrative and for the benefit of a developer reading the grammar; the speech recognition engine ignores it. |
Optional |
- |
|
Specifies the highest level container for an XML grammar definition. |
Required |
version, mode, root, tag-format, xml:lang, xml:base, xmlns |
|
Contains any legal rule expansion. |
Optional |
repeat, repeat-prob, weight |
|
Specifies one or more external pronunciation lexicon documents. |
Optional |
uri, type |
|
Specifies document metadata. |
Optional |
name, content |
|
Contains information about the document in a metadata schema. |
Optional |
- |
|
Specifies a set of alternative phrases that can possibly be matched by a user. |
Optional |
- |
|
Specifies the definition of a sequence of phrases that, if matched by user input, must be matched in the sequence specified in the definition. |
Required |
id, scope, sapi:dynamic |
|
Specifies a reference to the rule to be imported. |
Optional |
uri, special, type |
|
Specifies a phrase and a matching mode that allows the entire phrase to be recognized when only a subset of that phrase is found in the speech input. |
Optional |
sapi:match |
|
Specifies semantic information and/or ECMA-compliant script that allows for the return of additional information when an element or series of elements is recognized. |
Optional |
- |
|
Specifies a string that a speech recognizer can convert to a phonetic representation. |
Optional |
sapi:pron, sapi:display |
Note
The meta, metadata and lexicon elements must occur before all rule elements contained with the root grammar element. There are no constraints on the ordering of the metadata, meta, and lexicon elements.
Additional SRGS Format Information
The following table lists elements and features of XML documents that are not specific to grammar files.
Topic |
Description |
---|---|
Specifies a reference to the grammar's associated Document Type Definition (DTD). |
|
Specifies the XML version number, and optionally the character encodings, as part of a grammar document's XML declaration on the first line of the document. |
|
Can be used to specify the description of a rule. |