Jump to content

Running Microsoft Speech API console program in PHP


ThurSN

Recommended Posts

I wrote a simple console program using Microsoft Speech API to generate a .WAV file from a hard-coded text ("Hello world"). If I run the code directly on the console (on the server), it produces a correct .WAV file (about 60 kB). However, if I call the program from PHP:

 

<?php

$cmd = "helloTTS.exe"               // Program name

exec($cmd);

?>

 

The program runs and finishes, but the size of the .WAV file is only 46 bytes. I've tried using system(), shell_exec(), and passthru(), all with the same result. In another forum, somebody said that probably the buffer size of PHP is not enough to hold the amount of the generated data.

 

If it's the buffer, I guess it's the buffer of the PHP shell. How to check & increase the size of this buffer? And what else could cause this problem?

Edited by ThurSN
Link to comment
Share on other sites

Update to the above: I tried to run the PHP script using PHP interactive mode in Windows (php -a), and the .WAV file is produced correctly (60 kB). Is there actually any difference between the PHP script run from the browser and using interactive mode?

Link to comment
Share on other sites

Is there actually any difference between the PHP script run from the browser and using interactive mode?

Yes. Accessing a php script means that it is served up by your http server. The php script therefor runs with the permissions of this http server.

 

Running the script yourself executes the script with whatever permissions you have.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.