[英]Referencing the System.Speech.Recognition library - C#
I have a problem with my speech recognition reference in my C# application. 我的C#应用程序中的语音识别参考出现问题。 When I reference it in my C# code with the
using System.Speech.Recognition
statement, the program will only run when a microphone is present and will refuse to run when the opposite case is true. 当我
using System.Speech.Recognition
语句在C#代码中引用它时,该程序仅在存在麦克风时运行,而在相反情况为真时拒绝运行。 Is there a way that I can use this library selectively, so that the program won't shut down if another computer that is hosting it doesn't have a microphone? 有没有一种方法可以选择性地使用该库,以便在托管该库的另一台计算机没有麦克风的情况下该程序不会关闭? Thanks in advance!
提前致谢!
You need to check for the presence of the microphone before you create the SpeechRecognizer object. 在创建SpeechRecognizer对象之前,您需要检查麦克风是否存在。
Ie, instead of doing: 即,而不是做:
using System.Speech.Recognition;
SpeechRecognizer reco = new SpeechRecognizer();
do 做
using System.Speech.Recognition;
SpeechRecognizer reco = null;
if (MicrophonePresent())
{
reco = new SpeechRecognizer();
// do remainder of setup here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.