/// <summary> /// Initializes the VC engine /// </summary> public void InitializeVoiceCommands() { if (Settings.SpeechEnabled && Settings.UseVoiceCommands) { vl = new VoiceListener(); foreach (string s in Settings.VoiceCommandsList) { vl.AddCommand(s); } if (Settings.VCPreset1 != "") { vl.AddCommand(Settings.VCPreset1); } if (Settings.VCPreset2 != "") { vl.AddCommand(Settings.VCPreset2); } if (Settings.VCPreset3 != "") { vl.AddCommand(Settings.VCPreset3); } vl.CommandReceived += new VoiceListener.CommandReceivedEventHandler(commandReceived); try { vl.Start(); } catch (Exception e) { Settings.SaveSetting("UseVoiceCommands", false); MessageBox.Show("Voice commands have been turned off:\n\n" + e.ToString()); vl.Stop(); vl = null; } } else { if (vl != null) { vl.Stop(); } vl = null; } }
/// <summary> /// Starts / stops the test /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTest_Click(object sender, EventArgs e) { if (btnTest.Text == "Start Test") { // Start the text btnTest.Text = "Cancel"; this.Height = 469; // Create the voicelistener vl = new VoiceListener(); // Add the test commands foreach (string s in Settings.VoiceCommandsList) { vl.AddCommand(s); } vl.CommandReceived += new VoiceListener.CommandReceivedEventHandler(commandRecognized); // Reset the counters correctCount = 0; wrongCount = 0; commandCount = 0; // Set the first test lblVC.Text = vl.Commands[rnd.Next(0, vl.Commands.Count)].ToString(); currentCommand = lblVC.Text; // Set status lblStatus.Text = "Waiting for voice command..."; lblStatus.ForeColor = Color.Green; // Start the listener vl.Start(); } else { // Stop the text this.Height = 219; btnTest.Text = "Start Test"; // Stop the voicelistener vl.Stop(); vl = null; } }
/// <summary> /// Starts / stops the test /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTest_Click(object sender, EventArgs e) { if (btnTest.Text == "Start Test") { // Start the text btnTest.Text = "Cancel"; this.Height = 469; // Create the voicelistener vl = new VoiceListener(); // Add the test commands foreach(string s in Settings.VoiceCommandsList) vl.AddCommand(s); vl.CommandReceived += new VoiceListener.CommandReceivedEventHandler(commandRecognized); // Reset the counters correctCount = 0; wrongCount = 0; commandCount = 0; // Set the first test lblVC.Text = vl.Commands[rnd.Next(0, vl.Commands.Count)].ToString(); currentCommand = lblVC.Text; // Set status lblStatus.Text = "Waiting for voice command..."; lblStatus.ForeColor = Color.Green; // Start the listener vl.Start(); } else { // Stop the text this.Height = 219; btnTest.Text = "Start Test"; // Stop the voicelistener vl.Stop(); vl = null; } }
/// <summary> /// Initializes the VC engine /// </summary> public void InitializeVoiceCommands() { if (Settings.SpeechEnabled && Settings.UseVoiceCommands) { vl = new VoiceListener(); foreach (string s in Settings.VoiceCommandsList) vl.AddCommand(s); if (Settings.VCPreset1 != "") vl.AddCommand(Settings.VCPreset1); if (Settings.VCPreset2 != "") vl.AddCommand(Settings.VCPreset2); if (Settings.VCPreset3 != "") vl.AddCommand(Settings.VCPreset3); vl.CommandReceived += new VoiceListener.CommandReceivedEventHandler(commandReceived); try { vl.Start(); } catch (Exception e) { Settings.SaveSetting("UseVoiceCommands", false); MessageBox.Show("Voice commands have been turned off:\n\n" + e.ToString()); vl.Stop(); vl = null; } } else { if(vl != null) vl.Stop(); vl = null; } }