没有重载匹配委托 system.speech.recognition.speechRecognizedEventargs

no overload matches delegate system.speech.recognition.speechRecognizedEventargs

我正在研究 sapi。我做了一个简单的控制台应用程序并尝试测试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.

        }
    }

我在调用函数 abc 时遇到错误。错误是:

"no overload matches delegate system.speech.recognition.speechRecognizedEventargs"

我做错了什么?

您的处理程序签名有误。应该是:

public void abc(object sender, SpeechRecognizedEventArgs e)