[英]Referencing the System.Speech.Recognition library - C#
我的C#應用程序中的語音識別參考出現問題。 當我using System.Speech.Recognition
語句在C#代碼中引用它時,該程序僅在存在麥克風時運行,而在相反情況為真時拒絕運行。 有沒有一種方法可以選擇性地使用該庫,以便在托管該庫的另一台計算機沒有麥克風的情況下該程序不會關閉? 提前致謝!
在創建SpeechRecognizer對象之前,您需要檢查麥克風是否存在。
即,而不是做:
using System.Speech.Recognition;
SpeechRecognizer reco = new SpeechRecognizer();
做
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.