SAPI 和 Windows 7 问题
我尝试使用 Windows 7 识别语音,但它总是将语音识别为命令或只是说“那是什么?”。
我怎样才能获得所有演讲?
代码:
SpeechRecognizer _speechRecognizer;
public Window1()
{
InitializeComponent();
// set up the recognizer
_speechRecognizer = new SpeechRecognizer();
_speechRecognizer.Enabled = false;
_speechRecognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(_speechRecognizer_SpeechRecognized); }
I'm trying to recognize speech with Windows 7 but it always recognizes a speech as a command or just says "What was that?".
How I can get all speeches?
CODE:
SpeechRecognizer _speechRecognizer;
public Window1()
{
InitializeComponent();
// set up the recognizer
_speechRecognizer = new SpeechRecognizer();
_speechRecognizer.Enabled = false;
_speechRecognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(_speechRecognizer_SpeechRecognized); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您想使用 .net System.Speech 命名空间而不是 SAPI?几年前在 http://msdn 上发表了一篇非常好的文章.microsoft.com/en-us/magazine/cc163663.aspx。这可能是迄今为止我发现的最好的介绍性文章。它有点过时,但非常有帮助。 (AppendResultKeyValue 方法在测试版后已被删除。)
您是否尝试使用共享识别器?这可能就是您看到命令的原因。您有特定的认可任务吗?在这种情况下,您最好使用特定于任务的语法和 inproc 识别器。
如果您需要处理任何单词,请使用 System.Speech 附带的 DictationGrammar。请参阅 http://msdn。 microsoft.com/en-us/library/system.speech.recognition.dictationgrammar%28VS.85%29.aspx
为了好玩,我将最简单的 .NET Windows 窗体应用程序组合在一起,以使用我可以使用的听写语法想到。我创建了一个表格。在上面放一个按钮并将按钮变大。添加了对 System.Speech 和行的引用:
然后我将以下事件处理程序添加到button1:
Perhaps you want to use the .net System.Speech namespace instead of SAPI? There is a very good article that was published a few years ago at http://msdn.microsoft.com/en-us/magazine/cc163663.aspx. It is probably the best introductory article I’ve found so far. It is a little out of date, but very helfpul. (The AppendResultKeyValue method was dropped after the beta.)
Are you trying to use a shared recognizer? That may be why you are seeing commands. Do you have a specific task for recognition? In that case, you would be better served with a task specific grammar and an inproc recognizer.
If you need to handle any words, use the DictationGrammar that comes with System.Speech. See http://msdn.microsoft.com/en-us/library/system.speech.recognition.dictationgrammar%28VS.85%29.aspx
For fun, I whipped together the simplest .NET windows forms app to use a dictation grammar that I could think of. I created a form. Dropped a button on it and made the button big. Added a reference to System.Speech and the line:
Then I added the following event handler to button1: