Exemple #1
0
        private void showConfirmation(SpeechRecognizer.SaidSomethingEventArgs e)
        {
            voiceConfirmEvent = e;

            switch (voiceConfirmEvent.Verb)
            {
                case SpeechRecognizer.Verbs.Close:
                case SpeechRecognizer.Verbs.Instrument:
                case SpeechRecognizer.Verbs.WallOfSound:
                case SpeechRecognizer.Verbs.KinectUp:
                case SpeechRecognizer.Verbs.KinectUpSmall:
                case SpeechRecognizer.Verbs.KinectDown:
                case SpeechRecognizer.Verbs.KinectDownSmall:
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.booleanChoices }, false, false);

                    voicePromptVisual(true);

                    voiceConfirmTime = new DispatcherTimer();
                    voiceConfirmTime.Interval = TimeSpan.FromMilliseconds(5000);
                    voiceConfirmTime.Tick += new EventHandler(voiceConfirmTime_Tick);
                    voiceConfirmTime.Start();
                    break;
                case SpeechRecognizer.Verbs.VoiceHelp:
                    if (MainWindow.mySpeechRecognizer.paused == true)
                    {
                        MainWindow.mySpeechRecognizer.toggleListening(true);
                    }
                    MainWindow.mySpeechRecognizer.resetSpeechTimeout(10);
                    showHelpVisual();
                    break;
            }
        }
Exemple #2
0
        void voiceGoDoThis(SpeechRecognizer.SaidSomethingEventArgs voiceCommand)
        {
            switch (voiceCommand.Verb)
            {
                case SpeechRecognizer.Verbs.Close:
                    Application.Current.Shutdown();
                    break;
                case SpeechRecognizer.Verbs.Instrument:
                    loadInstrument();
                    break;
                case SpeechRecognizer.Verbs.WallOfSound:
                    loadWallOfSound();
                    break;
                case SpeechRecognizer.Verbs.KinectUp:
                    MainWindow.adjustKinectAngle(8);
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
                    break;
                case SpeechRecognizer.Verbs.KinectUpSmall:
                    MainWindow.adjustKinectAngle(4);
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
                    break;
                case SpeechRecognizer.Verbs.KinectDown:
                    MainWindow.adjustKinectAngle(-8);
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
                    break;
                case SpeechRecognizer.Verbs.KinectDownSmall:
                    MainWindow.adjustKinectAngle(-4);
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
                    break;
            }

            MainWindow.mySpeechRecognizer.toggleListening(false);
        }
Exemple #3
0
 private void ListeningChanged(object sender, SpeechRecognizer.ListeningChangedEventArgs e)
 {
     if (e.Paused)
     {
         MainWindow.mySpeechRecognizer.stopListening(MainCanvas);
         MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
         MainWindow.SFXNotListening.Play();
         hideHelpVisual();
     }
     else
     {
         MainWindow.mySpeechRecognizer.startListening(MainCanvas);
         MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.startScreenChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices, MainWindow.mySpeechRecognizer.stopListeningChoices }, false, false);
         MainWindow.SFXListening.Play();
     }
 }
Exemple #4
0
        //Voice navigation code
        private void RecognizerSaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e)
        {
            //What to do when we're pretty certain the player said something we know
            if (e.Verb == SpeechRecognizer.Verbs.SpeechStart || e.Verb == SpeechRecognizer.Verbs.SpeechStop || e.Verb == SpeechRecognizer.Verbs.None)
            {
                return;
            }

            if (!showingConfirmDialog)
            {
                //Confirm the action
                showConfirmation(e);
            }
            else
            {
                //We're already at that stage, shall we do it yes or no?
                if (e.Verb == SpeechRecognizer.Verbs.True)
                {
                    actOnVoiceDecision(true);
                }
                else if (e.Verb == SpeechRecognizer.Verbs.False)
                {
                    actOnVoiceDecision(false);
                }
            }
        }
Exemple #5
0
        void voiceGoDoThis(SpeechRecognizer.SaidSomethingEventArgs voiceCommand)
        {
            if (voiceCommand.Verb != SpeechRecognizer.Verbs.ReturnToStart || voiceCommand.Verb != SpeechRecognizer.Verbs.Close)
            {
                MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.wallChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
            }

            int skeletonId = MainWindow.findVoiceCommandPlayer(MainWindow.sensor.AudioSource.SoundSourceAngle);

            switch (voiceCommand.Verb)
            {
                case SpeechRecognizer.Verbs.CustomWall:
                    //Switch to the Custom wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.CustomWall);
                    }
                    break;
                case SpeechRecognizer.Verbs.CreateWall:
                    //Record new samples for the Custom wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.RecordNewWall);
                    }
                    break;
                case SpeechRecognizer.Verbs.EightBitWall:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.EightBit);
                    }
                    //Switch to the 8-bit Wall
                    break;
                case SpeechRecognizer.Verbs.TranceWall:
                    //Switch to the Trance wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.Trance);
                    }
                    break;
                case SpeechRecognizer.Verbs.MetalWall:
                    //Switch to the Metal wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.Metal);
                    }
                    break;
                case SpeechRecognizer.Verbs.SaxWall:
                    //Switch to the Sax wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.Sax);
                    }
                    break;
                case SpeechRecognizer.Verbs.AnimalWall:
                    //Switch to the Sax wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.Animal);
                    }
                    break;
                case SpeechRecognizer.Verbs.BeatboxWall:
                    //Switch to the Sax wall
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        wallSwitchPlayerTo(MainWindow.activeSkeletons[skeletonId], menuOptions.Beatbox);
                    }
                    break;
                case SpeechRecognizer.Verbs.KinectUp:
                    //Angle Kinect up
                    MainWindow.adjustKinectAngle(8);
                    break;
                case SpeechRecognizer.Verbs.KinectUpSmall:
                    //Angle Kinect slightly up
                    MainWindow.adjustKinectAngle(4);
                    break;
                case SpeechRecognizer.Verbs.KinectDown:
                    //Angle Kinect down
                    MainWindow.adjustKinectAngle(-8);
                    break;
                case SpeechRecognizer.Verbs.KinectDownSmall:
                    //Angle Kinect sligtly down
                    MainWindow.adjustKinectAngle(-4);
                    break;
                case SpeechRecognizer.Verbs.Capture:
                    //Take a picture
                    takeAPicture();
                    break;
                case SpeechRecognizer.Verbs.ReturnToStart:
                    //Back to StartScreen
                    returnToStart();
                    break;
                case SpeechRecognizer.Verbs.Close:
                    //Close Moto
                    Application.Current.Shutdown();
                    break;
            }
            MainWindow.mySpeechRecognizer.toggleListening(false);
        }
Exemple #6
0
        // This method exists so that it can be easily called and return safely if the speech prereqs aren't installed.
        // We isolate the try/catch inside this class, and don't impose the need on the caller.
        public static SpeechRecognizer Create()
        {
            SpeechRecognizer recognizer = null;

            try
            {
                recognizer = new SpeechRecognizer();
            }
            catch (Exception)
            {
                // speech prereq isn't installed. a null recognizer will be handled properly by the app.
            }

            return recognizer;
        }
Exemple #7
0
        private void showConfirmation(SpeechRecognizer.SaidSomethingEventArgs e)
        {
            voiceConfirmEvent = e;

            switch (e.Verb)
            {
                case SpeechRecognizer.Verbs.CustomWall:
                case SpeechRecognizer.Verbs.CreateWall:
                case SpeechRecognizer.Verbs.EightBitWall:
                case SpeechRecognizer.Verbs.TranceWall:
                case SpeechRecognizer.Verbs.MetalWall:
                case SpeechRecognizer.Verbs.SaxWall:
                case SpeechRecognizer.Verbs.AnimalWall:
                case SpeechRecognizer.Verbs.BeatboxWall:
                case SpeechRecognizer.Verbs.KinectUp:
                case SpeechRecognizer.Verbs.KinectUpSmall:
                case SpeechRecognizer.Verbs.KinectDown:
                case SpeechRecognizer.Verbs.KinectDownSmall:
                case SpeechRecognizer.Verbs.Capture:
                case SpeechRecognizer.Verbs.ReturnToStart:
                case SpeechRecognizer.Verbs.Close:
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.booleanChoices }, false, false);
                    voicePromptVisual(true);

                    voiceConfirmTime = new DispatcherTimer();
                    voiceConfirmTime.Interval = TimeSpan.FromMilliseconds(5000);
                    voiceConfirmTime.Tick += new EventHandler(voiceConfirmTime_Tick);
                    voiceConfirmTime.Start();
                    break;
                case SpeechRecognizer.Verbs.VoiceHelp:
                    if (MainWindow.mySpeechRecognizer.paused == true)
                    {
                        MainWindow.mySpeechRecognizer.toggleListening(true);
                    }
                    MainWindow.mySpeechRecognizer.resetSpeechTimeout(10);
                    showHelpVisual();
                    break;
            }
        }
Exemple #8
0
 public static void setupVoice()
 {
     mySpeechRecognizer = SpeechRecognizer.Create();
     mySpeechRecognizer.Start(sensor.AudioSource);
 }
Exemple #9
0
 public static void destroyVoice()
 {
     mySpeechRecognizer.Dispose();
     mySpeechRecognizer = null;
 }
Exemple #10
0
        void voiceGoDoThis(SpeechRecognizer.SaidSomethingEventArgs voiceCommand)
        {
            if (voiceCommand.Verb != SpeechRecognizer.Verbs.ReturnToStart || voiceCommand.Verb != SpeechRecognizer.Verbs.Close)
            {
                MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.instrumentChoices, MainWindow.mySpeechRecognizer.kinectMotorChoices }, true, true);
            }

            int skeletonId = MainWindow.findVoiceCommandPlayer(MainWindow.sensor.AudioSource.SoundSourceAngle);

            switch (voiceCommand.Verb)
            {
                case SpeechRecognizer.Verbs.DrumsSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Drums);
                    }
                    break;
                case SpeechRecognizer.Verbs.GuitarSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarRight, MainWindow.PlayerMode.Acoustic);
                    }
                    break;
                case SpeechRecognizer.Verbs.LeftyGuitarSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarLeft, MainWindow.PlayerMode.Acoustic);
                    }
                    break;
                case SpeechRecognizer.Verbs.ElectricGuitarSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarRight, MainWindow.PlayerMode.Electric);
                    }
                    break;
                case SpeechRecognizer.Verbs.LeftyElectricGuitarSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.GuitarLeft, MainWindow.PlayerMode.Electric);
                    }
                    break;
                case SpeechRecognizer.Verbs.KeyboardSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Keyboard);
                    }
                    break;
                case SpeechRecognizer.Verbs.TriangleSwitch:
                    if (MainWindow.activeSkeletons.ContainsKey(skeletonId))
                    {
                        switchInstrument(MainWindow.activeSkeletons[skeletonId], instrumentList.Triangle);
                    }
                    break;
                case SpeechRecognizer.Verbs.StartMetronome:
                    currentFocus = playerFocus.Metronome;
                    metronome.destroyMetronome();
                    MainWindow.sensor.AllFramesReady -= listenForMetronome;
                    metronome.setupMetronome();
                    checkTutorial(MainWindow.Tutorials.Metronome);
                    MainWindow.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(listenForMetronome);
                    break;
                case SpeechRecognizer.Verbs.StopMetronome:
                    metronome.destroyMetronome();
                    MainWindow.sensor.AllFramesReady -= listenForMetronome;
                    break;
                case SpeechRecognizer.Verbs.BackToInstruments:
                    break;
                case SpeechRecognizer.Verbs.Capture:
                    takeAPicture();
                    break;
                case SpeechRecognizer.Verbs.KinectUp:
                    MainWindow.adjustKinectAngle(8);
                    break;
                case SpeechRecognizer.Verbs.KinectUpSmall:
                    MainWindow.adjustKinectAngle(4);
                    break;
                case SpeechRecognizer.Verbs.KinectDown:
                    MainWindow.adjustKinectAngle(-8);
                    break;
                case SpeechRecognizer.Verbs.KinectDownSmall:
                    MainWindow.adjustKinectAngle(-4);
                    break;
                case SpeechRecognizer.Verbs.ReturnToStart:
                    returnToStart();
                    break;
                case SpeechRecognizer.Verbs.Close:
                    Application.Current.Shutdown();
                    break;
            }
            MainWindow.mySpeechRecognizer.toggleListening(false);
        }
Exemple #11
0
        private void showConfirmation(SpeechRecognizer.SaidSomethingEventArgs e)
        {
            voiceConfirmEvent = e;

            switch (voiceConfirmEvent.Verb)
            {
                case SpeechRecognizer.Verbs.DrumsSwitch:
                case SpeechRecognizer.Verbs.GuitarSwitch:
                case SpeechRecognizer.Verbs.LeftyGuitarSwitch:
                case SpeechRecognizer.Verbs.ElectricGuitarSwitch:
                case SpeechRecognizer.Verbs.LeftyElectricGuitarSwitch:
                case SpeechRecognizer.Verbs.KeyboardSwitch:
                case SpeechRecognizer.Verbs.TriangleSwitch:
                case SpeechRecognizer.Verbs.StartMetronome:
                case SpeechRecognizer.Verbs.StopMetronome:
                case SpeechRecognizer.Verbs.KinectUp:
                case SpeechRecognizer.Verbs.KinectUpSmall:
                case SpeechRecognizer.Verbs.KinectDown:
                case SpeechRecognizer.Verbs.KinectDownSmall:
                case SpeechRecognizer.Verbs.BackToInstruments:
                case SpeechRecognizer.Verbs.Capture:
                case SpeechRecognizer.Verbs.ReturnToStart:
                case SpeechRecognizer.Verbs.Close:
                    MainWindow.mySpeechRecognizer.switchGrammar(new Choices[] { MainWindow.mySpeechRecognizer.booleanChoices }, false, false);

                    voicePromptVisual(true);

                    voiceConfirmTime = new DispatcherTimer();
                    voiceConfirmTime.Interval = TimeSpan.FromMilliseconds(5000);
                    voiceConfirmTime.Tick += new EventHandler(voiceConfirmTime_Tick);
                    voiceConfirmTime.Start();
                    break;
                case SpeechRecognizer.Verbs.VoiceHelp:
                    if (MainWindow.mySpeechRecognizer.paused == true)
                    {
                        MainWindow.mySpeechRecognizer.toggleListening(true);
                    }
                    MainWindow.mySpeechRecognizer.resetSpeechTimeout(10);
                    showHelpVisual();
                    break;
            }
        }