Pregunta

I'm using the C++ code given here. But the shared speech recognition used here runs its own commands such as move,minimize,delete. I need to create this without invoking the MS speech recognition program.

hr = cpEngine.CoCreateInstance(CLSID_SpSharedRecognizer);

this line above creates the shared instance.

I tried to use CLSID_SpInprocRecognizer instead but can not get it right. I'm new to this. Is there a way to do this?

¿Fue útil?

Solución

I met the same issue here, and spent lot of time trying to find an answer. Luckily, I've got the solution by following the steps:

  1. Do use the in-process recognizer, if you want to get rid of the MS speech recognition program

hr = cpRecognizer.CoCreateInstance(CLSID_SpInprocRecognizer);

2.In-process recognizer doesn't have default input sources or recognition engines set up, and you need to set them to get the in-process recognizer to listen.

CComPtr<ISpObjectToken>      cpObjectToken;
CComPtr<ISpAudio>            cpAudio;

 // Get the default audio input token.
hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpObjectToken);

// Set the audio input to our token.
hr = cpRecognizer->SetInput(cpObjectToken, TRUE);
// Set up the inproc recognizer audio input with an audio input object.

// Create the default audio input object.
hr = SpCreateDefaultObjectFromCategoryId(SPCAT_AUDIOIN, &cpAudio);

// Set the audio input to our object.
hr = cpRecognizer->SetInput(cpAudio, TRUE);

3.specifies the particular speech recognition engine to be used. If not specified, it will use the default one. If it's not called, it still use the default one(I commend out this line, still works fine).

hr = cpRecognizer->SetRecognizer(NULL);

That's it! It opens a default U.S. English recognition engine, and picks up my command pretty quick.

reference:

http://stackoverflow.com/questions/18448394/inproc-speech-recognition-engine-in-python
http://msdn.microsoft.com/en-us/library/ms718864%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms718866%28v=vs.85%29.aspx
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top