コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: hapsys/elite-voice
        public MainWindow()
        {
            InitializeComponent();


            TextLogger logger = TextLogger.instance;

            logger.output = logTextBox;

            /**
             * Initialize log4net
             */
            string log4netPath = "log4net/log4net.config";

            if (File.Exists(log4netPath))
            {
                XmlConfigurator.Configure(new FileInfo(log4netPath));
            }
            else if (File.Exists(Environment.ExpandEnvironmentVariables("%APPDATA%") + "/EliteVoice/" + log4netPath))
            {
                XmlConfigurator.Configure(new FileInfo(Environment.ExpandEnvironmentVariables("%APPDATA%") + "/EliteVoice/" + log4netPath));
            }
            else
            {
                logger.log("Not found log4net configuration. See documentation.");
            }

            var enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
            var dev        = enumerator.GetDefaultAudioEndpoint(NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.Role.Console);

            //logger.log(dev.DeviceFriendlyName);
            //logger.log(dev.FriendlyName);

            speech = Speech.instance;
            //speech.speech.
            audios = speech.speech.GetAudioOutputs();
            int idx = 0, i = 0;

            foreach (SpObjectToken audio in audios)
            {
                audioDevices.Items.Add(audio.GetDescription());
                //if (audio.GetDescription().Equals(speech.speech.AudioOutput.GetDescription()))
                if (audio.GetDescription().Equals(dev.FriendlyName))
                {
                    speech.speech.AudioOutput = audio;
                    idx = i;
                }
                i++;
            }
            audioDevices.SelectedIndex = idx;

            /*
             *
             */
            logger.log("Found voices:");
            foreach (ISpeechObjectToken voice in speech.speech.GetVoices())
            {
                logger.log(voice.GetDescription());
            }

            /**
             *
             */
            EliteVoice.ConfigReader.ConfigReader config = null;
            string configPath = "config/config.xml";

            if (File.Exists(configPath))
            {
                config = new EliteVoice.ConfigReader.ConfigReader(configPath);
            }
            else if (File.Exists(Environment.ExpandEnvironmentVariables("%APPDATA%") + "/EliteVoice/" + configPath))
            {
                config = new EliteVoice.ConfigReader.ConfigReader(Environment.ExpandEnvironmentVariables("%APPDATA%") + "/EliteVoice/" + configPath);
            }
            else
            {
                logger.log("Not found configuration!!!");
                return;
            }

            config.parse();

            /*
             *
             */
            commands = new CommandProcessor(config);
            List <FileDescription> files = new List <FileDescription>();

            fileGrid.ItemsSource = files;
            FileProcessor processor = new FileProcessor(files, commands);

            tProcessor = new Thread(new ThreadStart(processor.directoryRead));
            tProcessor.Start();
            lProcessor = new Thread(new ThreadStart(processor.processCurrentFile));
            lProcessor.Start();
        }
コード例 #2
0
 public CommandProcessor(EliteVoice.ConfigReader.ConfigReader config)
 {
     this.config = config;
     init();
 }