WP 8.1 语音识别中的 SRGS 语法和自由格式输入

SRGS grammars and free-form input in WP 8.1 Speech Recognition

我希望我的移动应用程序能够识别某些命令以便在页面之间导航。我使用 SRGS 语法在 xml 文件的帮助下描述命令。 例如,要显示新闻页面,我使用这样的规则:

<rule id="top">
<one-of>

  <item>
    <ruleref uri="#newsQuery"/>
    <tag>out.navigation = "News"</tag>
  </item>

</one-of>

<rule id="newsQuery" scope="public">
<example>Show me news</example>
<item repeat="0-1">Show</item>
<one-of>
  <item>latest news</item>
  <item>news page</item>
  <item>news</item>
  <item>latest news pages</item>
</one-of>

对我来说效果很好。但是,如果我想有这样的命令,例如 "Search {something}" ,其中 {something} 是您想要的任何东西并且它不能作为规则创建,我该怎么办?

我希望从 SpeechRecognitionResult 收到我要问的整个短语。

在 phone 上,您不能将自由形式的听写与语法混合,如 MSDN

所述

A grammar set can contain only one of either a dictation grammar or a web search grammar. Because the dictation and web search grammars perform recognition remotely, you can’t include them in a grammar set that contains grammars that perform recognition locally (as in a list grammar or an SRGS grammar) on the phone.

因此,对于您的任务,您只需为整个话语选择听写语法或网络搜索语法。我不担心一开始能认出 "search" ,反正剩下的更重要。您可以使用 AddGrammarFromPredefinedType

激活听写语法