item Element (Microsoft.Speech)

Microsoft Speech Platform SDK 11

Collapse image Expand Image Copy image CopyHover image

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 token elements, a ruleref element, a tag element, 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 the contents of the item element are listed must match the sequence in which the content occurs in the input for recognition to be successful.

Syntax

XML Copy imageCopy Code
<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. If omitted, the content of the item element must occur exactly once in the input. A value of m- indicates that the item must occur a minimum of m 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 input is optional (a speaker can utter the content either zero times or one time).

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 item element to contain a rule expansion when it is necessary to make the rule expansion either optional or repeatable (in other words, in cases where the repeat attribute must be used). When the item element is contained in a one-of element, use the item element to contain a rule expansion when it is necessary to assign a weight to the rule expansion (in other words, in cases where the weight attribute must be used).

The effects of any tag elements contained within an item element are applied to the entire contents of the item element.

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".

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). To support multiple languages for your applications, you can use multiple grammars in parallel, each with a separate single language.

Example

XML Copy imageCopy Code
<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>