Page 1 of 1

calling cepstral from php on os x

PostPosted: Thu Mar 29, 2007 4:38 am
by buggedcom
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
<?php

      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 />';
      print_r($output);
echo '<br />';
      print_r($return);

?>     


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

PostPosted: Tue May 15, 2007 9:28 am
by Alex
Hello,

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

-Alex

I have similar needs...please help.

PostPosted: Wed May 23, 2007 6:22 pm
by Varen
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.

Sincerely,

Varen Swaab

PostPosted: Sun Jun 17, 2007 2:37 am
by manojb
Perhaps you should try using the '-f <filename>' option to swift.

PostPosted: Sun Nov 04, 2007 9:08 pm
by talkingblogs.de
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,
Arne
:)

PostPosted: Tue Dec 02, 2008 12:52 pm
by petrocket
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
        putenv("DYLD_LIBRARY_PATH=");

        // 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 )

PostPosted: Tue Dec 02, 2008 12:55 pm
by petrocket
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);
print_r($output);