Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
item Element (Microsoft.Speech)
Contains any valid rule expansion. A valid rule expansion can consist of a word or other entity that can be spoken, such as content in a token Element (Microsoft.Speech), a ruleref Element (Microsoft.Speech), a tag Element (Microsoft.Speech), or any logical combination of these. When an item element contains a combination of rule expansions (for example, a combination of words), the sequence in which words occur in the speech input must match the sequence of rule expansions in the item element for recognition to be successful.
Syntax
<item
repeat = (n | m-n | m- | 0-1)
repeat-prob = (n | n. | n.nnnn | .nnnn)
weight = (n | n. | .n | n.n)
</item>
Attributes
The item element takes the following attributes:
Attribute |
Description |
---|---|
repeat |
Optional. Specifies the number of times a contained expansion can be repeated. The value of this attribute can be any positive integer, or any range of positive integers, but cannot be 0 (zero). The value of this attribute applies to the entire content of the item element. |
repeat-prob |
Optional. Specifies the probability of successive repetition of a repeated item. Applies only to items that have a repeat attribute. The value of this attributes is a positive floating-point value between 0.0 and 1.0 (inclusive). For example, a repeat-prob value of 0.8 indicates an 80% probability that the item is repeated. |
weight |
Optional. Specifies a multiplying factor that increases or decreases the likelihood that an alternative word or phrase is chosen from an expansion of alternative words or phrases. The value of this attribute is a positive floating-point value. Alternatives that do not have a weight specified have the default weight value of 1.0. A weight greater than 1.0 positively biases the alternative against alternatives that have no weight assigned, and a weight less than 1.0 negatively biases an alternative against alternatives that have no weight assigned. |
Remarks
Use the repeat attribute to define a rule expansion in an item element as either optional or repeatable. A value of n- indicates that the item must occur a minimum of n times and can be repeated an infinite number of times. For example, a value of 1- indicates that the content of the item element can occur from one to any number of times. A value of 0-1 indicates that the occurrence of the content of the item element in the speech input is optional (a speaker can utter the content either zero times or one time). If repeat is omitted, the content of the item element must occur exactly once in the speech input for successful recognition.
For item elements that contain alternatives within a one-of Element (Microsoft.Speech), use the weight attribute to assign a bias to each alternative relative to other alternatives. You can assign values to the weight attribute that are greater than or less than 1.0 to each alternative in an expansion. An alternative’s weight in comparison to other alternatives in an expansion determines its bias. For example, if the alternatives in an expansion have weights of .2, .5, and .7, the alternative with the weight of .7 would have the highest bias, even though its weight is less than 1.0. If another alternative in the same expansion did not have an assigned weight (it receives the default weight 1.0), it would have a higher bias than the alternatives with weights of .2, .5, and .7. In the example below, "medium" has a higher bias than "small", but a lower bias than "large".
The effects of a tag Element (Microsoft.Speech) contained within an item element are applied to the entire contents of the item element.
Unlike the Speech Recognition Grammar Specification (SRGS) Version 1.0 specification, the Microsoft Speech Platform SDK 11 does not support the use of the xml:lang attribute on the item element. Grammars in the Speech Platform SDK 11 can contain only one language, and this must be declared in the grammar Element (Microsoft.Speech).
Example
<grammar root="pizzaSize" version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US" tag-format="semantics/1.0">
<rule id="pizzaSize" scope="public">
<item repeat="0-1" repeat-prob=".4"> I would like </item>
a
<one-of>
<item weight=".5"> small </item>
<item> medium </item>
<item weight="2"> large </item>
</one-of>
pizza
</rule>
</grammar>