473,395 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

I have two events i need to make that when one event raise the other one wont:

Ok here are the codes of the two events.
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
  1. void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
  2.         {   
  3.             Successfully = "Successfully Recognized The Command: " + e.Result.Text;
  4.           //  System.Windows.Forms.MessageBox.Show(e.Result.Text + "\r\nConfidence: " + e.Result.Confidence);
  5.           //  if (e.Result.Confidence >= RequiredConfidence)
  6.             //    RaiseSpeechEvent(e.Result.Text);
  7.  
  8.             if (e.Result.Text=="b f b c 2")
  9.             {
  10.                 realtime_write_to_Log_successfully(Successfully);
  11.                 Logger.Write(Successfully);
  12.                 label1.Visible = true;
  13.                 label1.Text = "Running Battlefield Bad Company 2";
  14.                 this.WindowState = FormWindowState.Minimized;
  15.                 notepadProcess = Process.Start(x86folder+"\\Electronic Arts\\Battlefield Bad Company 2\\BFBC2Updater.exe");
  16.                 this.Close();
  17.             }
  18.             if (e.Result.Text == "exit")
  19.             {
  20.                 realtime_write_to_Log_successfully(Successfully);
  21.                 Logger.Write(Successfully);
  22.             }
  23.             if (e.Result.Text == "start i e")
  24.             {
  25.                 realtime_write_to_Log_successfully(Successfully);
  26.                 Logger.Write(Successfully);
  27.                 System.Diagnostics.Process.Start("iexplore.exe","www.ynet.co.il");
  28.                 this.Close();
  29.             }
  30.             string myCommand = string.Empty;
  31.             if (e.Result.Text == "l c")
  32.             {
  33.                 realtime_write_to_Log_successfully(Successfully);
  34.                 Logger.Write(Successfully);
  35.                 foreach (string s in commands)
  36.                 {
  37.                     myCommand += s + " ";
  38.                 }
  39.                 MessageBox.Show(myCommand);
  40.             }
  41.  
  42.  
  43.               //  this.Close();
  44.  
  45.  
  46.             Logger.Write(String.Format("Word: {0}, Percentage of matching: {1}", e.Result.Text, e.Result.Confidence * 100));
  47.             Logger.Write(String.Format("Word: {0}, Percentage of not matching: {1}", e.Result.Text, 100 - (e.Result.Confidence * 100)));
  48.             realtime_write_to_Log_successfully(String.Format("Word: {0}, Percentage of matching: {1}", e.Result.Text, e.Result.Confidence * 100));
  49.             realtime_write_to_Log_successfully(String.Format("Word: {0}, Percentage of not matching: {1}", e.Result.Text, 100 - (e.Result.Confidence * 100)));
  50.             if (e.Result.Confidence >= RequiredConfidence)
  51.                 RaiseSpeechEvent(e.Result.Text);
  52.         }
  53.  
And the second event wich i need him to stop from being raise when the first event is raised:

Expand|Select|Wrap|Line Numbers
  1.  void speechRecogniser_SpeechDetected(object sender, SpeechDetectedEventArgs e)  
  2.  
  3.          {
  4.  
  5.              listView1.Clear();
  6.  
  7.              realtime_write_to_Log("Number of times detected word without recognized: "+how_many_times_word_detected++.ToString());
  8.  
  9.          }
  10.  
And this is the function when i listen and when one of the events happen it will raise it:

Expand|Select|Wrap|Line Numbers
  1. public void StartListening()
  2.         {
  3.  
  4.                 commands = new string[] { "exit", "b f b c 2", "start i e", "l c" };
  5.  
  6.                 for (int i = 0; i < commands.Length; i++)
  7.                     c.Add(commands[i]);
  8.                 gb = new GrammarBuilder(c);
  9.                 git = new Grammar(gb);
  10.                 rec = new SpeechRecognitionEngine();
  11.                 rec.SpeechRecognized += rec_SpeechRecognized;
  12.                 rec.LoadGrammar(git);
  13.                 rec.SetInputToDefaultAudioDevice();
  14.                 rec.RecognizeAsync(RecognizeMode.Multiple);
  15.                 rec.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(speechRecogniser_SpeechDetected);
  16.         }
  17.  
So you can see in the middle code here wich is the second event im doing:
Expand|Select|Wrap|Line Numbers
  1. realtime_write_to_Log("Number of times detected word without recognized: "+how_many_times_word_detected++.ToString());
  2.  
And i need that this int or this event will stop from being raise or activate when the firs event is raised.
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.
Sep 10 '10 #1
0 994

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Tom | last post by:
Hi, In the following code I have reproduced a problem in IE that is extremely annoying for my application. <html> <head> <script type="text/javascript">
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
1
by: Jonah Olsson | last post by:
Hello, I'm trying to build an "add-on" to an already existing custom web user control. The old control collects some user data and saves it to a database. The new control should collect some...
5
by: norton | last post by:
Hi All, I am writing a simple win form which contains a button, when user click the button i want to validate all the other textbox and see if there is anything goes wrong may i know how...
4
by: Saladin | last post by:
Hi VB.Net Desktop What's a good way to run an event on a different form? I've got a form 'on top' and when I click a button I's like the underlying form to reload. Thanks Graeme
1
by: Jeremy.Deats | last post by:
I have been programming in C# for the past few years and I'm now trying to implement something in VB.NET (Framework 1.1) that I'm having a problem with... In C# I can create a new class and make...
4
by: Ty Salistean | last post by:
So, here is a wierd question that we have been discussing for a bit now. Does an event fire even though nothing is subscribed to listen to the event? For instance, does the Click event of a...
12
by: Steve | last post by:
Hi All, I'm a newbee in C# and have a Windows form application. The main form has a progress bar. In one of the methods of the main form, I call a class derived from Object which processes a...
4
by: Vertilka | last post by:
I will simplify the question by introducing an example... What I need is that: I have a control on top of other controls in a form. when i click on it i want to pass the click event to the...
6
by: kirk | last post by:
I have three events, using event handler methods as depicted below. Two of those event handler methods need to reset specific data whenever the other event left fires. I wasn't sure how to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.