我正试图使用PHP和Python在我的Mac (小牛)上设置一个文本到语音服务器。当我通过终端执行Python脚本时,它工作得很好。但是,当我通过PHP通过浏览器执行它时,会生成TTS音频文件,但是LAME无法转换该文件。
这就是我的Python脚本中的内容:
from os import system
import sys
word=sys.argv[1].strip()
system('say -v Allison -o audio/'+word+'.aiff '+word)
system('lame audio/'+word+'.aiff audio/'+word+'.mp3')这是我的PHP:
<html>
<?php
error_reporting(E_ALL);
if (isset($_GET['word'])){$word=$_GET['word'];}
else {$word="test";}
echo $word;
exec('python tts.py '.$word);
echo "<audio controls><source src='audio/".$word.".mp3'></audio>";
?>
</html>任何关于可能出错的建议都将不胜感激。
发布于 2014-10-26 01:47:04
所以,我想出了一个问题:当“say”exec文件在usr/bin中时,lame在usr/bin/local中。下面的PHP脚本在将lame迁移到usr/bin之后工作,并且我能够完全取消Python:
<html>
<?php
error_reporting(E_ALL);
if (isset($_GET['word'])){$word=$_GET['word'];}
else {$word="test";}
echo $word;
//exec('python tts.py '.$word);
exec('say -v Allison -o audio/'.$word.'.aiff '.$word);
exec('lame audio/'.$word.'.aiff audio/'.$word.'.mp3');
echo "<audio controls><source src='audio/".$word.".mp3'></audio>";
?>
</html>https://stackoverflow.com/questions/26563689
复制相似问题