首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Microsoft语音识别平台

Microsoft语音识别平台
EN

Stack Overflow用户
提问于 2010-08-30 20:42:33
回答 1查看 13K关注 0票数 7

我用System.Speech在C#中写了一个语音识别的应用,它在Windows7上运行良好。然而,我想要创建一个同样可以在Windows2003 (x86)上运行的应用。

我的编程环境: Windows 7 x64 Pro Visual Studio2008

为了在我的编程环境中开发这个应用程序,我安装了:

1.Microsoft Speech Platform -服务器运行时(版本10.1) (x86)

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

2.Microsoft Speech Platform -软件开发工具包(版本10.1) (x86)

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

3.Microsoft Speech Platform - Server Runtime Languages (版本10.1)

(此处安装了适用于en-GB的SR )

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

在我的程序中,我使用了Microsoft.Speech.Recognition,而不是System.Speech;

粘贴SDK文档中的以下代码:

代码语言:javascript
复制
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;
  }
}

我还在项目属性中将平台目标设置为x86。代码可以编译,但一旦我运行或调试它,识别就不起作用了。知道我错过了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-09-01 02:14:47

您正在创建一个未指定引擎的语音识别引擎。由于您已经安装了en-GB引擎,因此需要指定一个cultureinfo (或recognizerinfo):

代码语言:javascript
复制
sre = new SpeechRecognitionEngine(new CultureInfo("en-GB")); 
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3600390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档