Пример #1
0
        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());
        }
Пример #2
0
 private static ICustomCommand SearchCommand(CommandRepository commandRepository, string command)
 {
     if (commandRepository.HasCustomCommand(command))
     {
         return(commandRepository.GetCustomCommand(command));
     }
     return(null);
 }
Пример #3
0
 public CommandDetector()
 {
     _commandRepository = new CommandRepository();
 }