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?
so much for high definition audio
probably the buffer in PHP is choking on the amount of data
PHP is designed for database use and XML, multimedia needs a different approach
Corsair Carbide 300R with window
Corsair TX850V2 70A@12V
Asus M5A99FX PRO R2.0 CFX/SLI
AMD Phenom II 965 C3 Black Edition @ 4.0 GHz
G.SKILL RipjawsX DDR3-2133 8 GB
EVGA GTX 260 + BFG GTX 260 SLI 55nm 216 core (GT200 Tesla)
Asus PA238QR IPS LED HDMI DP 1080p
ST2000DM001 & Windows 8.1 x64 Professional
LG WH14NS40 14X Blu-Ray Writer BDXL 128GB
Microsoft Wireless Desktop 2000
Wacom Bamboo CHT470M
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?