2013-06-02 48 views
4

我目前正在做一些關於Webkit語音識別的RnD,我想創建一個特定於應用程序的語法文件。 根據W3C定義,我寫了下面的代碼。但它似乎並沒有顯示出對這些詞的認可有了改進的結果。你能否提供一些幫助。?Web Speech API語法是否向開發人員公開?

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

語法文件是一個簡單的文件,看起來像下面這樣。

<?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> 
+0

任何人都可以提供一些關於上述q的支持嗎?如果需要更多的描述,它當然可以完成。謝謝。 –

+0

[有沒有一種方法可以在HTML5語音輸入API中使用語法?](http://stackoverflow.com/questions/8683772/is-there-a-way-to-use-a-grammar -with最HTML -5-語音輸入-API) –

回答

2

儘管w3c指定了網絡語音的語法,但它尚未由chrome實現。

相關問題