Microsoft Speech Recognition - numbers only

2019-05-30 06:42发布

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条回答
干净又极端
2楼-- · 2019-05-30 07:01

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>
查看更多
登录 后发表回答