Partilhar via


Grammar XML

  Microsoft Speech Technologies Homepage

The syntax of the XML Grammar Tag Format in the Microsoft Speech Application SDK Version 1.1 (SASDK) uses Extensible Markup Language (XML) elements and attributes, as specified in the World Wide Web Consortium (W3C) Speech Recognition Grammar Specification Version 1.0. These XML elements and attributes represent the rule structures that define the words or phrases (commands) recognized by speech recognition engines.

Recognition Grammar Elements

The following table defines the XML elements that comprise the XML Grammar Tag Format, listed in alphabetical order.

Element name  Description Required/ Optional Attributes 
example 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
grammar Specifies the highest level container for an XML grammar definition. Required version
mode
root
tag-format
xml:lang
xml:base
xmlns
item Contains any legal rule expansion. Optional repeat
repeat-prob
weight
meta Specifies document metadata. Optional name
content
one-of Specifies a set of alternative phrases that can possibly be matched by a user. Optional xml:lang
rule 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
ruleref Specifies a reference to the rule to be imported. Optional uri
special
type
xml:lang
tag Specifies semantic information and/or an ECMA-compliant script that allows for the return of additional information when an element or series of elements is recognized. Optional
token Specifies a string that a speech recognizer can convert to a phonetic representation. Optional

Element Attributes

The following table defines the XML attributes that comprise the XML Grammar Tag Format, listed in alphabetical order.

Attribute name  Description
content Specifies the property name of metadata defined by a meta element.
id Specifies the programmatic name of a rule.
mode Specifies the mode (voice or DTMF) of the contained or referenced grammar.
name Specifies the value of the metadata property identified by the name attribute of a meta element.
repeat Specifies the number of times a set of phrases within a rule can be repeated.
repeat-prob Specifies the probability of successive repetition of a repeated item.
root Specifies a single rule within a grammar document that can be activated for recognition.
scope Specifies whether a rule can be used only within its containing grammar or whether it can be referenced by another grammar.
special Specifies a reference to one of the three reserved rulenames that have specific interpretation and processing by a speech recognizer.
tag-format Specifies the content type of all tag elements that a grammar contains.
type Specifies the media type of the grammar containing the reference.
uri Specifies the location, by Uniform Resource Identifier (URI), of the rule to be referenced.
version Specifies which version of the XML grammar specification is used.
weight Specifies a multiplying factor that increases the likelihood that an alternative is chosen from an alternative expansion.
xml:base Specifies a grammar document's base Uniform Resource Identifier (URI).
xml:lang Specifies the language identifier, and optionally a country/region or other variation, for the content of the element on which it appears.
xmlns Specifies the grammar namespace used.

Additional File Format Information

The following table contains links to additional XML Grammar Tag Format information.

Topic name Description
Rule Expansion Specifies the sets of words or phrases within a rule that is used to match user input.
XML DOCTYPE Declaration Specifies a reference to the grammar's associated Document Type Definition (DTD).
XML Header 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.
Comments in GRXML Documents Can be used to specify the description of a rule for display in the Microsoft Speech Application SDK (SASDK) Speech Grammar Editor Rule Browser.