Is Web Speech API Grammar exposed to developers?

☆樱花仙子☆ 提交于 2019-11-29 23:19:38

问题


I am currently doing some RnD on Webkit Speech Recognition and I wanted to create an application specific grammar file. According W3C definition I wrote the following code. But it doesnt seem to show improved results in recognition for these words. Can you kindly provide some help with this.?

var recognition = new webkitSpeechRecognition(); recognition.grammars.addFromUri("voice/api_grammar/weight.grxml");

The grammar file is a simple file which looked like the following.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
                  "http://www.w3.org/TR/speech-grammar/grammar.dtd">

<grammar version="1.0"
         xmlns="http://www.w3.org/2001/06/grammar"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://www.w3.org/2001/06/grammar 
                             http://www.w3.org/TR/speech-grammar/grammar.xsd"
         xml:lang="en-US" mode="voice" root="sequence">

  <meta name='description' content='Example using examples'/>

  <meta name='in.1' content='sunny Yorktown Heights New York United States'/>
  <meta name='out.1' content='$sequence[$repeat[$alternatives["sunny"]],$ruleref[$token["Yorktown Heights"]],$Token["New","York"],$TOKEN["United States"]]'/>




  <rule id="ruleref">
    <example>"Yorktown Heights"</example>
    <ruleref uri="#token"/>
  </rule>

  <rule id="alternatives">
    <example>sunny</example>
    <example>cloudy</example>
    <example>warm</example>
    <example>cold</example>
    <one-of>
      <item> sunny </item>
      <item> cloudy </item>
      <item> warm </item>
      <item> cold </item>
    </one-of>
  </rule>

  <rule id="repeat">
   <example></example> <!-- for count=0 -->
   <example>warm</example>
   <example>warm sunny cloudy</example>
   <item repeat="0-3">
      <ruleref uri="#alternatives"/>
   </item>
  </rule>

  <rule id="sequence">
    <example>
      warm sunny cloudy "Yorktown Heights" New York "United States"
    </example>
    <example>
      warm sunny cloudy   Yorktown   Heights   New York United
            States
    </example>
    <example> <!-- this example is actually wrong but that is legal -->
      warm sunny cloudy "Yorktown   Heights" New York "United States"
    </example>

    <ruleref uri="#repeat"/> <ruleref uri="#ruleref"/>
    <ruleref uri="#Token"/> <ruleref uri="#TOKEN"/>    
  </rule>

</grammar>

回答1:


Though w3c specified the grammar for web speech it is not yet implemented by the chrome.



来源:https://stackoverflow.com/questions/16883609/is-web-speech-api-grammar-exposed-to-developers

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