コード例 #1
0
ファイル: VoiceControlHelper.cs プロジェクト: andykmc/vision
 public static void Initialize()
 {
     viewControlHelper   = ViewControlHelper.Instance;
     detectedVoiceParams = new MyVoiceParams();
     keywordDetected     = false;
     voiceControlEnabled = false;
     toSearch            = false;
     commandSentence     = "";
     parentWindow        = App.Current.MainWindow;
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: andykmc/vision
        public void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            bgwk2Running = true;
            VoicePipeline pipeline = new VoicePipeline();

            pipeline.SetVoiceCommands();
            pipeline.EnableVoiceRecognition(0);
            if (!pipeline.Init())
            {
                return;
            }
            //MessageBox.Show("Voice pipline initialized");
            while (true)
            {
                //check if need to terminate the pipline when window is closing
                if (backgroundWorker2.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }

                if (pipeline.AcquireFrame(true))
                {
                    if (pipeline.IsAudioFrame())
                    {
                        MyVoiceParams detectedVoiceParams = pipeline.getDetectedPhrase();
                        if (detectedVoiceParams.detectedPhrase != "")
                        {
                            backgroundWorker2.ReportProgress(1, detectedVoiceParams);
                        }
                    }
                    else
                    {
                        pipeline.ReleaseFrame();
                        continue;
                    }
                }
                else
                {
                    MessageBox.Show("Failed to initialize VoicePipeline");
                    break;
                }

                pipeline.ReleaseFrame();
            }
            pipeline.PauseVoiceRecognition(true);
            //pipeline.ReleaseFrame();
            pipeline.Close();
            pipeline.Dispose();
            bgwk2Running = false;
        }
コード例 #3
0
ファイル: VoicePipeline.cs プロジェクト: andykmc/vision
 public MyVoiceParams getDetectedPhrase()
 {
     if (commandDetected())
     {
         MyVoiceParams myVoiceParams = new MyVoiceParams();
         myVoiceParams.detectedPhrase  = detectedPhrase;
         myVoiceParams.alertLabel      = alertLabel;
         myVoiceParams.confidenceLevel = confidenceLevel;
         alertLabel = "";
         return(myVoiceParams);
     }
     else
     {
         MyVoiceParams myVoiceParams = new MyVoiceParams();
         myVoiceParams.detectedPhrase  = "";
         myVoiceParams.alertLabel      = alertLabel;
         myVoiceParams.confidenceLevel = 0;
         alertLabel = "";
         return(myVoiceParams);
     }
 }