【问题标题】:Kinect Speech Recognition only recognizing one grammar ruleKinect 语音识别仅识别一个语法规则
【发布时间】:2014-05-12 13:59:58
【问题描述】:

我目前正在使用 Microsoft Kinect SDK 开发语音识别应用程序。该应用程序的目标是加载包含语法的任何(有效)XML 文件并使用它来处理语音。 出于某种我还没有理解的原因,应用程序似乎只能识别属于 XML 语法文件中第一条规则的所有单词。例如,在以下语法中:

<grammar version="1.0" xml:lang="en-US" root="rootRule" tag-format="semantics/1.0-literals" xmlns="http://www.w3.org/2001/06/grammar">
<rule id="rootRule">
<one-of>
  <item>
    <tag>PEOPLE</tag>
    <one-of>
      <item> team </item>
      <item> kara </item>
      <item> john </item>
      <item> george </item>
    </one-of>
  </item>
  <item>
    <tag>FOOD</tag>
    <one-of>
      <item> apple </item>
      <item> banana </item>
    </one-of>
  </item>
</one-of>
</rule>
<rule id="anotherRule">
<one-of>
  <item>
    <tag>COMMANDS</tag>
    <one-of>
      <item> close </item>
      <item> shut down </item>
      <item> stop the application </item>
    </one-of>
  </item>
  <item>
    <tag>TOYS</tag>
    <one-of>
      <item> doll </item>
      <item> teddy bear </item>
    </one-of>
  </item>
  </one-of>
 </rule>
</grammar>

应用程序将只识别属于规则 ID“rootRule”的单词,忽略规则 ID“anotherRule”中的所有单词。为什么会这样?我不手动处理 XML 文件,SDK 已经这样做了,我只提供文件的位置:

spRecEng.LoadGrammar(new Grammar(filename));

它适用于第一条规则,所以理论上它应该适用于以下所有规则?!

我正在基于一个已经存在的应用程序开发我的应用程序(两者都有同样的问题),它的源代码可以在以下位置找到:https://dl.dropboxusercontent.com/u/28555145/KinectForWindowsSpeech.rar

【问题讨论】:

    标签: xml kinect speech


    【解决方案1】:

    你在语法元素root="rootRule"中指定了你的根规则:

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

    所以它以 rootRule 为基础。如果您需要替代方案,您可以在顶部构建替代方案。第二条规则可以被第一条规则引用并用于识别,例如见这里:

    http://msdn.microsoft.com/en-us/library/hh362887(v=office.14).aspx

    但是语法只有一个入口点可以进行识别。这就是引擎的工作原理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-15
      • 1970-01-01
      • 2018-04-17
      • 2011-11-01
      相关资源
      最近更新 更多