Compartir a través de


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

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

lexicon

Specifies one or more external pronunciation lexicon documents.

Optional

uri, type

meta

Specifies document metadata.

Optional

name, content

metadata

Contains information about the document in a metadata schema.

Optional

-

one-of

Specifies a set of alternative phrases that can possibly be matched by a user.

Optional

-

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, sapi:dynamic

ruleref

Specifies a reference to the rule to be imported.

Optional

uri, special, type

sapi:subset

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

tag

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

-

token

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

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 Grammar Files

Can be used to specify the description of a rule.

In This Section