5 function __construct() {
6 $this->mode = 'rhvoice';
9 $this->display = ":99";
12 function text2Wav($string,$lang = "ru")
17 if ($redis->pconnect('127.0.0.1', 6379, 2.5)) {
18 $hash="voice-".hash("sha256","$lang-$string");
19 $result=$redis->get($hash);
25 if ($this->mode == 'festival') {
27 $prolog="/etc/festival/$lang.scm";
28 if (!file_exists($prolog)) {
29 $prolog="/etc/festival/default.scm";
32 //make sure that your environment is set to find the festival binaries!
33 $cmd = "festival_client --prolog $prolog --ttw | lame -f - -";
34 } elseif ($this->mode == 'rhvoice') {
35 $cmd = "DISPLAY=".$this->display." RHVoice-client -s Anna+CLB -r ".$this->speed." -p ".$this->pitch." | lame -f - -";
41 $descriptorspec = array(
42 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
43 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
44 2 => array("pipe", "w") // stderr is a file to write to
48 $process = proc_open($cmd, $descriptorspec, $pipes, $cwd, $env);
49 if (is_resource($process)) {
50 fwrite($pipes[0],$string);
52 $data = stream_get_contents($pipes[1]);
55 $proc_result = proc_close($process);
60 $redis->set($hash,$data);