【发布时间】: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
【问题讨论】: