I’ve seen a couple of questions come by the listen alias about using an in-process speech recognizer. When you use an in-process recognizer, you have to specify a lot more than you need to specify with the shared recognizer.
In particular, you need to specify an audio source and a recognition engine. The shared recognizer uses the defaults for both of these.
Most people figure out that they need to specify an audio source; more commonly (and I’ve tripped over this myself) they forget to specify a recognition engine.
And while there’s a nifty helper for the audio input in sphelper.h (namely, SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpToken)), there isn’t a helper for the recognition engine.
So, here’s a helper function that returns the object token for the default shared recognizer: