In the second event im using int veriable to count each time the event is raised. The problem is that when the first event is raised also the second one raised too.
The first event recognize specific words/text im using in my code. The second event recognize any audio any word i say to the microphone and therefore when the first event raise also the second one is raise too.
I need somehow to make that the when the first event raised the second event will not raise cuz i want to count words that are not in the list i did. So i need he second event to be raised only when i say words that are not in the list i created in my code i mean words that arent recognized by the program.
First event:
Expand|Select|Wrap|Line Numbers
- void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
- {
- Successfully = "Successfully Recognized The Command: " + e.Result.Text;
- // System.Windows.Forms.MessageBox.Show(e.Result.Text + "\r\nConfidence: " + e.Result.Confidence);
- // if (e.Result.Confidence >= RequiredConfidence)
- // RaiseSpeechEvent(e.Result.Text);
- if (e.Result.Text=="b f b c 2")
- {
- realtime_write_to_Log_successfully(Successfully);
- Logger.Write(Successfully);
- label1.Visible = true;
- label1.Text = "Running Battlefield Bad Company 2";
- this.WindowState = FormWindowState.Minimized;
- notepadProcess = Process.Start(x86folder+"\\Electronic Arts\\Battlefield Bad Company 2\\BFBC2Updater.exe");
- this.Close();
- }
- if (e.Result.Text == "exit")
- {
- realtime_write_to_Log_successfully(Successfully);
- Logger.Write(Successfully);
- }
- if (e.Result.Text == "start i e")
- {
- realtime_write_to_Log_successfully(Successfully);
- Logger.Write(Successfully);
- System.Diagnostics.Process.Start("iexplore.exe","www.ynet.co.il");
- this.Close();
- }
- string myCommand = string.Empty;
- if (e.Result.Text == "l c")
- {
- realtime_write_to_Log_successfully(Successfully);
- Logger.Write(Successfully);
- foreach (string s in commands)
- {
- myCommand += s + " ";
- }
- MessageBox.Show(myCommand);
- }
- // this.Close();
- Logger.Write(String.Format("Word: {0}, Percentage of matching: {1}", e.Result.Text, e.Result.Confidence * 100));
- Logger.Write(String.Format("Word: {0}, Percentage of not matching: {1}", e.Result.Text, 100 - (e.Result.Confidence * 100)));
- realtime_write_to_Log_successfully(String.Format("Word: {0}, Percentage of matching: {1}", e.Result.Text, e.Result.Confidence * 100));
- realtime_write_to_Log_successfully(String.Format("Word: {0}, Percentage of not matching: {1}", e.Result.Text, 100 - (e.Result.Confidence * 100)));
- if (e.Result.Confidence >= RequiredConfidence)
- RaiseSpeechEvent(e.Result.Text);
- }
Expand|Select|Wrap|Line Numbers
- void speechRecogniser_SpeechDetected(object sender, SpeechDetectedEventArgs e)
- {
- listView1.Clear();
- realtime_write_to_Log("Number of times detected word without recognized: "+how_many_times_word_detected++.ToString());
- }
Expand|Select|Wrap|Line Numbers
- public void StartListening()
- {
- commands = new string[] { "exit", "b f b c 2", "start i e", "l c" };
- for (int i = 0; i < commands.Length; i++)
- c.Add(commands[i]);
- gb = new GrammarBuilder(c);
- git = new Grammar(gb);
- rec = new SpeechRecognitionEngine();
- rec.SpeechRecognized += rec_SpeechRecognized;
- rec.LoadGrammar(git);
- rec.SetInputToDefaultAudioDevice();
- rec.RecognizeAsync(RecognizeMode.Multiple);
- rec.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(speechRecogniser_SpeechDetected);
- }
Expand|Select|Wrap|Line Numbers
- realtime_write_to_Log("Number of times detected word without recognized: "+how_many_times_word_detected++.ToString());
Cuz the first event are words he successfully recognized so when the first event raise the second one should not raise. And when the second one raise the first one isnt raise and thats not a problem since he didnt recognized.
The problem is how to make the second event from raise up when the first event recognize the words.
Thanks for helping.