Note

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

Microsoft Speech Platform

SPPHRASERULE

SPPHRASERULE contains the information for a rule in a grammar result. The Speech Platform uses the pFirstChild and pNextSibling pointers to represent the parse tree. SPPHRASE.Rule is the root node of the parse tree.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>struct tagSPPHRASERULE</strong> { <strong>LPCWSTR</strong> <em>*pszName;</em> <strong>ULONG</strong> <em>ulId;</em> <strong>ULONG</strong> <em>ulFirstElement;</em> <strong>ULONG</strong> <em>ulCountOfElements;</em> <strong>const SPPHRASERULE</strong> *<em>pNextSibling;</em> <strong>const SPPHRASERULE</strong> *<em>pFirstChild;</em> <strong>float</strong> <em>SREngineConfidence;</em> <strong>signed char</strong> <em>Confidence;</em> }; </pre>

Members

  • pszName
    Name of this rule (for SRGS grammars, this is the value of the rule element's id attribute).
  • ulId
    ID of this rule (assigned by the Speech Platform when the grammar is loaded).
  • ulFirstElement
    The index of the first spoken element (word) of this rule.
  • ulCountOfElements
    Number of spoken elements (words) spanned by this rule.
  • pNextSibling
    Pointer to the next sibling in the parse tree.
  • pFirstChild
    Pointer to the first child node in the parse tree.
  • SREngineConfidence
    Confidence for this rule computed by the SR engine. The value is engine dependent and not standardized across multiple SR engines.
  • Confidence
    Confidence for this rule computed by Speech Platform. The value is either SP_LOW_CONFIDENCE, SP_NORMAL_CONFIDENCE, or SP_HIGH_CONFIDENCE.

Remarks

It is sometimes possible for ulFirstElement to have a value that is larger than the largest possible index for a recognized phrase. This can happen when a rule that can match zero elements is triggered at the end of a phrase. The following example shows a situation for which ulFirstElement can have a value that is out of range for the phrase.

The following example is a grammar that conforms to the Speech Recognition Grammar Specification (SRGS) Version 1.0 can match two input phrases: "one large drink" and "one large drink please". If a user speaks the phrase "one large drink", the value of ulCountOfElements for rule1 is 3 (the number of words in the phrase). In contrast, the value of ulCountOfElements for rule2 is 0, because this rule matched no words in the input phrase, and the value of ulFirstElement for rule2 is 3, the index that is one higher than that of the last word in the input phrase. For a phrase with three words, the valid indexes are 0, 1, and 2.

`

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

<rule id="rootRule" scope="public"> <ruleref uri="#rule1"> <ruleref uri="#rule2"> </rule>

<rule id="rule1" scope="private"> <item> one large drink </item> </rule>

<rule id="rule2" scope="private"> <item repeat="0-" repeat-prob="0.1"> please </item> </rule>

</grammar>

`