views:

119

answers:

1

Hi,

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..

A: 

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.

Hans Passant
It seems that I can't create a delegate instance due to the Windows Form class, I don't know how to do that. Is using the .net framework easy? cause i need to submit this project next friday. do you think i still have time to change? however, i will not have time to come back if it fails.
manuel
The odds to get this done on Friday with System.Speech are much better. You didn't really get started if you didn't get notifications going yet.
Hans Passant
oh okay, i will try it right away, thanks a lot!!
manuel
Hi, I've modified the code to suit my environment, but I'm still having errors I can't solve.1. sre->SpeechRecognized += gcnew EventHandler (generates compile error C3352: 'void gen_myplugin::Dialog::sre_SpeechRecognized(System::Object ^,System::Speech::Recognition::SpeechRecognizedEventArgs ^)' : the specified function does not match the delegate type 'void (System::Object ^,System::EventArgs ^)'2. each cases inside switch (e->Result->Text) generates compile error C2051: case expression not constantHow do I solve them?
manuel
Hans Passant
Please answer my question: http://stackoverflow.com/questions/2623826/net-speech-recognition-plugin-runtime-error-unhandled-exception-what-could-pos
manuel
Please accept my answer first.
Hans Passant