Microsoft Speech Recognition - numbers only

和自甴很熟 提交于 2019-12-08 08:35:29

问题


Is there a way to limit the grammar to numbers only in either dictation mode or in constructing a custom grammar XML file? Obviously I can't enter all the numbers into the XML, but there has to be an easy way.


回答1:


I know you asked this a long time ago, but I have a solution in case you still need it. Here is the file I came up with. This requires the user to speak single digits only, such as one five seven (not one fifty-seven, which will not work). You can play around with this to suit your needs:

<?xml version="1.0" encoding="utf-8" ?>
<grammar version="1.0" xml:lang="en-US" root="rootRule" xmlns="http://www.w3.org/2001/06/grammar">
  <rule id="rootRule">
    <item repeat="1-">
      <ruleref uri="#digit"></ruleref>
    </item>
  </rule>
  <rule id="digit">
    <one-of>
      <item>0</item>
      <item>1</item>
      <item>2</item>
      <item>3</item>
      <item>4</item>
      <item>5</item>
      <item>6</item>
      <item>7</item>
      <item>8</item>
      <item>9</item>
    </one-of>
  </rule>
</grammar>


来源:https://stackoverflow.com/questions/23635802/microsoft-speech-recognition-numbers-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!