Beispiel #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;
        }
        public CortanaCommand(string name, string argument, CommandDiagnostics diagnostics=null) : this()
        {
            Name = name;
            Argument = argument;

            OrganizeFeedback(diagnostics);
        }
Beispiel #3
0
        /// <summary>
        /// Converts VoiceCommandActivatedEvent into specific CortanaCommand. 2 purposes:
        /// 1) Parse the "argument" of the command (ex. filename "My Cool Script", notepad note "feed the cat", etc.) into usable format.
        /// 2) Separate the details of "capturing" a voice command (here) from the command's business logic (in it's subclass of CortanaCommand)
        /// </summary>
        public static CortanaCommand ProcessCommand(VoiceCommandActivatedEventArgs commandArgs)
        {
            SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;
            CommandDiagnostics      diagnostics             = new CommandDiagnostics(commandArgs);

            return(ProcessCommand(speechRecognitionResult, diagnostics));
        }
Beispiel #4
0
        public CortanaCommand(string name, string argument, CommandDiagnostics diagnostics = null) : this()
        {
            Name     = name;
            Argument = argument;

            OrganizeFeedback(diagnostics);
        }
 private void OrganizeFeedback(CommandDiagnostics diagnostics)
 {
     if (diagnostics != null) {
         RawText = diagnostics.RawText;
         Mode = diagnostics.Mode;
     }
     else {
         RawText = Mode = null;
     }
 }
Beispiel #6
0
 private void OrganizeFeedback(CommandDiagnostics diagnostics)
 {
     if (diagnostics != null)
     {
         RawText = diagnostics.RawText;
         Mode    = diagnostics.Mode;
     }
     else
     {
         RawText = Mode = null;
     }
 }
Beispiel #7
0
 /// <summary>
 /// Converts VoiceCommandActivatedEvent into specific CortanaCommand. 2 purposes:
 /// 1) Parse the "argument" of the command (ex. filename "My Cool Script", notepad note "feed the cat", etc.) into usable format.
 /// 2) Separate the details of "capturing" a voice command (here) from the command's business logic (in it's subclass of CortanaCommand) 
 /// </summary>
 public static CortanaCommand ProcessCommand(VoiceCommandActivatedEventArgs commandArgs)
 {
     SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;
     CommandDiagnostics diagnostics = new CommandDiagnostics(commandArgs);
     return ProcessCommand(speechRecognitionResult, diagnostics);
 }
Beispiel #8
0
 public static UserCortanaCommand ProcessUserCommand(string voiceCommandName, SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics commandArgs)
 {
     SharedModel model = ModelHolder.Model;
     UserCortanaCommand command = null;
     if (model != null) {
         IList<UserCortanaCommand> commands = model.UserCortanaCommands;
         command = commands.Where( c => c.Name.Equals(voiceCommandName) ).First();
         if (command != null) {
             command = command.Spawn(speechRecognitionResult);
         }
     }
     return command;
 }
 public BriefMeCortanaCommand(string argument, CommandDiagnostics diagnostics = null) : base(BriefMe, argument, diagnostics) { /*Super constructor does everything*/ }
 public NotepadCortanaCommand(string argument, CommandDiagnostics diagnostics = null) : base(Notepad, argument, diagnostics) { /*Super constructor does everything*/ }
 public ToggleListeningCortanaCommand(string argument, CommandDiagnostics diagnostics = null) : base(ToggleListening, argument, diagnostics) { /*Super constructor does everything*/ }
Beispiel #12
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);
        }
Beispiel #13
0
        public static UserCortanaCommand ProcessUserCommand(string voiceCommandName, SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics commandArgs)
        {
            SharedModel        model   = ModelHolder.Model;
            UserCortanaCommand command = null;

            if (model != null)
            {
                IList <UserCortanaCommand> commands = model.UserCortanaCommands;
                command = commands.Where(c => c.Name.Equals(voiceCommandName)).First();
                if (command != null)
                {
                    command = command.Spawn(speechRecognitionResult);
                }
            }
            return(command);
        }
Beispiel #14
0
 public ExecuteCortanaCommand(string argument, CommandDiagnostics diagnostics = null) : base(Execute, argument, diagnostics) /*Super constructor does everything*/ }