private void worker_DoWork(object sender, DoWorkEventArgs e) { //Logic for simple recognition activity // Set a 3 second timeout for the recognition (optional) _tempVr.SetTimeout(3); //instruct the module to listen for a built in word from the 1st wordset _tempVr.RecognizeWord(1); Dispatcher.BeginInvoke((Action)delegate { ResponseTb.AppendText("Speak" + Environment.NewLine); ResponseTb.ScrollToEnd(); }); //need to wait until HasFinished has completed before collecting results while (!_tempVr.HasFinished()) { Dispatcher.BeginInvoke((Action)delegate { ResponseTb.AppendText("."); }); } // Once HasFinished has returned true, we can ask the module for the index of the word it recognised. If you're new to using the EasyVR module, // download the Easy VR Commander (http://www.veear.eu/downloads/) to interrogate the config of your module and see what the indexes correspond to // Here is a standard setup at time of writing for an EASYVR 3 module: // 0=Action,1=Move,2=Turn,3=Run,4=Look,5=Attack,6=Stop,7=Hello // NOTE: Depending on what you are looking to recognise, you may need a different method to GetWord() - GetToken and GetCommand are also available var indexOfRecognisedWord = _tempVr.GetWord(); Dispatcher.BeginInvoke((Action)delegate { ResponseTb.AppendText("Response: "+indexOfRecognisedWord + Environment.NewLine); ResponseTb.AppendText("Recognition finished" + Environment.NewLine); ResponseTb.ScrollToEnd(); }); }
private void ResponseTb_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { //note: this is code behind which is generally frowned upon in MVVM but it is a View operation only - // "Code behind on view is only bad when the operations needs dependencies past the View." ResponseTb.ScrollToEnd(); }
private void GetModuleIdButton_Click(object sender, RoutedEventArgs e) { var temp = _tempVr.GetId(); ResponseTb.AppendText($"The return was: {temp}" + Environment.NewLine); ResponseTb.ScrollToEnd(); }
private void SendPhoneToneButton_Click(object sender, RoutedEventArgs e) { var temp1 = _tempVr.PlayPhoneTone(3, 30); ResponseTb.AppendText($"The return was: {temp1}" + Environment.NewLine); ResponseTb.ScrollToEnd(); }