public SpeechPlatformRecognizer(String lang, Boolean kinect) { //Console.WriteLine("Looking for Speech Platform recognizers"); foreach (RecognizerInfo config in SpeechRecognitionEngine.InstalledRecognizers()) { //if (config.Culture.Equals(requiredCulture) && config.Id == requiredId) { //Console.WriteLine(" Found: " + config.Description); if (speechRecognitionEngine == null && lang.Equals(config.Culture.IetfLanguageTag)) { if (kinect) { string value; config.AdditionalInfo.TryGetValue("Kinect", out value); if (!"True".Equals(value, StringComparison.OrdinalIgnoreCase)) { continue; } } speechRecognitionEngine = new SpeechRecognitionEngine(config); } } if (speechRecognitionEngine == null) { return; } speechRecognitionEngine.MaxAlternates = 1; speechRecognitionEngine.SpeechDetected += delegate(object sender, SpeechDetectedEventArgs eventArgs) { if (listener != null) { listener.speechDetected(maxAudioLevel); } }; speechRecognitionEngine.RecognizeCompleted += delegate(object sender, RecognizeCompletedEventArgs eventArgs) { processRecognizeCompletedEventArgs(eventArgs); }; speechRecognitionEngine.SpeechHypothesized += delegate(object sender, SpeechHypothesizedEventArgs eventArgs) { processSpeechHypothesizedEventArgs(eventArgs); }; speechRecognitionEngine.AudioLevelUpdated += delegate(object sender, AudioLevelUpdatedEventArgs eventArgs) { //Console.WriteLine(eventArgs.AudioLevel); maxAudioLevel = Math.Max(maxAudioLevel, eventArgs.AudioLevel); }; //setInputToDefaultAudioDevice(); }
public DesktopRecognizer(String lang) { //Console.WriteLine("Looking for Windows Desktop recognizers"); foreach (RecognizerInfo config in SpeechRecognitionEngine.InstalledRecognizers()) { if (speechRecognitionEngine == null && lang.Equals(config.Culture.IetfLanguageTag)) { speechRecognitionEngine = new SpeechRecognitionEngine(config); } } if (speechRecognitionEngine == null) { return; } speechRecognitionEngine.MaxAlternates = 1; speechRecognitionEngine.SpeechDetected += delegate(object sender, SpeechDetectedEventArgs eventArgs) { if (listener != null) { listener.speechDetected(maxAudioLevel); } }; speechRecognitionEngine.RecognizeCompleted += delegate(object sender, RecognizeCompletedEventArgs eventArgs) { processRecognizeCompletedEventArgs(eventArgs); }; speechRecognitionEngine.SpeechHypothesized += delegate(object sender, SpeechHypothesizedEventArgs eventArgs) { processSpeechHypothesizedEventArgs(eventArgs); }; speechRecognitionEngine.AudioLevelUpdated += delegate(object sender, AudioLevelUpdatedEventArgs eventArgs) { //Console.WriteLine(eventArgs.AudioLevel); maxAudioLevel = Math.Max(maxAudioLevel, eventArgs.AudioLevel); }; //setInputToDefaultAudioDevice(); }