2013-05-31 100 views
3

我試圖讓一個簡單的語音識別程序啓動,但它不起作用,我已經安裝了一些語言(en-GB & en-US),但每當我使用以下內容時:SpeechRecognitionEngine.InstalledRecognizers返回沒有識別器安裝

SpeechRecognitionEngine.InstalledRecognizers

它返回一個空的集合。即使當我嘗試啓動識別器時,它也會返回「無識別器安裝」。但是當我重新安裝一種語言時,它說它已經安裝。

using (SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"))) 
{ 
    // Create and load a dictation grammar. 
    recognizer.LoadGrammar(new DictationGrammar()); 

    // Add a handler for the speech recognized event. 
    recognizer.SpeechRecognized += 
     new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized); 

    // Configure input to the speech recognizer. 
    recognizer.SetInputToDefaultAudioDevice(); 

    // Start asynchronous, continuous speech recognition. 
    recognizer.RecognizeAsync(RecognizeMode.Multiple); 

    // Keep the console window open. 
    while (true) 
    { 
     Console.ReadLine(); 
    } 
} 

由於什麼原因無法找到安裝的識別器?

編輯:

這是異常:{System.ArgumentException:所需ID的識別號找到。 參數名稱:文化 在System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo的文化)

和:這個問題是我安裝的語言包,可以var recognizers = SpeechRecognitionEngine.InstalledRecognizers();返回集合與0

+0

你的代碼中沒有地方叫'SpeechRecognitionEngine.InstalledRecognizers'。你能發佈你實際使用的代碼以及拋出的異常的全文嗎? –

+0

@ Dan Puzey,使用SpeechRecognitionEngine.InstalledRecognizers();僅用於檢查安裝的內容,我不會在實際代碼中使用它 – Jeffnl

+0

因此,無論您在問題中列出的代碼如何,情況都是如此。我可以在LinqPad中單獨運行這一行,並得到結果 - 看起來您最初發布的代碼與該問題無關。 –

回答

3

計數訪問Microsoft.Speech和我使用System.Speech,當我切換到Microsoft.Speech它的工作。

+1

@ [配置文件未找到]你能分享你在哪裏得到Microsoft.Speech語言包?我無法找到它們。我的電腦上安裝了英語(美國)語言,但SpeechRecognitionEngine recognitionizer = new SpeechRecognitionEngine(新的System.Globalization.CultureInfo(「en-US」))仍然失敗。 – Zesty