calling cepstral from php on os x

How-to questions and answers

calling cepstral from php on os x

Postby buggedcom » Thu Mar 29, 2007 4:38 am

I'm trying to call swift from php using exec on a mac os x machine, however it's not working. I've tried via the terminal and it works fine?

Any ideas? (It's still a trial)

The code I'm using from php is

Code: Select all

      exec('/usr/bin/swift -n Callie -o /Users/ollie/Sites/dev/test.wav -m text', $output, $return)    ;
   echo '/usr/bin/swift -n Callie -o /Users/ollie/Sites/dev/test.wav -m text<br />';
echo $output.'<br />';
echo $return.'<br />';
echo '<br />';


which doesn;t produce anything, yet from the terminal it works fine

Code: Select all
/usr/bin/swift -n Callie -o /Users/ollie/Sites/dev/test.wav -m text
Last edited by buggedcom on Wed May 30, 2007 7:40 am, edited 1 time in total.
Posts: 1
Joined: Thu Mar 29, 2007 4:29 am

Postby Alex » Tue May 15, 2007 9:28 am


I'm no php expert, but it looks like there is no text being passed to the swift call?

Posts: 26
Joined: Mon Dec 04, 2006 11:19 am

I have similar needs...please help.

Postby Varen » Wed May 23, 2007 6:22 pm

I'm considering several distribution licenses for a web site project I'm working on but I don't have the skill needed to make the (what seems to be) simple connection between a web page and the command line swift interface. I'm OK with PHP and a regular whiz with html but that's where it ends.

I'm sure that some substantive guidance by Cepstral (perhaps an actual "how to" or tutorial) would solve this mysterious problem for many independent web developers such as myself who don't have the mental bandwidth to wrap our heads around yet another technology simply to accomplish one simple thing and don't have a budget to hire someone to do so.

I'm looking to put Cepstral voices on a web page as a download link which is created as a result of a form submission. In other words, just like the sample on the Cepstral web site a user will type in text and hit a submit button where a call is made to an external (http) OS X server, an .mp3 file is created into a public html folder.

I would sure appreciate it if someone at Cepstral could help me with this.


Varen Swaab
Posts: 1
Joined: Wed May 23, 2007 6:09 pm

Postby manojb » Sun Jun 17, 2007 2:37 am

Perhaps you should try using the '-f <filename>' option to swift.
Posts: 19
Joined: Fri Mar 09, 2007 3:35 pm

Postby » Sun Nov 04, 2007 9:08 pm

Hi all, hi Alex! :D

I just stumbled across this post in the Cepstral forum while trying to solve a similar issue. Somebody tried to use my talkingblogs-plugin and exactly the same thing as described above happened ...

I'm not quite sure, but maybe the problem comes from the rights, which the PHP user has on the web server. There might be problems with the PHP exec() function in some PHP environments with activated safe_mode for example (try setting variable "safe_mode" to "off"). The problem might also come from other restrictions that are set up on the web server (Apache?!) regarding PHP ...

I'll discuss the problem with the guy who just contacted me and let u know the results.

Greetz from Germany,
Posts: 5
Joined: Sun Nov 04, 2007 8:57 pm

Postby petrocket » Tue Dec 02, 2008 12:52 pm

If you look in your php error log file you should see that there is a linking error when you call /usr/bin/swift

The reason for the linking error is that MAMP defines DYLD_LIBRARY_PATH to be a directory in the MAMP/Library folder, which the swift program was probably never linked against.

To get around this problem in your script unset the environment var before execing /usr/bin/swift like this:

Code: Select all
        // must get rid of modified DYLD library path on osx

        // now exec the swift application and have it write to output.wav
        exec('/usr/bin/swift -o output.wav "testing 1 2 3"');

If you are going to run a lot more php after this exec call and you get errors you might add a second call to putenv to set the environment variable back to the original MAMP setting (you can see this in MAMP/Library/bin/envvars - open this file in textedit )

Postby petrocket » Tue Dec 02, 2008 12:55 pm

Another useful tidbit when using exec - the reason you didn't see the error output (or any output at all) is because exec only captures STDOUT and not STDERR. To view the STDERR output of any app you must append the magical linux text " 2>&1 " (which means append STDERR (2) to STDOUT (1))

In php this looks like
Code: Select all
$output = array();
exec('/usr/bin/swift 2>&1', $output);

Return to How do I... ?

Who is online

Users browsing this forum: No registered users and 1 guest