如何在以Windows Form作为界面窗口的CLR项目中使用SAPI的SetNotifyCallbackFunction()?

发布于 2024-08-28 10:12:04 字数 353 浏览 2 评论 0原文

我正在尝试为 Winamp 编写一个 dll 插件。我正在使用 Microsoft Visual Studio 2008 和 Microsoft SAPI 5.1。我使用 Windows Form (System::Windows::Forms::Form) 创建了界面窗口。

我尝试使用 SetNotifyWIndowMessage(),但当我对着麦克风说话时,该方法从未被调用。所以我尝试使用 SetNotifyCallbackFunction(),但出现编译错误,提示我应该使用 '&'在参数中的方法名称前面。但是,当我添加“&”时,我收到另一个编译错误,指出除非创建委托实例,否则我无法获取该方法的地址。

我应该怎么办?有人请帮助我..

I'm trying to write a dll plugin for Winamp. I'm using Microsoft Visual Studio 2008 and Microsoft SAPI 5.1. I created the interface window using Windows Form (System::Windows::Forms::Form).

I tried to use SetNotifyWIndowMessage(), but the method is never called when I speak to the microphone. So I tried using SetNotifyCallbackFunction(), but I got a compile error saying that I should use '&' in front of the method name in the parameter. However, when I add the '&', I got another compile error saying that i can't take the address of the method unless creating delegate instance.

What should I do? Someone please help me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野生奥特曼 2024-09-04 10:12:04

好吧,如上所述,您需要创建一个委托实例来包装您的回调。但不要去那里,SAPI 5.1 已经相当过时了。不再提供更新,因为 .NET 框架有一个非常好的包装器。查看 System.Speech.Recognition 命名空间和 SpeechRecognitionEngine 类。您将需要使用 SpeechRegonized 事件。您可以在 MSDN 库中找到大量代码示例该类的页面

Well, as indicated, you need to create a delegate instance to wrap your callback. But don't go there, SAPI 5.1 is quite outdated. Updates are no longer shipped because the .NET framework has a very nice wrapper for it. Check out the System.Speech.Recognition namespace and the SpeechRecognitionEngine class. You'll want to use the SpeechRegonized event. You'll find plenty of code samples in the MSDN Library pages for the class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文