Speech SDK
-
Hello All, I'm using the Speech SDK inside a COM module thus:
HRESULT hr; ISpVoice * pVoice = NULL; ...... hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); if(! SUCCEEDED(hr)) MessageBox (NULL, "Cant load Voice",NULL,NULL); else hr = pVoice->Speak(L"Hello World", SPF_DEFAULT, NULL); ...... pVoice->Release(); pVoice = NULL;
It compiles and - amazingly enough - works ok. Now, if I change the 2nd parameter in Speak() to SPF_ASYNC or SPF_ASYNC | SPF_PURGEBEFORESPEAK, to call it asynchronously, thre is no sound at all. :confused: Thanks alex 'Architecture is music frozen in space.' -
Hello All, I'm using the Speech SDK inside a COM module thus:
HRESULT hr; ISpVoice * pVoice = NULL; ...... hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); if(! SUCCEEDED(hr)) MessageBox (NULL, "Cant load Voice",NULL,NULL); else hr = pVoice->Speak(L"Hello World", SPF_DEFAULT, NULL); ...... pVoice->Release(); pVoice = NULL;
It compiles and - amazingly enough - works ok. Now, if I change the 2nd parameter in Speak() to SPF_ASYNC or SPF_ASYNC | SPF_PURGEBEFORESPEAK, to call it asynchronously, thre is no sound at all. :confused: Thanks alex 'Architecture is music frozen in space.'Maybe because you dn't appear to specifically wait for the speech to start or finish, if you go asynchronous you are calling pVoice->Release(); too soon and it never has a chance to get started.
-
Maybe because you dn't appear to specifically wait for the speech to start or finish, if you go asynchronous you are calling pVoice->Release(); too soon and it never has a chance to get started.
That's it, thanks. OTH, I'm trying to 'launch and forget' the TTS, but I have to call Release()before returning from the func, otherwise the speech object will never get destroyed. All this occurs inside a shell interface, called by Explorer. Can the speech object be global? (created at _Module.Init() and destroyed at _Module.Term()? I did try it but it caused a GPF. Ideas anyone? Thanks. alex 'Architecture is music frozen in space.'
-
That's it, thanks. OTH, I'm trying to 'launch and forget' the TTS, but I have to call Release()before returning from the func, otherwise the speech object will never get destroyed. All this occurs inside a shell interface, called by Explorer. Can the speech object be global? (created at _Module.Init() and destroyed at _Module.Term()? I did try it but it caused a GPF. Ideas anyone? Thanks. alex 'Architecture is music frozen in space.'
How about you launch a separate EXE and pass it information on what speech to say? Then when the EXE is done, it can exit, or else stay resident and you communicate with it next time. That would allow your shell interface to 'exit' fairly quickly, and the speech will still be playing in the background.
-
How about you launch a separate EXE and pass it information on what speech to say? Then when the EXE is done, it can exit, or else stay resident and you communicate with it next time. That would allow your shell interface to 'exit' fairly quickly, and the speech will still be playing in the background.
Well, it is meant as a shell add-in, so i wouldn't want to complicate things. Otherwise, i'm not fluent enough in ATL COM but it looks to me like launching a new thread might do the trick ? The COM module could launch it, and the next time around (when it's called again by Explorer), it could check if the thread is still alive and either kill (Release) it before launching a new one (with a different message) or just wait for it to finish speaking and then.. How do we identify the 'speak' thread from one call to another? Does it make any sense? alex 'Architecture is music frozen in space.'
-
Well, it is meant as a shell add-in, so i wouldn't want to complicate things. Otherwise, i'm not fluent enough in ATL COM but it looks to me like launching a new thread might do the trick ? The COM module could launch it, and the next time around (when it's called again by Explorer), it could check if the thread is still alive and either kill (Release) it before launching a new one (with a different message) or just wait for it to finish speaking and then.. How do we identify the 'speak' thread from one call to another? Does it make any sense? alex 'Architecture is music frozen in space.'
The problem with this is that you might have created the instance of the speech object on one thread and tried to delete it on another. COM is not happy about that. What you might need to do is try to create a new thread when your COM object's DLL is loaded and retain that thread for the lifetime of the DLL load. Then you can send information to that thread from the various COM objects instantiated to speak. Maybe that is worth a try. However, based on what your criteria were - asynchronous speech - I am already thinking a separate EXE is the better way to go.
-
The problem with this is that you might have created the instance of the speech object on one thread and tried to delete it on another. COM is not happy about that. What you might need to do is try to create a new thread when your COM object's DLL is loaded and retain that thread for the lifetime of the DLL load. Then you can send information to that thread from the various COM objects instantiated to speak. Maybe that is worth a try. However, based on what your criteria were - asynchronous speech - I am already thinking a separate EXE is the better way to go.