Share via


one-of Element

Specifies a set of alternative phrases that can possibly be matched by a user's speech input. Each alternative word or phrase must be enclosed within an item element.

Syntax

<one-of>...</one-of>

Attributes

None.

Remarks

Unlike the Speech Recognition Grammar Specification (SRGS) Version 1.0 specification, System.Speech does not support the use of the xml:lang attribute on the one-of element. Grammars in System.Speech can contain only one language, and this must be declared in the grammar Element.

Example

The rule named phoneRule in the grammar shown below recognizes utterances such as the following:

  • Call him at home.

  • Call her office.

  • Phone her at office.

The repeat attribute on the item element indicates that the words in the one-of element it encloses can be spoken zero or one time, making them optional.

<grammar root="phoneRule" version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
 xml:lang="en-US" tag-format="semantics/1.0">

  <rule id="phoneRule" scope="public">

    <one-of>
      <item> call </item> 
      <item> phone </item> 
    </one-of>

    <one-of>
      <item> him </item> 
      <item> her </item>  
    </one-of>
    
    <item repeat="0-1">
      <one-of>
        <item> on </item>
        <item> at </item>
      </one-of>
    </item>

    <one-of>
      <item> home </item>
      <item> mobile </item>
    </one-of>

  </rule>

</grammar>