warning to recreate SpeechRecognitionEngine (how does this apply to C++) RRS feed

  • Question

  • At and I think a few other places, I have read warnings that I should destroy and recreate SpeechRecognitionEngine every 2 minutes. My lack of clarity is that this is a C# class. And...every two minutes?

    How does this apply to the C++ APIs? Does the problem/memory leak/memory usage issue occur with C++ so rapidly?

    Do you mean a SpeechRecognizer like created via
    HRESULT hr = CoCreateInstance(CLSID_SpInprocRecognizer, NULL, CLSCTX_INPROC_SERVER, __uuidof(ISpRecognizer), (void**)&(x->pSpeechRecognizer));


    Tuesday, June 18, 2013 9:49 PM

All replies

  • Based on the adaptation flag, in the scenario's listed, you want to reset this either on a clock cycle or create it when someone is detected. The SpeechRecognizer is part of the Speech technology for Windows which would be supported from a different team. Kinect for Windows leverages the technology and provides tuned libraries to work with the Kinect for Windows device's mic array.

    COM/C++ - Microsoft Speech API (SAPI) 5.4

    .Net - System.Speech Namespaces

    As a best practice it is recommended that you recycle the objects frequently depending on your scenarios. You will require testing to conver the scenarios you are supporting to know how this might affect your application.

    As for how you destroy SpeechRecognitionEngine, the .Net object you will call .Dispose() and for COM/C++ call Release().

    Tuesday, June 18, 2013 11:48 PM
  • Thank you for your reply, I understand of what you write, yet am ambiguity remains for me. Perhaps, there is something you implied that I didn't understand. A followup inquiry please.

    Yes, in all cases testing, testing, testing. For now, lets set that aside and focus on the knowledge your team has that then caused you to issue this warning to developers.

    Is the warning to recycle the objects tightly associated with the value of SetPropertyNum(L"AdaptationOn", 0) that is set/or not when the CLSID_SpInprocRecognizer is created (example in my 1st post)? And that if I turn OFF the adaptation then this warning does not apply?

    When you write "...that you recycle the objects..." in your 2nd paragraph, what specific objects of which are you writing? There are many object created. Which are you recommending be recycled? In my codebase, I have followed somewhat closely the code from your BasicSpeech SDK example. I have INuiAudioBeams, IMediaObject, IStream, property bags, KinectAudioStream's, CLSID_SpInprocRecognizer, RecognitionContext's, etc.

    So...are you saying that I tear down and destroy everything associated with the speech recognition featureset all the way down to the INuiSensor to limit this growing memory usage? Or...and let me make a only the CLSID_SpInprocRecognizer (having the default adaptation enabled) and objects depending on it the ones that I need to recycle?


    Wednesday, June 19, 2013 9:46 AM