Example #1
0
        public static CortanaCommand ProcessCommand(SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics diagnostics)
        {
            // Get the name of the voice command and the text spoken
            string voiceCommandName = speechRecognitionResult.RulePath[0];
            string textSpoken = speechRecognitionResult.Text;

            string argument = null;
            CortanaCommand processedCommand = null;

            //bool modelUsed = ModelHolder != null;
            //if (modelUsed) {
            //    UserCortanaCommand userCommand = ProcessUserCommand(voiceCommandName, speechRecognitionResult, diagnostics);
            //    bool wasUserCommand = userCommand != null;
            //    if (wasUserCommand) {
            //        return userCommand;
            //    }
            //}

            switch (voiceCommandName)
            {
                case CortanaCommand.Execute:
                    argument = GetPhraseArg(speechRecognitionResult, "filename"); // filename
                    //argument = CortanaCommand.StripOffCommandName(voiceCommandName, textSpoken);
                    processedCommand = new ExecuteCortanaCommand(argument, diagnostics);
                    break;

                case CortanaCommand.ToggleListening:
                    processedCommand = new ToggleListeningCortanaCommand(null, diagnostics); // no argument needed
                    break;

                case CortanaCommand.YouTube:
                    const string youtube = "YouTube";
                    argument = CortanaCommand.StripOffCommandName(youtube, textSpoken); // search text
                    processedCommand = new YoutubeCortanaCommand(argument, diagnostics);
                    break;

                case CortanaCommand.Notepad:
                    const string notepad = "Notepad";
                    argument = CortanaCommand.StripOffCommandName(notepad, textSpoken); // text
                    processedCommand = new NotepadCortanaCommand(argument, diagnostics);
                    break;

                case CortanaCommand.FeedMe:
                    processedCommand = new FeedMeCortanaCommand(null, diagnostics); // no argument needed
                    break;

                case CortanaCommand.Calibrate:
                    processedCommand = new CalibrateCortanaCommand(null, diagnostics); // no argument needed
                    break;

                case CortanaCommand.BriefMe:
                    processedCommand = new BriefMeCortanaCommand(null, diagnostics); // no argument needed
                    break;

                default:
                    Debug.WriteLine("Command Name Not Found:  " + voiceCommandName);
                    break;
            }
            return processedCommand;
        }
Example #2
0
        public static CortanaCommand ProcessCommand(SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics diagnostics)
        {
            // Get the name of the voice command and the text spoken
            string voiceCommandName = speechRecognitionResult.RulePath[0];
            string textSpoken       = speechRecognitionResult.Text;

            string         argument         = null;
            CortanaCommand processedCommand = null;

            //bool modelUsed = ModelHolder != null;
            //if (modelUsed) {
            //    UserCortanaCommand userCommand = ProcessUserCommand(voiceCommandName, speechRecognitionResult, diagnostics);
            //    bool wasUserCommand = userCommand != null;
            //    if (wasUserCommand) {
            //        return userCommand;
            //    }
            //}

            switch (voiceCommandName)
            {
            case CortanaCommand.Execute:
                argument = GetPhraseArg(speechRecognitionResult, "filename");     // filename
                //argument = CortanaCommand.StripOffCommandName(voiceCommandName, textSpoken);
                processedCommand = new ExecuteCortanaCommand(argument, diagnostics);
                break;

            case CortanaCommand.ToggleListening:
                processedCommand = new ToggleListeningCortanaCommand(null, diagnostics);     // no argument needed
                break;

            case CortanaCommand.YouTube:
                const string youtube = "YouTube";
                argument         = CortanaCommand.StripOffCommandName(youtube, textSpoken); // search text
                processedCommand = new YoutubeCortanaCommand(argument, diagnostics);
                break;

            case CortanaCommand.Notepad:
                const string notepad = "Notepad";
                argument         = CortanaCommand.StripOffCommandName(notepad, textSpoken); // text
                processedCommand = new NotepadCortanaCommand(argument, diagnostics);
                break;

            case CortanaCommand.FeedMe:
                processedCommand = new FeedMeCortanaCommand(null, diagnostics);     // no argument needed
                break;

            case CortanaCommand.Calibrate:
                processedCommand = new CalibrateCortanaCommand(null, diagnostics);     // no argument needed
                break;

            case CortanaCommand.BriefMe:
                processedCommand = new BriefMeCortanaCommand(null, diagnostics);     // no argument needed
                break;

            default:
                Debug.WriteLine("Command Name Not Found:  " + voiceCommandName);
                break;
            }
            return(processedCommand);
        }