我在C#写了一个应用程序使用System.Speech其在Windows 7上正常工作语音识别。 不过,我创建相同的应用程序,将在Windows 2003(x86)的工作后我。

我的编程环境: 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 /下载/ details.aspx?displaylang = EN&FAMILYID = 4d36908b-3264-49ef-B154-f23bf7f44ef4

3.Microsoft语音平台 - 服务器运行语言(版本10.1)

(对于烯GB这里安装SR)

的http:// WWW .microsoft.com /下载/ details.aspx?displaylang = EN&FAMILYID = f704cd64-1dbf-47a7-ba49-27c5843a12d5

在我的节目,而不是System.Speech我用Microsoft.Speech.Recognition;

粘贴从SDK文档此代码:

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。代码编译但一旦我运行或调试它肯定是行不通的。任何想法,我缺少的是什么?

有帮助吗?

解决方案

您要创建一个语音识别引擎,而无需指定一个引擎。既然你已经安装了EN-GB引擎,你需要指定的的CultureInfo (或 recognizerinfo ):

sre = new SpeechRecognitionEngine(new CultureInfo("en-GB")); 
scroll top