语音识别引擎不关机 - 无效操作异常 [英] Speech Recognition Engine does not shut down - invalid operation exception

查看:493
本文介绍了语音识别引擎不关机 - 无效操作异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

决定要连接一个简单的演讲书面申请作为测试床学习语音识别+ F#。以允许语音识别来开始或停止我有线了下列方法:

 让激活()=
     sp.RecognizeAsync(RecognizeMode.Multiple) 让停用()=
     sp.RecognizeAsyncCancel()
     sp.RecognizeAsyncStop()

我就可以开始使用默认语法词典发动机罚款。问题来了whens我称之为停用方法。我经常收到以下异常:

 'System.InvalidOperationException'类型的未处理的异常出现在System.Speech.dll 其他信息:当识别器识别做无法执行此操作。


解决方案

请参阅这里

有似乎与你的code两个问题:


  1. 您应该调用 RecognizeAsyncCancel RecognizeAsyncStop ,但不能同时使用。他们这样做只是同样的事情 RecognizeAysncCancel 截断输入,而 RecognizeAsyncStop 没有。我猜,叫他们两人一排是导致你所看到的错误。


  2. 两者 RecognizeAsyncCancel RecognizeAsyncStop 有当他们完成回调。直到最后的操作完成你不应该做任何事情的引擎。见链接,如何做到这一点的例子。


Decided to wire up a simple speech writing application as a test bed for learning Speech Recognition + F#. To allow the speech recognition to be started or stopped I wired up the following methods:

 let Activate () = 
     sp.RecognizeAsync(RecognizeMode.Multiple)

 let Deactivate () = 
     sp.RecognizeAsyncCancel()
     sp.RecognizeAsyncStop()

I can start the engine fine with the default grammar dictionary. The problem comes whens I call the deactivate method. I often get the following exception:

 An unhandled exception of type 'System.InvalidOperationException' occurred in System.Speech.dll

 Additional information: Cannot perform this operation while the recognizer is doing recognition.

解决方案

See here.

There appear to be two issues with your code:

  1. You should either call RecognizeAsyncCancel or RecognizeAsyncStop, but not both. They do the same thing except that RecognizeAysncCancel truncates the input while RecognizeAsyncStop doesn't. I'm guessing that calling both of them in a row is causing the error you're seeing.

  2. Both RecognizeAsyncCancel and RecognizeAsyncStop have callbacks for when they are complete. You shouldn't do anything else with the engine until the final operation is complete. See the link for an example of how to do this.

这篇关于语音识别引擎不关机 - 无效操作异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆