private void CreateCustomCommand(string command, CommandRepository commandRepository) { SpeechSynthesisService.Speak("Teach me how to do it"); IList <ICoreCommand> subCommands = new List <ICoreCommand>(); var newCommand = SpeechRecognitionService.Listen(); while (true) { var intent = IntentService.GetIntent(newCommand); if (CommandsHelper.GetCoreCommandIntents().Contains(intent.TopScoringIntent.Name) && intent.TopScoringIntent.Score > 0.7) { var factory = new CoreCommandFactory(); var coreCommand = factory.Create(intent.TopScoringIntent.Name); coreCommand.Validate(new List <string>(), true); subCommands.Add(coreCommand); SpeechSynthesisService.Speak("Anything else"); } else { if (intent.TopScoringIntent.Name == "no") { break; } SpeechSynthesisService.Speak("Cannot do that"); } newCommand = SpeechRecognitionService.Listen(); intent = IntentService.GetIntent(newCommand); if (intent.TopScoringIntent.Name == "no") { break; } } commandRepository.SaveCustomCommand(command, subCommands, Guid.NewGuid().ToString()); }
private static ICustomCommand SearchCommand(CommandRepository commandRepository, string command) { if (commandRepository.HasCustomCommand(command)) { return(commandRepository.GetCustomCommand(command)); } return(null); }
public CommandDetector() { _commandRepository = new CommandRepository(); }