Realize the conversion of text to sound (WAVE)

xiaoxiao2021-03-06  15

//text_to_wave.cpp

#include #include

#pragma comment (lib, "ole32.lib") # Pragma Comment (Lib, "SAPI.LIB")

INT Main (int Argc, char * argv []) {ispVoice * pvoice = null; // COM initialization: if (Failed (:: Coinitialize (Null)) Return False; // Get IsPVoice: HRESULT HR = CoCreateInstance (CLSID_SPVoice , NULL, CLSCTX_ALL, IID_ISpVoice, (void **) & pVoice); if (SUCCEEDED (hr)) {CComPtr cpWavStream; CComPtr cpOldStream; CSpStreamFormat OriginalFmt; pVoice-> getOutputStream (& cpOldStream); OriginalFmt.AssignFormat ( CpoldStream); // Binding file: hr = spbindtofile (l "d: //output.wav", SPFM_CREATE_ALWAYS, & CPWAVSTREAM, & Originalfmt.Formatid (), OriginalFmt.waveFormateXptr ());

IF (succeeded (hr)) {pvoice-> setOutput (cpwavstream, true); wchar wtx [] = L " text to wave"; pvoice-> speak (WTX, SPF_IS_XML , Null; pvoice-> release (); pvoice = null;}}

/ / Release COM resources: :: couninitialize (); return true;}

转载请注明原文地址:https://www.9cbs.com/read-46257.html

New Post(0)