找不到所需ID的识别器。\ r \ n参数名称:culture

时间:2016-08-27 13:24:17

标签: c# .net speech-recognition microsoft-speech-platform microsoft-speech-api

我正在使用微软语音识别器开发语音识别程序[Microsoft.Speech.Recognition]

SpeechRecognitionEngine sre;
private void button1_Click(object sender, EventArgs e)
{
  sre = new SpeechRecognitionEngine(new   CultureInfo(CultureInfo.CurrentCulture.Name.ToString())); //exception occurred here 
 // 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);
        //string str;
        ////RecognizerInfo rf = SpeechRecognitionEngine.InstalledRecognizers();
        //SpeechRecognitionEngine spe = new SpeechRecognitionEngine ();
        //str = spe.RecognizerInfo.Id;
        //string cul = spe.RecognizerInfo.Culture.NativeName ;
    }

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

从接受的答案中复制粘贴 当我运行这个程序时,我重新初始化对象“sre”

时出现异常

附加信息:找不到所需ID的识别器。

异常 - {“找不到所需ID的识别器。\ r \ nParameter name:culture”}

at Microsoft.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo culture)
at Text_To_Speech.SpeechToText.SpeechToText_Load(Object sender, EventArgs e) in F:\VSTest\ProjeTest\form\Text To Speech\Text To Speech\Text To Speech\SpeechToText.cs:line 41
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

开发环境

Windows Server 2012 X86

2015年视觉工作室

MicrosoftSpeechPlatformSDK - 版本11.0 X86

SpeechPlatformRuntime

0 个答案:

没有答案