private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { if (speechMap.ContainsKey(e.Verb)) { SendCommand(speechMap[e.Verb]); } switch (e.Verb) { case SpeechRecognizer.Verbs.PatchOne: midiMaster.SendProgramChange(0x00); break; case SpeechRecognizer.Verbs.PatchTwo: midiMaster.SendProgramChange(0x01); break; case SpeechRecognizer.Verbs.PatchThree: midiMaster.SendProgramChange(0x02); break; case SpeechRecognizer.Verbs.Calibrate: StartCalibration(); break; case SpeechRecognizer.Verbs.Done: AdvanceCalibration(); break; } }
void recognizer_SaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { FlyingText.NewFlyingText(mWindow.theGraphPlot.Graph_Rect.Width / 100, new Point(mWindow.theGraphPlot.Graph_Rect.Width / 2, mWindow.theGraphPlot.Graph_Rect.Height / 2), e.Matched); switch (e.Verb) { case SpeechRecognizer.Verbs.Start: mWindow.ControlPan.StartButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.Stop: mWindow.ControlPan.StopButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.Reset: mWindow.ControlPan.ResetButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.Pause: mWindow.Voice_Button.Background = Brushes.Red; mWindow.Voice_Button.Header = "Voice Paused"; break; case SpeechRecognizer.Verbs.Resume: mWindow.Voice_Button.Background = Brushes.Green; mWindow.Voice_Button.Header = "Voice Running"; break; case SpeechRecognizer.Verbs.AddLine: mWindow.ControlPan.AddLine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.AddSineCurve: mWindow.ControlPan.AddSine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.AddParabola: mWindow.ControlPan.AddParabola.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.EditingMode: mWindow.IndicatorPan.EditingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.MatchingMode: mWindow.IndicatorPan.MatchingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.TrackingMode: mWindow.IndicatorPan.TrackingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; case SpeechRecognizer.Verbs.NewRandomLine: mWindow.ControlPan.AddLine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent)); break; } }
private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { //should this be moved to allframesready? if (serve == false) { switch (e.Verb) { case SpeechRecognizer.Verbs.Serve: ellipse1.Height = 45; ellipse1.Width = 45; ellipse1.Opacity = 1; firsthit = true; serve = true; break; case SpeechRecognizer.Verbs.OneLeft: if (p1righty == true) { p1racket.RenderTransform = rotatetransform1; } p1righty = false; break; case SpeechRecognizer.Verbs.OneRight: if (p1righty == false) { p1racket.RenderTransform = rotatetransform2; } p1righty = true; break; case SpeechRecognizer.Verbs.TwoLeft: if (p2righty == true) { p2racket.RenderTransform = rotatetransform1; } p2righty = false; break; case SpeechRecognizer.Verbs.TwoRight: if (p2righty == false) { p2racket.RenderTransform = rotatetransform2; } p2righty = true; break; } } }
private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), e.Matched); switch (e.Verb) { case SpeechRecognizer.Verbs.Pause: this.myFallingThings.SetDropRate(0); this.myFallingThings.SetGravity(0); break; case SpeechRecognizer.Verbs.Resume: this.myFallingThings.SetDropRate(this.dropRate); this.myFallingThings.SetGravity(this.dropGravity); break; case SpeechRecognizer.Verbs.Reset: this.dropRate = DefaultDropRate; this.dropSize = DefaultDropSize; this.dropGravity = DefaultDropGravity; this.myFallingThings.SetPolies(PolyType.All); this.myFallingThings.SetDropRate(this.dropRate); this.myFallingThings.SetGravity(this.dropGravity); this.myFallingThings.SetSize(this.dropSize); this.myFallingThings.SetShapesColor(System.Windows.Media.Color.FromRgb(0, 0, 0), true); this.myFallingThings.Reset(); break; case SpeechRecognizer.Verbs.DoShapes: this.myFallingThings.SetPolies(e.Shape); break; case SpeechRecognizer.Verbs.RandomColors: this.myFallingThings.SetShapesColor(System.Windows.Media.Color.FromRgb(0, 0, 0), true); break; case SpeechRecognizer.Verbs.Colorize: this.myFallingThings.SetShapesColor(e.RgbColor, false); break; case SpeechRecognizer.Verbs.ShapesAndColors: this.myFallingThings.SetPolies(e.Shape); this.myFallingThings.SetShapesColor(e.RgbColor, false); break; case SpeechRecognizer.Verbs.More: this.dropRate *= 1.5; this.myFallingThings.SetDropRate(this.dropRate); break; case SpeechRecognizer.Verbs.Fewer: this.dropRate /= 1.5; this.myFallingThings.SetDropRate(this.dropRate); break; case SpeechRecognizer.Verbs.Bigger: this.dropSize *= 1.5; if (this.dropSize > MaxShapeSize) { this.dropSize = MaxShapeSize; } this.myFallingThings.SetSize(this.dropSize); break; case SpeechRecognizer.Verbs.Biggest: this.dropSize = MaxShapeSize; this.myFallingThings.SetSize(this.dropSize); break; case SpeechRecognizer.Verbs.Smaller: this.dropSize /= 1.5; if (this.dropSize < MinShapeSize) { this.dropSize = MinShapeSize; } this.myFallingThings.SetSize(this.dropSize); break; case SpeechRecognizer.Verbs.Smallest: this.dropSize = MinShapeSize; this.myFallingThings.SetSize(this.dropSize); break; case SpeechRecognizer.Verbs.Faster: this.dropGravity *= 1.25; if (this.dropGravity > 4.0) { this.dropGravity = 4.0; } this.myFallingThings.SetGravity(this.dropGravity); break; case SpeechRecognizer.Verbs.Slower: this.dropGravity /= 1.25; if (this.dropGravity < 0.25) { this.dropGravity = 0.25; } this.myFallingThings.SetGravity(this.dropGravity); break; } }
private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { }
private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { switch (e.Verb) { case SpeechRecognizer.Verbs.Protego: if (gamePaused) { return; } FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Protego"); double averageXWristPosition = this.rightWristXPosition.Sum() / FRAME_SIZE; double averageYWristPosition = this.rightWristYPosition.Sum() / FRAME_SIZE; double averageXBodyPosition = this.shoulderCenterXPosition.Sum() / FRAME_SIZE; double averageYBodyPosition = this.shoulderCenterYPosition.Sum() / FRAME_SIZE; double squaredDist = Math.Pow(averageXWristPosition - averageXBodyPosition, 2) + Math.Pow(averageYWristPosition - averageYBodyPosition, 2); // Wrist must be within sqrt(3000) distance of shoulder center (sternum) if (squaredDist < 3000) { this.myFallingThings.moveThingsAway(); this.myFallingThings.DrawShape(PolyType.Circle, MaxShapeSize, System.Windows.Media.Color.FromRgb(255, 255, 255)); this.protegoDuration = 300; // Shield is displayed for 300 frames this.hitSound.Play(); } break; case SpeechRecognizer.Verbs.Expelliarmus: if (gamePaused) { return; } FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Expelliarmus"); // We take the oldest 1/3 of frames within our window to compensate for delay of speech recognition double averageXVelocity = this.rightWristXVelocity.Take(Convert.ToInt32(FRAME_SIZE / 3)).Sum() * 3 / FRAME_SIZE; double xMoved = Math.Abs(this.rightWristXPosition[Convert.ToInt32(FRAME_SIZE / 2)] - this.rightWristXPosition[0]); // Must be moving left to right, and must have moved a specified minimum distance if (averageXVelocity > 0 && xMoved > 10) { this.myFallingThings.removeThings(); this.myFallingThings.AddToScore(0, 10, new Point(this.shoulderCenterXPosition.Sum() / FRAME_SIZE, this.shoulderCenterYPosition.Sum() / FRAME_SIZE)); this.popSound.Play(); } break; case SpeechRecognizer.Verbs.Stupefy: if (gamePaused) { return; } FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Stupefy"); double averageYVelocity = this.rightWristYVelocity.Sum() / FRAME_SIZE; // Must be moving up to down if (averageYVelocity > 0) { this.myFallingThings.SetSpinRate(0); this.myFallingThings.SetGravity(0); this.myFallingThings.AddToScore(0, 5, new Point(this.shoulderCenterXPosition.Sum() / FRAME_SIZE, this.shoulderCenterYPosition.Sum() / FRAME_SIZE)); this.hitSound.Play(); } break; case SpeechRecognizer.Verbs.Reset: FlyingText.NewFlyingText(this.screenRect.Width / 30, new Point(this.screenRect.Width / 2, this.screenRect.Height / 2), "Reset"); this.dropRate = DefaultDropRate; this.dropSize = DefaultDropSize; this.dropGravity = DefaultDropGravity; this.myFallingThings.SetPolies(PolyType.All); this.myFallingThings.SetDropRate(this.dropRate); this.myFallingThings.SetGravity(this.dropGravity); this.myFallingThings.SetSize(this.dropSize); this.myFallingThings.SetShapesColor(System.Windows.Media.Color.FromRgb(0, 0, 0), true); this.myFallingThings.Reset(); this.gamePaused = false; break; } }
void recognizer_SaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e) { switch (e.Verb) { case SpeechRecognizer.Verbs.Pause: dtwTextOutput.Text = "Pause"; player.Pause(); break; case SpeechRecognizer.Verbs.Resume: dtwTextOutput.Text = "Play"; player.Play(); break; case SpeechRecognizer.Verbs.Reset: dtwTextOutput.Text = "Reset"; player.Stop(); break; case SpeechRecognizer.Verbs.RandomColors: dtwTextOutput.Text = "Random Colors"; break; case SpeechRecognizer.Verbs.Colorize: dtwTextOutput.Text = "Colorize"; break; case SpeechRecognizer.Verbs.Bigger: dtwTextOutput.Text = "Bigger"; break; case SpeechRecognizer.Verbs.Quit: dtwTextOutput.Text = "Quit"; this.Close(); break; case SpeechRecognizer.Verbs.HideSkeleton: dtwTextOutput.Text = "Hide Skeleton"; skeletonCanvas.Visibility = Visibility.Hidden; break; case SpeechRecognizer.Verbs.HideDepth: dtwTextOutput.Text = "Hide Depth"; depthImage.Visibility = Visibility.Hidden; break; case SpeechRecognizer.Verbs.HideVideo: dtwTextOutput.Text = "Hide Video"; videoImage.Visibility = Visibility.Hidden; break; case SpeechRecognizer.Verbs.ShowSkeleton: dtwTextOutput.Text = "Show Skeleton"; skeletonCanvas.Visibility = Visibility.Visible; break; case SpeechRecognizer.Verbs.ShowDepth: dtwTextOutput.Text = "Show Depth"; depthImage.Visibility = Visibility.Visible; break; case SpeechRecognizer.Verbs.ShowVideo: dtwTextOutput.Text = "Show Video"; videoImage.Visibility = Visibility.Visible; break; case SpeechRecognizer.Verbs.PlayWildlife: dtwTextOutput.Text = "Play Wildlife Video"; videoMedia.Visibility = Visibility.Visible; videoMedia.Play(); break; case SpeechRecognizer.Verbs.StopWildlife: dtwTextOutput.Text = "Stop Wildlife Video"; videoMedia.Pause(); break; case SpeechRecognizer.Verbs.ResetWildlife: dtwTextOutput.Text = "Reset Wildlife Video"; videoMedia.Position = TimeSpan.FromSeconds(0); break; case SpeechRecognizer.Verbs.HideWildlife: dtwTextOutput.Text = "Hide Wildlife Video"; videoMedia.Pause(); videoMedia.Visibility = Visibility.Collapsed; break; } }