I wrote a simple code to generate a .WAV file from a hard-coded text ("Hello world") using Speech SDK. Here's my code:
using namespace std;
int _tmain(int argc, _TCHAR* argv)
HRESULT hr = S_OK;
CComPtr <ISpVoice> cpVoice;
CComPtr <ISpStream> cpWavStream;
hr = ::CoInitialize(NULL);
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&cpVoice);
hr = cAudioFmt.AssignFormat(SPSF_22kHz16BitMono);
hr = SPBindToFile(L"hello.wav", SPFM_CREATE_ALWAYS, &cpWavStream, &cAudioFmt.FormatId(), cAudioFmt.WaveFormatExPtr(), SPEI_PHONEME);
hr = cpVoice->SetOutput(cpWavStream, TRUE);
hr = cpVoice->Speak(L"Hello World", SPF_DEFAULT, NULL);
If I run the program directly on the console on a server, it produces a correct .WAV file (about 60 kB). However, if I call the program in a PHP script:
$cmd = "helloTTS.exe"; // The name of the program
The program runs and finishes, but the produced .WAV file is only 46 bytes. Why does this happen?
Update: I tried to run the PHP script using PHP interactive mode in Windows (php -a), and the program works correctly; the size of the .WAV file is 60 kB.
A question that might help me: which library (.DLL) is actually called by the functions such as ISpVoice::Speak()? Is it SAPI.DLL?
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?