我最近尝试在Windows 7 Dell计算机上使用VS 2010中的C#(WinFormsApp)编写基本语音识别。我能够使用Microsoft的基本示例(http://msdn.microsoft.com/en-us/magazine/cc163663.aspx#S5)以及像这样的论坛来工作。但是,我需要更换计算机,现在我试图在具有相同规格的Lenovo计算机上进行复制。它不起作用,事实上,语音识别不断干扰程序运行,当我更改为SpeechRecognitionEngine
时,它仍然无法运行。 我能够编译没有错误,但我看不到结果,即显示e.Result.Text
的消息框。在c#VS 2010中使用Windows 7运行基本语音识别程序,它编译但它不运行
我的代码如下:
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;
using System.Speech.Recognition;
using System.Threading;
namespace SpeechRecogTest
{
public partial class Form1 : Form
{
SpeechRecognitionEngine sr = new SpeechRecognitionEngine();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//Create grammar
Choices words = new Choices();
words.Add("Hi");
words.Add("No");
words.Add("Yes");
Grammar wordsList = new Grammar(new GrammarBuilder(words));
wordsList.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized);
sr.LoadGrammar(wordsList);
}
void rec_SpeechRecognized(object sender, RecognitionEventArgs e)
{
MessageBox.Show(e.Result.Text);
}
}
}
我会很感激你的一切帮助。我非常肯定我已经安装了所有的SDK,包括SAPI 5.1,Windows SDK v7.0和v7.1,我还包括COM和NET的语音库,并且我构建了一个可用的合成器。
感谢您的回复。我只是尝试了我添加的两条线,但它也没有。我的电脑可以听写并验证它听到我的声音,但我的程序无法在我的文本框中显示此结果 – Ami 2011-04-29 22:57:31
为什么不尝试我发布在http://的小示例程序stackoverflow.com/questions/4730318/what-is-the-best-option-for-transcribing-speech-to-text-in-a-asp-net-web-app/4737003#4737003并查看它是否有效。看看是否有效。 – 2011-04-30 21:34:45
谢谢,我会的。我认为这与我在这台新电脑上做的安装有些关系,因为否则这个程序是逐字的。你认为哪些组件对于安装在x64 windows 7机器上很重要?我已经从注册表中删除了devenv.exe。 – Ami 2011-05-02 17:31:07