简体   繁体   中英

Error when testing Windows Speech Recognition API (SAPI)

I am trying to test the following example: Test of Speech Recognition using Windows SAPI

The code compiles well But It crashes in execution.

The returned pointer to ISpRecognizer Object takes the values NULL as shown in the following code :

// This function exits when the word passed as parameter is said by the user
int start_listening(const std::string& word)
{
.....

HRESULT hr;

ISpRecognizer* recognizer;
hr = CoCreateInstance(CLSID_SpSharedRecognizer,
    nullptr, CLSCTX_ALL, IID_ISpRecognizer,
    reinterpret_cast<void**>(&recognizer)); <<<<<ERROR: recognizer =NULL


<<< hr = REGDB_E_CLASSNOTREG<< MEAN "class not registered"

check_result(hr); 

ISpRecoContext* recoContext;
hr = recognizer->CreateRecoContext(&recoContext);<<<<CRASH: TRY TO ACCESS TO 
                                                 <<<<  A NULL  POINTER
...
...
...

I am using visual studio 2015 on windows 8.1 and targeting x64 platform.

Do you know why the pointer to ISPRecognizer is NULL and why I am getting HRESULT=REGDB_E_CLASSNOTREG ?

I'm thinking that you're not calling ::CoInitialize() beforehand, and not properly initializing your ISpReognizer. I've got a fully working example as an answer to another question over here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM