Search code examples
c++kinectspeech-recognitionsapi

Kinect + SpCreateDefaultObjectFromCategoryId = SPERR_NOT_FOUND


I've created a solution which uses the microsoft SAPI to recognize speech defined in a grammar file.

On its own, this code works fine. However, when I integrate it with the same program which is running the Kinect SDK, it fails on the line:

hr = cpRecognizer->SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN,&pAudioToken);
//At this point, HR == -2147200966 == SPERR_NOT_FOUND

I have tried plugging in a microphone which is external to the kinect into an available microphone port and setting it to be the default microphone. This did not bring me any joy, either.

I then use the pAudioToken to call cpRecognizer->SetInput(pAudioToken,TRUE);


Solution

  • One thing you need to take into account is the difference between the desktop SAPI recognizers and the server SAPI recognizers. Unfortunately, it's very tricky to determine (from visual inspection) which one you're including - they're both named sapi.h, but the category IDs are different.

    One easy difference is that SAPI_VER is 0x055 for the server version, but 0x054 or less for desktop.

    However, the key difference here is that SPCAT_AUDIOIN (the audio input category) is named differently in the server SAPI header and the desktop SAPI header, and it's entirely possible that there is no default token for the audio input category for the server recognizer.

    Plugging a microphone in would not change the server recognizer's idea of what the default input would be, although it would change the desktop recognizer's default input.

    I would recommend iterating through the audio input category using the SpEnumTokens helper to see which input devices are available.