Exemplo n.º 1
0
        public void Initialize()
        {
            // Initialize Engine
            engine.SetInputToDefaultAudioDevice();
            engine.UnloadAllGrammars();

            // Load Grammar
            var commandDatabase = CommandDatabaseConfig.FromDirectory(Program.Config.CommandDatabaseDirectory);
            var grammars        = GrammarGenerator.FromConfig(commandDatabase);

            foreach (var grammar in grammars)
            {
                engine.LoadGrammar(grammar);
            }

            // Load Corrections
            var correctionsContent  = File.ReadAllText(Program.Config.CorrectionsDictionaryPath);
            var correctionsUnloaded = JsonConvert.DeserializeObject <Dictionary <string, string> >(correctionsContent);

            corrections.Clear();
            foreach (var kvp in correctionsUnloaded)
            {
                corrections.Add(kvp.Key, kvp.Value);
            }

            // Initialize Services
            foreach (var service in services.Values)
            {
                service.Initialize();
            }
        }
Exemplo n.º 2
0
        public CommandEngine()
        {
            Enabled = false;

            segment = "";
            lastTs  = DateTime.MinValue;

            actions         = new Dictionary <string, IAction>();
            commandDatabase = CommandDatabaseConfig.FromDirectory(Program.Config.CommandDatabaseDirectory);

            var asm = Assembly.GetExecutingAssembly();

            foreach (var type in asm.GetTypes()
                     .Where(x => typeof(IAction).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract))
            {
                actions[type.Name] = (IAction)Activator.CreateInstance(type);
            }
        }