2012-02-19 61 views
9

我對C#和微軟語音平臺都比較陌生,但我正在研究一個需要轉錄自由聽寫的服務器應用程序。 MS Speech Platform SDK似乎很完美,並且可以在服務器上工作,除非我引用了GrammarBuilder中的AppendDictation()方法。在Microsoft Speech Platform 11(服務器)上添加AppendDictation?

我使用的是微軟語音平臺SDK 11,如果我定義了一個語法的應用程序工作正常,但我在AppendDictation()添加的那一刻,我遇到了這個錯誤:

Cannot find grammar referenced by this grammar. 

即使從文檔這個樣本似乎失敗:

GrammarBuilder startStop = new GrammarBuilder(); 
GrammarBuilder dictation = new GrammarBuilder(); 
dictation.AppendDictation(); 

startStop.Append(new SemanticResultKey("StartDictation", new SemanticResultValue("Start Dictation",true))); 
startStop.Append(new SemanticResultKey("DictationInput", dictation)); 
startStop.Append(new SemanticResultKey("StopDictation", new SemanticResultValue("Stop Dictation", false))); 
Grammar grammar=new Grammar(startStop); 
grammar.Enabled=true; 
grammar.Name=" Free-Text Dictation "; 
_recognizer.LoadGrammar(grammar); 

奇怪的是,如果我改變LoadGrammar到LoadGrammarAsync,語法負載(或至少是事件處理程序被調用),但隨後的recoginzer失敗,此錯誤:

Error: At least one grammar must be loaded before doing a recognition. 

我讀過該平臺的服務器版本不支持聽寫,但它似乎很奇怪,它會出現一種方法,只是不工作。有沒有人設法讓聽寫語法在服務器上工作?我究竟做錯了什麼?

非常感謝

回答

11

對於任何人誰可能會遇到這樣的未來 - 現在我已經通過電子郵件來回與微軟,並最終收到此迴應:

The managed interfaces (Microsoft.Speech and System.Speech) are built on top of the native SAPI interfaces. These interfaces are the same for both the Server engine and the Desktop engine.

BUT the engine itself is responsible for implementing dictation, and the Server engine does not do so. Therefore, the call will fail when you load the grammar.

不是問題的答案我希望,但它確實解釋了它。

+1

那麼有沒有其他的方法來做聽寫呢? – KTF 2014-05-03 02:20:01

3

如果您使用System.Speech,則可以使用_recognizer.LoadGrammar(new DictationGrammar());加載語法,並且它可以正常工作。識別並不差,但是您必須使用16KHz PCM波形文件或其他兼容波形文件配置。很遺憾,不適用於Microsoft.Speech

相關問題