决定连接一个简单的语音写作应用程序作为学习语音识别 + F# 的测试平台。为了允许启动或停止语音识别,我连接了以下方法:
let Activate () =
sp.RecognizeAsync(RecognizeMode.Multiple)
let Deactivate () =
sp.RecognizeAsyncCancel()
sp.RecognizeAsyncStop()
我可以使用默认的语法词典很好地启动引擎。当我调用 deactivate 方法时,问题就来了。我经常遇到以下异常:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Speech.dll
Additional information: Cannot perform this operation while the recognizer is doing recognition.