private void LoadContent() { kinectDevice = new Runtime(); kinectDevice.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectDevice.SkeletonEngine.TransformSmooth = true; kinectDevice.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectDevice.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); kinectDevice.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinectDevice_SkeletonFrameReady); kinectDevice.VideoFrameReady += new EventHandler <ImageFrameReadyEventArgs>(kinectDevice_VideoFrameReady); kinectAudio = new KinectAudioSource(); kinectAudio.FeatureMode = true; kinectAudio.AutomaticGainControl = false; kinectAudio.SystemMode = SystemMode.OptibeamArrayOnly; ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault(); sre = new SpeechRecognitionEngine(ri.Id); audioChoices = new Choices(); audioChoices.Add("stop"); audioChoices.Add("start"); audioChoices.Add("kinect shutdown"); audioChoices.Add("reset time"); audioChoices.Add("spree"); audioChoices.Add("reset hand"); audioChoices.Add("faster"); audioChoices.Add("slower"); grammerBuilder = new GrammarBuilder(); grammerBuilder.Culture = ri.Culture; grammerBuilder.Append(audioChoices); grammer = new Grammar(grammerBuilder); sre.LoadGrammar(grammer); sre.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized); sre.SetInputToAudioStream(kinectAudio.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null)); sre.RecognizeAsync(RecognizeMode.Multiple); player = new NinjaPlayer(this); backGround = Content.Load <Texture2D>("wood_paneling"); font = Content.Load <SpriteFont>("font"); sound = new SoundPlayer(); }
private void LoadContent() { kinectDevice = new Runtime(); kinectDevice.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); kinectDevice.SkeletonEngine.TransformSmooth = true; kinectDevice.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); kinectDevice.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); kinectDevice.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinectDevice_SkeletonFrameReady); kinectDevice.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(kinectDevice_VideoFrameReady); kinectAudio = new KinectAudioSource(); kinectAudio.FeatureMode = true; kinectAudio.AutomaticGainControl = false; kinectAudio.SystemMode = SystemMode.OptibeamArrayOnly; ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault(); sre = new SpeechRecognitionEngine(ri.Id); audioChoices = new Choices(); audioChoices.Add("stop"); audioChoices.Add("start"); audioChoices.Add("kinect shutdown"); audioChoices.Add("reset time"); audioChoices.Add("spree"); audioChoices.Add("reset hand"); audioChoices.Add("faster"); audioChoices.Add("slower"); grammerBuilder = new GrammarBuilder(); grammerBuilder.Culture = ri.Culture; grammerBuilder.Append(audioChoices); grammer = new Grammar(grammerBuilder); sre.LoadGrammar(grammer); sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized); sre.SetInputToAudioStream(kinectAudio.Start(), new SpeechAudioFormatInfo( EncodingFormat.Pcm, 16000,16,1,32000,2, null)); sre.RecognizeAsync(RecognizeMode.Multiple); player = new NinjaPlayer(this); backGround = Content.Load<Texture2D>("wood_paneling"); font = Content.Load<SpriteFont>("font"); sound = new SoundPlayer(); }