Skip to content

Instantly share code, notes, and snippets.

@3735943886
Last active August 4, 2023 17:27
Show Gist options
  • Save 3735943886/97bef1d4e30edca6615eeab54101a180 to your computer and use it in GitHub Desktop.
Save 3735943886/97bef1d4e30edca6615eeab54101a180 to your computer and use it in GitHub Desktop.
#pragma comment(lib, "winmm")
#pragma comment(lib, "ole32")
#include <sapi.h>
void main()
{
    HRESULT hr;
    ISpVoice* pVoice;
    // For TTS
    ::CoInitialize(NULL);
    pVoice = NULL;
    ::CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
    hr = pVoice->Speak(L"Hello World", SPF_DEFAULT, NULL);
    pVoice->Release();
    ::CoUninitialize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment