3
votes

I am building a GRXML grammar for a software that will use Microsoft's Speech SDK for voice recognition.

The tags must follow the tag-format "properties-ms/1.0" about which I did not find any specific documentation (apart from MSDN that does not answer my question).

My main concern is about tagging digits so as to transform a recognized text like "one two three four" into the number "1234". Here is the idea :

<rule id="CODE">
    <item repeat="4">
        <ruleref uri="#DIGIT"/>
    </item>
</rule>

<rule id="DIGIT">
    <one-of>
        <item>
            one
            <tag>"1"</tag>
        </item>
        <item>
            two
            <tag>"2"</tag>
        </item>
        <item>
            three
            <tag>"3"</tag>
        </item>
        <item>
            four
            <tag>"4"</tag>
        </item>
        <item>
            five
            <tag>"5"</tag>
        </item>
    </one-of>
</rule>

This does no concatenation but at least I get the semantic value for each digit.

However when I use such a rule for the digits, at runtime the program breaks, throwing an exception stating "The semantic value in rule 'CODE' was already set and cannot be changed.".

How can I make the semantic tagging work along with the "repeat" of the DIGIT rule ? I do not wish to split my CODE rule into 4 identical items, each with a different semantic key : there are other cases in my grammar where the number of digits is not fixed.

Also, is there a way to concatenate the tags so as to provide a general semantic meaning for the number .

2
according to msdn.microsoft.com/en-us/library/office/… "tag-format value ... properties-ms/1.0 - This value declares that the content within tag elements is a boolean, an integer, or a string. A string must be enclosed in double quotes."George Birbilis
also see msdn.microsoft.com/en-us/library/office/… regarding syntax differences depending on tag-formatGeorge Birbilis

2 Answers

1
votes

A possible solution would be something like this

<rule id="numbers">
  <item repeat="4">
   <ruleref uri="#numbers_1to4"/>
   <tag>out += rules.numbers_1to4;</tag> 
  </item>
</rule>


<rule id="numbers_1to4">
    <one-of>
      <item>one<tag>out = "1"</tag></item>
      <item>two<tag>out = "2"</tag></item>
      <item>three<tag>out = "3"</tag></item>
      <item>four<tag>out = "4"</tag></item>
     </one-of>
  </rule>
0
votes

I'm not familiar with the proprietary tag-format used in Microsoft's Speech SDK, but here's how you would accomplish this via the standard "semantics-1.0" format:

<rule id="CODE">
   <tag>out.CODE = &quot;&quot;;</tag>
   <item repeat="4">
      <ruleref uri="#DIGIT"/>
      <tag>out.CODE += rules.latest();</tag>
   </item>
</rule>


<rule id="DIGIT">
   <one-of>
      <item>
         one
         <tag>out = &quot;1&quot;;</tag>
      </item>
      <item>
         two
         <tag>out = &quot;2&quot;;</tag>
      </item>
      <item>
         three
         <tag>out = &quot;3&quot;;</tag>
      </item>
      <item>
         four
         <tag>out = &quot;4&quot;;</tag>
      </item>
      <item>
         five
         <tag>out = &quot;5&quot;;</tag>
      </item>
</one-of>