示例#1
0
        private void btPractice_Click(object sender, EventArgs e)
        {
            gbCommandEditor.Enabled = true;
            _recog.RecognizeAsyncStop();
            ls = ListnerStates.LS_INACTIVE;
            steps.Clear();
            step          = 0;
            rbOFF.Checked = true;
            Maven_Helper_Practice mhp = new Maven_Helper_Practice();

            mhp.Show();
        }
示例#2
0
 private void rbOFF_CheckedChanged(object sender, EventArgs e)
 {
     if (rbOFF.Checked == true)
     {
         gbCommandEditor.Enabled = true;
         _recog.RecognizeAsyncStop();
         ls = ListnerStates.LS_INACTIVE;
         steps.Clear();
         step            = 0;
         lbAlert.Visible = true;
     }
 }
示例#3
0
 private void rbON_CheckedChanged(object sender, EventArgs e)
 {
     if (rbON.Checked == true)
     {
         gbCommandEditor.Enabled = false;
         _recog.RecognizeAsync(RecognizeMode.Multiple);
         ls = ListnerStates.LS_INACTIVE;
         steps.Clear();
         step = 0;
         RefreshFile();
         lbAlert.Visible = false;
     }
 }
示例#4
0
        private void _recog_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            string SpeechText = e.Result.Text.ToLower();
            string Direction;

            CommandType command = SpeechToCommand(SpeechText);
            //Microsoft.VisualBasic.Interaction.MsgBox(command);

            bool directionalCommand = ((command == CommandType.CT_LEFT) || (command == CommandType.CT_RIGHT) || (command == CommandType.CT_BOTTOM));

            //Maven.SpeakAsync(SpeechText);

            if (command == CommandType.CT_RESET)
            {
                resetSteps();
                Maven.SpeakAsync("I have reset the game.");
                inactivityCounter = 0;
                tInactivity.Stop();
            }


            //If the recognizer is in inactive mode, it needs to be woken up
            if (ls == ListnerStates.LS_INACTIVE)
            {
                if ((command == CommandType.CT_DISPLAY) || (directionalCommand && (cbDisplay.Checked == true)))
                {
                    resetSteps();
                    tInactivity.Start();
                    inactivityCounter = 0;
                    ls = ListnerStates.LS_LISTENING;
                    Maven.SpeakAsync("Listening...");
                    if (directionalCommand)
                    {
                        steps.Add(SpeechText);
                        Maven.SpeakAsync(SpeechText);
                    }
                }
            }

            //If the recognizer is in listening mode, it will listen for top, left, right directional commands
            else if (ls == ListnerStates.LS_LISTENING)
            {
                if (directionalCommand)
                {
                    inactivityCounter = 0;
                    if (command != lastCommand)
                    {
                        steps.Add(SpeechText);
                        Maven.SpeakAsync(SpeechText);
                    }

                    if ((cbScurry.Checked == true) && (steps.Count == 6))
                    {
                        ls   = ListnerStates.LS_SPEAKING;
                        step = 0;
                        Maven.SpeakAsync("Get Ready...");
                        Direction = "Go " + (string)steps[step];
                        Maven.SpeakAsync(Direction);
                    }
                }
                else if (command == CommandType.CT_SCURRY)
                {
                    inactivityCounter = 0;
                    ls   = ListnerStates.LS_SPEAKING;
                    step = 0;
                    Maven.SpeakAsync("Get Ready...");
                    Direction = "Go " + (string)steps[step];
                    Maven.SpeakAsync(Direction);
                    if (step == steps.Count - 1)
                    {
                        resetSteps();
                        Maven.SpeakAsync("Hope that went well!");
                        tInactivity.Stop();
                    }
                }
            }

            else if (ls == ListnerStates.LS_SPEAKING)
            {
                if (command == CommandType.CT_NEXT)
                {
                    inactivityCounter = 0;
                    step++;
                    if (step < steps.Count)
                    {
                        Direction = "Go " + (string)steps[step];
                        Maven.SpeakAsync(Direction);
                        if (step == steps.Count - 1)
                        {
                            resetSteps();
                            Maven.SpeakAsync("Hope that went well!");
                            tInactivity.Stop();
                        }
                    }
                }
            }

            lastCommand = command;
        }
示例#5
0
 private void resetSteps()
 {
     ls = ListnerStates.LS_INACTIVE;
     steps.Clear();
     step = 0;
 }