Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Speech SDK

Speech SDK

Scheduled Pinned Locked Moved C / C++ / MFC
comarchitectureannouncement
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alex__b
    wrote on last edited by
    #1

    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.'

    B 1 Reply Last reply
    0
    • A alex__b

      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.'

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • B Blake Miller

        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.

        A Offline
        A Offline
        alex__b
        wrote on last edited by
        #3

        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.'

        B 1 Reply Last reply
        0
        • A alex__b

          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.'

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • B Blake Miller

            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.

            A Offline
            A Offline
            alex__b
            wrote on last edited by
            #5

            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.'

            B 1 Reply Last reply
            0
            • A alex__b

              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.'

              B Offline
              B Offline
              Blake Miller
              wrote on last edited by
              #6

              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.

              A 1 Reply Last reply
              0
              • B Blake Miller

                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.

                A Offline
                A Offline
                alex__b
                wrote on last edited by
                #7

                Thank you, I will try that. alex 'Architecture is music frozen in space.'

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups