I have a difficult time to combine this code with checkbox.
I want the code run when the checkbox is enabled(true) and stop when the checkbox is disabled(false) but for some reason i cant and i want some help.
If anyone has a solution or sth different to propose i will be grateful.
The code is: private void Form1_Load(object sender, EventArgs e)
Choices cities = new Choices(new string[] { "google" });
Grammar gr = new Grammar(new GrammarBuilder(cities));
SpeechRecognitionEngine recognize = new SpeechRecognitionEngine();
SpeechSynthesizer Synth = new SpeechSynthesizer();
recognize.SetInputToDefaultAudioDevice();
DictationGrammar Voc = new DictationGrammar();
recognize.LoadGrammar(Voc);
recognize.RecognizeAsync(RecognizeMode.Multiple);
recognize.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognize_SpeechRecognized);
}
**private void recognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)**
{
if (e.Result.Text == "google")
System.Diagnostics.Process.Start("http://www.google.com");
}
**(and possibly sth that touches the solution?)**
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
recognize.RecognizeAsync(RecognizeMode.Multiple);
else if (checkBox1.Checked == false) // turn off
recognize.RecognizeAsyncCancel();
}
THANKS