我正在使用这里给出的C ++代码。 但这里使用的共享语音识别运行自己的命令,如移动,最小化,删除。 我需要创build这个没有调用MS语音识别程序。
hr = cpEngine.CoCreateInstance(CLSID_SpSharedRecognizer);
上面这一行创build了共享实例。
我试图使用CLSID_SpInprocRecognizer,而不是正确的。 我是新来的。 有没有办法做到这一点?
我在这里遇到了同样的问题,花了很多时间试图找到答案。 幸运的是,我已经通过以下步骤获得了解决方案:
hr = cpRecognizer.CoCreateInstance(CLSID_SpInprocRecognizer);
2.进程识别器没有设置默认的输入源或识别引擎,您需要设置它们让进程中的识别器进行侦听。
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.指定要使用的特定语音识别引擎。 如果没有指定,它将使用默认的。 如果没有调用,它仍然使用默认的(我建议这条线,仍然工作正常)。
hr = cpRecognizer->SetRecognizer(NULL);
而已! 它打开了一个默认的美国英语识别引擎,并且很快地拿起了我的命令。
参考:
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