Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Serialization of Developer-defined Rule Variable Properties (Microsoft.Speech)

By default, the semantic interpreter returns developer-defined properties of the Rule Variable as daughter nodes, where the element name for the node is the name of the property. If the script expression assigns a simple value to the property, the semantic interpreter returns the daughter node with its assigned value and a confidence value. In the following example, the script assigns the simple string value Orly to the Airport property. The speech recognition engine will return "Orly" when it recognizes the phrase "Paris".

<rule id="destination">
    Fly me to
    <one-of>
      <item> London <tag> out.Airport="Heathrow"; </tag></item>
      <item> Pairs <tag> out.Airport="Orly"; </tag></item>
      <item> Berlin <tag> out.Airport="Tegel"; </tag></item>
    </one-of>
</rule>

Using this grammar, the utterance "Fly me to Paris" produces the following SML output.

<SML text="Fly me to Paris" utteranceConfidence="0.840" confidence="0.840" >
    <Airport confidence="0.840"> Orly </Airport>
</SML>

Initializing Properties as Objects

If a script expression initializes a property of a Rule Variable as an object, the semantic interpreter returns a daughter node with a confidence attribute and the value of the object. If the object is empty, the interpreter returns an empty daughter node. The following grammar is identical to the previous grammar except that instead of assigning a simple scalar value to the Airport property, the expressions create Airport as an empty object.

<rule id="destination">
    Fly me to
    <one-of>
      <item> London<tag> out.Airport=new Object(); </tag></item>
      <item> Paris<tag> out.Airport=new Object(); </tag></item>
      <item> Berlin<tag> out.Airport=new Object(); </tag></item>
    </one-of>
</rule>

Using this grammar, the utterance "Fly me to Paris" produces the following SML output. Notice that there is no semantic value for Airport.

<SML text="Fly me to Paris" utteranceConfidence="0.840" confidence="0.840">
    <Airport confidence="0.840" />
</SML>

Returning Text Content in a Property Node

The text content contained in an SML node can be a simple type value only. To return an SML node that contains both a daughter node and text content in the daughter node, the script expression can assign the value to be returned to out.daughterNode. The following grammar illustrates this concept.

<rule id="destination">
  Fly me to
  <one-of>
    <item> London <tag> out.Airport="We fly to Heathrow airport"; </tag></item>
    <item> Paris <tag> out.Airport="We fly to Orly airport"; </tag></item>
    <item> Berlin <tag> out.Airport="We fly to Tegel airport"; </tag></item>
  </one-of>
</rule>

Using this grammar, the utterance "Fly me to Paris" produces the following SML output.

<SML text="Fly me to Paris" utteranceConfidence="0.840" confidence="0.840" >
    <Airport confidence="0.840"> We fly to Orly airport </Airport>
</SML>

Creating New Attributes for a Property Node

Use the _attributes property to add new developer-defined attributes to the nodes that are created by developer-defined properties. An important point to remember is that because the Airport property has a child property, it must be created with this script expression: out.Airport=new Object();. The following grammar is similar to the previous grammar except for the addition of script expressions that create new attributes in the Airport node of the SML output. Another difference between this grammar and the previous grammar is that the Airport node has text content and child nodes that have text content.

<rule id="destination">
  <tag>out.Airport=new Object();</tag>
  Fly me to
  <one-of>
    <item>London
      <tag>
        out.Airport._value="We fly to Heathrow airport";
        out.Airport._attributes.country="UK";
        out.Airport._attributes.code="EGLL";
        out.Airport._attributes.elevation="80 ft. MSL";
      </tag>
    </item>
    <item>Paris
      <tag>
        out.Airport._value="We fly to Orly airport";
        out.Airport._attributes.country="FR";
        out.Airport._attributes.code="LFPO";
        out.Airport._attributes.elevation="292 ft. MSL";
      </tag>
    </item>
    <item>Berlin
      <tag>
        out.Airport._value="We fly to Tegel airport";
        out.Airport._attributes.country="DEU";
        out.Airport._attributes.code="EDDT";
        out.Airport._attributes.elevation="121 ft. MSL";
      </tag>
    </item>
  </one-of>
</rule>

Using this grammar, the utterance "Fly me to Paris" produces the following SML output.

<SML text="Fly me to Paris" utteranceConfidence="0.949" confidence="0.949" >
  <Airport confidence="0.998" country="FR" code="LFPO" elevation="292 ft. MSL"> We fly to Orly airport </Airport>
</SML>

See Also

Concepts

Semantic Markup Language Reference (Microsoft.Speech)

Using the tag Element (Microsoft.Speech)