2010-08-30 84 views
6

我在C#寫了一個應用程序使用System.Speech語音識別其在Windows 7 工作正常,但是我創建將在Windows 2003(86)工作在相同的應用程序後,我。微軟語音識別平臺

我的編程環境: Windows 7的64位專業版 Visual Studio 2008中

爲了在我的編程環境來開發這個應用程序我安裝:

1.Microsoft語音平臺 - 服務器運行時(10.1版) (86)

http://www.microsoft.com/downloads/details.aspx?FamilyID=674356C4-E742-4855-B3CC-FC4D5522C449&displaylang=en&displaylang=en

2.Microsoft語音平臺 - 軟件開發工具包(SDK)(10.1版)(86)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4d36908b-3264-49ef-b154-f23bf7f44ef4

3.Microsoft語音平臺 - 服務器運行時的語言(10.1版)

(在這裏安裝SR EN-GB)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=f704cd64-1dbf-47a7-ba49-27c5843a12d5

在我的程序,而不是系統。語音我使用了Microsoft.Speech.Recognition;在項目屬性

using Microsoft.Speech.Recognition; 

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace WindowsFormsApplication1 
{ 
    public partial class Form1 : Form 
    { 
    public Form1() 
    { 
     InitializeComponent(); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
     // Create a new SpeechRecognitionEngine instance. 
     sre = new SpeechRecognitionEngine(); 

     // Create a simple grammar that recognizes 「red」, 「green」, or 「blue」. 
     Choices colors = new Choices(); 
     colors.Add("red"); 
     colors.Add("green"); 
     colors.Add("blue"); 

     GrammarBuilder gb = new GrammarBuilder(); 
     gb.Append(colors); 

     // Create the actual Grammar instance, and then load it into the speech recognizer. 
     Grammar g = new Grammar(gb); 
     sre.LoadGrammar(g); 

     // Register a handler for the SpeechRecognized event. 
     sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized); 
     sre.SetInputToDefaultAudioDevice(); 
     sre.RecognizeAsync(RecognizeMode.Multiple); 
    } 

    // Simple handler for the SpeechRecognized event. 
    void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) 
    { 
     MessageBox.Show(e.Result.Text); 
    } 

    SpeechRecognitionEngine sre; 
    } 
} 

我還設置平臺目標86:

粘貼從SDK文檔此代碼。代碼編譯,但一旦我運行或調試它識別不起作用。任何想法我錯過了什麼?

+0

至少在Windows XP中,你不能沒有從SDK安裝組件運行語音識別軟件。您確定目標計算機上存在必需的組件嗎? – 2010-08-30 13:37:57

+0

的想法是先把在本地機器上這方面的工作,後來把它部署到Windows 2003 我的編程機是Windows 7的64位VS2008具有運行時,SDK和enGB SR安裝如上所述。編譯,在我的機器上運行,但它不能識別選項(顏色名稱) – 2010-08-30 16:32:43

+0

調試時,我注意到在 sre = new SpeechRecognitionEngine(); 屬性: EndSilenceTmeout EndSilenceTmeoutAmbiguous 拋出異常: 「識別器設置不被識別 支持,但計劃繼續執行 – 2010-08-30 16:38:17

回答

5

您正在創建語音識別引擎而未指定引擎。既然你已經安裝了EN-GB引擎,你需要指定一個cultureinfo(或recognizerinfo):

sre = new SpeechRecognitionEngine(new CultureInfo("en-GB")); 
+0

唉唉,這是它非常感謝:)! – 2010-08-31 19:56:16