我试图编写一些语音识别应用程序,我发现了这段代码:
SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine();
recognitionEngine.SetInputToDefaultAudioDevice();
recognitionEngine.LoadGrammar(new DictationGrammar());
RecognitionResult result = recognitionEngine.Recognize(new TimeSpan(0, 0,20));
foreach (RecognizedWordUnit word in result.Words)
{
Console.Write(word.Text);
}
但是当我想调试它时,它在命令上显示错误访问被拒绝 HRESULT: 0x80070005 (E_ACCESSDENIED)):recognitionEngine.SetInputToDefaultAudioDevice();
(对 System.Speech 的引用已设置)。我已经浏览了很多线程,但我找不到答案。我应该在某个地方设置对麦克风的访问权限还是如何解决这个问题?
感谢你的回答 ;)