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 override bool Equals(object obj) { if (obj == null || !(obj is CortanaCommand)) { return(false); } CortanaCommand cc = obj as CortanaCommand; bool sameName = this.Name.Equals(cc.Name); bool sameArg = false; if (Argument != null) { if (cc != null && cc.Argument != null) { sameArg = this.Argument.Equals(cc.Argument); } sameArg = false; } else { sameArg = cc != null && cc.Argument == null; } return(sameName && sameArg); }
/// <summary> /// Run the command in text mode (as opposed to voice mode). /// </summary> public static async Task RunAsTextCommand(CortanaCommand command) { // Store argument in clipboard string rawInput = command.ToInputString(); ClipboardHelper.CopyToClipboard(rawInput); // Run the closest thing to Cortana command line I have const string filename = "Cortanahk.ahk"; await FileHelper.Launch(filename, StorageFolders.LocalFolder); }
async Task IAppPage.RespondToVoice(CortanaCommand command) { await ViewModel.RespondToVoice(command); }
/// <summary> /// Run the command in text mode (as opposed to voice mode). /// </summary> public static async Task RunAsTextCommand(CortanaCommand command) { // Store argument in clipboard string rawInput = command.ToInputString(); ClipboardHelper.CopyToClipboard(rawInput); // Run the closest thing to Cortana command line I have const string filename = "Cortanahk.ahk"; await FileHelper.Launch(filename, StorageFolders.LocalFolder); }