$speech, 'tekst' => $speech, 'v' => $v, 'e' => $e, 'haal' => $v ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); if (($v >= 14) and ($v <= 17)) { $url = 'http://teenus.eki.ee/konesyntees'; } elseif (($v >= 18) and ($v <= 23)) { $url = 'http://heliraamat.eki.ee/oss_syntees/koduleht.php'; } elseif (($v >= 24) and ($v <= 25)) { // meelis, kihnu $url = 'http://teenus.eki.ee/konesyntees'; } elseif (($v >= 26) and ($v <= 28)) { $url = 'http://heliraamat.eki.ee/oss_syntees/koduleht.php'; } elseif (($v >= 29) and ($v <= 39)) { // 29 lee, 30 liivika_hts, reserveerime 31..39 võimalikele uutele hts-idele $url = 'http://teenus.eki.ee/konesyntees'; } elseif (($v >= 40) and ($v <= 49)) { // 40,41,42 on veebilehel Eva,Tõnu,Riina // reserveerime 40..49 võimalikele uutele dnn-idele koneveeb.ee $url = 'https://koneveeb.ee/koduleht.php'; } elseif (($v >= 50) and ($v < 70)) { // 50,51,...69 reserveerime HTS V03 häältele $url = 'https://koneveeb.ee/koduleht.php'; } elseif (($v >= 74) and ($v <= 75)) { // spontaansed $url = 'http://heliraamat.eki.ee/oss_syntees/koduleht.php'; } elseif (($v >= 300) and ($v <= 311)) { // hääleks $v-300 lehelt neurokone.ee $url = 'https://koneveeb.ee/neuroproxy.php'; } elseif (($v >= 400) and ($v <= 499)) { // $url = 'http://koneveeb.eki.ee:5151'; $url = 'http://koneveeb.eki.ee/syntproxy/v1/synthesize/'; } elseif (($v >= 500) and ($v <= 599)) { $url = 'https://koneveeb.ee/koduleht.php'; } else { // $url = 'http://heli.eki.ee/syntees/koduleht.php'; $url = 'https://teenus.eki.ee/synthub'; } $result = file_get_contents($url, false, $context, 0, 40000); // kõnesünteesi server tagastab JSON räsi kujul oma tehtud // failinime(d) ilma kataloogi ja laiendita $jsonobj = json_decode($result); $filename = $jsonobj->wav; if (empty($filename)) { $filename = microtime(true) . '_'; } $wav_file = "{$audiodir}/{$filename}.wav"; $mp3_file = "{$audiodir}/{$filename}.mp3"; // tõmbame ja salvestame tehtud failid // kui teenusserver tagastas valmis URLi, kasutame seda $url = $jsonobj->wavurl; if (empty($url)) { $url = 'http://heli.eki.ee/syntees/wave/' . $filename . '.wav'; } file_put_contents($wav_file, fopen($url, 'r')); $url = $jsonobj->mp3url; if (empty($url)) { $url = 'http://heli.eki.ee/syntees/wave/' . $filename . '.mp3'; } file_put_contents($mp3_file, fopen($url, 'r')); // paneme uue failinime räsisse kirja $summad[$kontrollsumma] = $filename; $summastring = serialize($summad); $fh = fopen($sum_file, 'w'); fwrite ($fh, $summastring); fclose($fh); valmis: //fclose($dfh); if (file_exists($wav_file)) { // teeme mp3 kui see miskipärast puudus if (! file_exists($mp3_file)) { $lame_cmd = sprintf("lame %s %s", $wav_file, $mp3_file); exec($lame_cmd); } // ja tagastame suhtelise viida $wav_file = "/heli/tmp/{$filename}.wav"; $mp3_file = "/heli/tmp/{$filename}.mp3"; header ("Content-Type: application/javascript"); $vastus = array ('wav' => $wav_file, 'mp3' => $mp3_file); echo json_encode ($vastus); } ?>