コード例 #1
0
        public void Main()
        {
            Regex regex = new Regex(@"</?\w+((\s+\w+(\s*=\s*(?:"".*?""|'.*?'|[^'"">\s]+))?)+\s*|\s*)/?>", RegexOptions.Singleline);
            SpeechRecognitionEngine speechEngine = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
            speechEngine.LoadGrammar(new Grammar(new GrammarBuilder("quit")));

            speechEngine.SpeechRecognized += speechEngine_SpeechRecognized;
            speechEngine.SetInputToDefaultAudioDevice(); // set input to default audio device

            speechEngine.RecognizeAsync(RecognizeMode.Multiple); // recognize speech
            speechEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechEngine_SpeechRecognized);

            connector = new Connector();
            connector.DeviceConnected += new EventHandler(OnDeviceConnected);
            connector.DeviceFound += new EventHandler(OnDeviceFound);
            connector.DeviceNotFound += new EventHandler(OnDeviceNotFound);
            connector.DeviceConnectFail += new EventHandler(OnDeviceNotFound);
            connector.DeviceDisconnected += new EventHandler(OnDeviceDisconnected);
            connector.DeviceValidating += new EventHandler(OnDeviceValidating);

            connector.setMentalEffortEnable(true);
            connector.setAppreciationEnabled(true);
            connector.setBlinkDetectionEnabled(false);
            connector.setMentalEffortRunContinuous(true);
            connector.setPositivityEnable(true);
            connector.setRespirationRateEnable(true);

            AvatarDescription.CreateRandom(AvatarBodyType.Female);

            //connector.Find();
            //connector.thinkGearPorts("COM5");
            //connector.Connect("COM5");
            //connector.Connect("COM6");
            // Scan for devices across COM ports
            // The COM port named will be the first COM port that is checked.
            connector.ConnectScan("COM29");

            // Blink detection needs to be manually turned on
            // connector.setBlinkDetectionEnabled(true);
            // Thread.Sleep(450000);

            if (connector.setMentalEffortEnable(true))
            {     // return true, means success
                Console.WriteLine("HelloEEG: MentalEffort is Enabled");
            }
            else
            {
                // return false, meaning not supported because:
                //  + connected hardware doesn't support
                //  + conflict with another option already set
                Console.WriteLine("Connected hardware doesn't support, or a conflict with another option already set.");
            }
            if (connector.getMentalEffortEnable())
            {     // return true, means it is enabled
                Console.WriteLine("HelloEEG: MentalEffort is configured");
            }
            else
            {     // return false, meaning not currently configured
                Console.WriteLine("HelloEEG: MentalEffort is NOT configured");

            }
            if (connector.setMentalEffortRunContinuous(true))
            {     // return true, means success
                Console.WriteLine("HelloEEG: MentalEffort Continuous operation");
            }
            else
            {     // return false, meaning not supported because:     //  + connected hardware doesn't support     //  + conflict with another option already set     //  + not support by this version of the SDK
                Console.WriteLine("HelloEEG: MentalEffort normal operation ");
            }
            if (connector.getMentalEffortRunContinuous())
            {     // return true, means it is enabled
                Console.WriteLine("HelloEEG: MentalEffort Continuous operation");
            }
            else
            {
                // return false, meaning not currently configured
                Console.WriteLine("HelloEEG: MentalEffort normal operation");
            }
        }