【问题标题】:no overload matches delegate system.speech.recognition.speechRecognizedEventargs没有重载匹配委托 system.speech.recognition.speechRecognizedEventargs
【发布时间】:2015-10-22 04:15:00
【问题描述】:

我正在研究 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 时遇到错误。错误是:

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

我做错了什么?

【问题讨论】:

  • 顺便说一句,您可以在SpeechTurtle.codeplex.com 找到有用的代码
  • 旁注:如果您使用 Visual Studio,当您在 += 之后单击选项卡时,它会自动为您生成委托。 (此评论是垃圾邮件/广告,因为我为生产 VS 的公司工作,使用该功能时请使用您的最佳判断 :))。

标签: c# sapi


【解决方案1】:

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

public void abc(object sender, SpeechRecognizedEventArgs e)

【讨论】:

  • 好的,成功了!我得到了例外。 Additional information: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
  • 这是一个不同的问题。请不要把问题串在一起;创建另一个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-26
  • 2011-04-04
  • 2011-06-05
相关资源
最近更新 更多