Search code examples
c++command-linetext-to-speechsapi

How would I go about allowing multiple instances of a TTS app to run?


For a project, I have been looking through the web for a MS command line program to read text to speech out loud with a custom SAPI5 voice. I found one that suits my needs, https://github.com/brookhong/tts. This is what I was looking for, but the thing that I needed was for it to run multiple times at once. I have tts -f 3 -v 1 "Hello" in a batch file, and it works just the way I want it but running the file a second time will cause it to just talk after the first instance has completed talking.

I have tried removing m_pVoice->WaitUntilDone( INFINITE ); from the source and reducing INFINITE to 1, as that seems to prevent the second instance from playing. What would be another way to go about this task?


Solution

  • After reviewing the source of the github repository you linked, there's a call

    hr = pVoice->Speak(wbuf, 0, NULL);
    

    Which could be the hold up. Instead of 0 you might want to try changing that to

    hr = pVoice->Speak(wbuf, SPF_ASYNC , NULL);
    

    Recompile, and then try running multiple instances.