我试图从统一使用Windows 10语法识别器,但它没有检测到任何东西。
private GrammarRecognizer grammarRecognizer;
在我的启动功能上:
grammarRecognizer = new GrammarRecognizer(Application.streamingAssetsPath + "/SRGS/myGrammar.xml", ConfidenceLevel.Low);
grammarRecognizer.OnPhraseRecognized += grammarRecognizer_OnPhraseRecognized;
grammarRecognizer.Start();
我也有这个功能:
void grammarRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
{
System.Action keywordAction;
Debug.Log("word said: " + args.text + " - conf: " + args.confidence);
if (args.confidence >= ConfidenceLevel.Medium)
Debug.Log("Confidence is low");
print(args.semanticMeanings);
}
但之前的功能永远不会被调用,因为它永远不会识别任何东西。我有这个语法:
<grammar version="1.0" xml:lang="en-US" root="playCommands"
xmlns="http://www.w3.org/2001/06/grammar">
<rule id="playCommands">
<ruleref uri="#playAction" />
<item> the </item>
<ruleref uri="#fileWords" />
</rule>
<rule id="playAction">
<one-of>
<item> play </item>
<item> start </item>
<item> begin </item>
</one-of>
</rule>
<rule id="fileWords">
<one-of>
<item> song </item>
<item> tune </item>
<item> track </item>
<item> item </item>
</one-of>
</rule>
</grammar>
答案 0 :(得分:0)
尝试取出标签中单词周围的空格。这为我解决了。