I am working on sapi. I made a simple console application and tried to test sapi.
class Program
{
public void abc(SpeechRecognizedEventArgs e)
{
switch (e.Result.Text)
{
case "say hello":
Console.WriteLine("Hi");
break;
case "my name is irfan":
Console.WriteLine("hello irfan!");
break;
}
}
public static void Main(string[] args)
{
SpeechRecognitionEngine sREngine = new SpeechRecognitionEngine();
Choices com = new Choices();
com.Add(new string[] { "say hello", "my name is irfan" });
GrammarBuilder gb = new GrammarBuilder();
gb.Append(com);
Grammar gram = new Grammar(gb);
sREngine.LoadGrammarAsync(gram);
sREngine.SetInputToDefaultAudioDevice();
sREngine.RecognizeAsync(RecognizeMode.Multiple);
sREngine.SpeechRecognized += abc; //getting error over there.
}
}
I am getting error on calling function abc
. The error is :
"no overload matches delegate system.speech.recognition.speechRecognizedEventargs"
what I am doing wrong?
Your handler signature is wrong. It should be:
public void abc(object sender, SpeechRecognizedEventArgs e)