Skip to content

Instantly share code, notes, and snippets.

@sherief
Forked from 3735943886/simplesapi.cpp
Created August 4, 2023 17:27
Show Gist options
  • Save sherief/61ae2a1e6d17b275833be91be12e54ec to your computer and use it in GitHub Desktop.
Save sherief/61ae2a1e6d17b275833be91be12e54ec 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