/// <summary> /// State Initializer /// </summary> public void InitializeKinectAudio() { KinectSensor sensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault(); if (null == sensor) { // Sensor not connected, bail throw new InvalidOperationException("Can not find Kinect sensor, make sure Kinect is connected"); } this.kinectAudioSource = sensor.AudioSource; this.kinectAudioSource.AutomaticGainControlEnabled = false; //Important to turn this off for speech recognition (Kinect SDK recommendaiton) sensor.Start(); this.kinectAudioStream = this.kinectAudioSource.Start(); Func <RecognizerInfo, bool> matchingFunc = r => { string value; r.AdditionalInfo.TryGetValue("Kinect", out value); return("True".Equals(value, StringComparison.InvariantCultureIgnoreCase) && "en-US".Equals(r.Culture.Name, StringComparison.InvariantCultureIgnoreCase)); }; sr.RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(matchingFunc).FirstOrDefault(); if (null == ri) { // If Speech recognizer is not detected, we have no choice but bail throw new InvalidOperationException("Can not find en-US speech recognizer"); } this.state.Recognizer = new sr.SpeechRecognitionEngine(ri.Id); }
public void StartListening(Microsoft.Speech.Recognition.RecognizerInfo recognizerInfo) { _ri = recognizerInfo; }