如果您所处的环境可以进行系统调用,则可以通过管道将
Festival
进入之内
lame
像这样:
<?php
$infile = tempnam();
file_put_contents($input, 'My name is judge');
$outfile = "/path/to/output.mp3";
$cmd = "text2wave -f 22050 < {$infile} | lame --quiet --preset medium - {$outfile}";
$output = $status = null;
exec($cmd, $output, $status);
SoX
相反,它也可以为您进行转换:
text2wave -f 22050 < input.txt | sox - output.mp3
this article
也许值得调查,但我自己还没试过。
我知道你没有使用ubuntu,但是对于其他可能觉得这个答案有用的人来说,有一个问题,即使你安装了所有“丑陋”的插件,SoX仍然不能输出MP3文件。您必须手动拆下.deb并修改debian/rules文件以删除——而不使用lame from deb\u CONFIGURE\u EXTRA\u标志。