本文整理汇总了C#中SpeechRecognitionEngine.SetInputToNull方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechRecognitionEngine.SetInputToNull方法的具体用法?C# SpeechRecognitionEngine.SetInputToNull怎么用?C# SpeechRecognitionEngine.SetInputToNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpeechRecognitionEngine
的用法示例。
在下文中一共展示了SpeechRecognitionEngine.SetInputToNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addApplication
public void addApplication(MonaApplication app)
{
SpeechRecognitionEngine appReco = new SpeechRecognitionEngine();
lock (runningApplications)
{
runningApplications[app.getIndex()] = app;
lock (commands)
{
commands[app.getIndex()] = new Dictionary<string, int>();
lock (engines)
{
lock (grammars)
{
grammars[app.getIndex()] = new Dictionary<string, Grammar>();
}
appReco.SetInputToNull();
appReco.SpeechRecognized += recognizedWord;
appReco.MaxAlternates = 1;
engines[app.getIndex()] = appReco;
}
}
lock (numberLock)
{
applicationsNb++;
}
}
}
示例2: AddRecognizer
AudioInstance AddRecognizer(bool active)
{
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new CultureInfo("en-GB"));
try
{
//dumpSupported(recognizer);
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
//recognizer.LoadGrammar(CreateGrammar(mTheWorld));
// Configure the input to the recognizer.
recognizer.SetInputToNull();
// Attach event handlers.
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(recognizer_RecognizeCompleted);
recognizer.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(recognizer_SpeechHypothesized);
// Perform recognition of the whole file.
//Form1.updateLog("Starting asynchronous recognition...");
AudioInstance ai = new AudioInstance();
ai.audioStream = null;
ai.ID = null;
ai.engine = recognizer;
ai.Active = false;
ai.NeedNewGrammar = true;
//Console.WriteLine("Entering lock: AddRecognizer");
lock (engines)
{
engines.Add(ai);
if (active) ai.Active = true;
}
//Console.WriteLine("Exitting lock: AddRecognizer");
return ai;
}
catch (Exception e)
{
Form1.updateLog("AddStream exception: " + e.ToString(), ELogLevel.Error,
ELogType.Audio | ELogType.SpeechRecog);
}
return null;
}