Тестовая Запись

#!/usr/bin/php -q
<?php
$agivars = array();
while (!feof(STDIN)) {
$agivar = trim(fgets(STDIN));
if ($agivar === '')
break;
$agivar = explode(':', $agivar);
$agivars[$agivar[0]] = trim($agivar[1]);
}
extract($agivars);

$text = $_SERVER["argv"][1];
$md5 = md5($text);
$prefix = '/var/lib/asterisk/festivalcache/';
$key = 'Yandex_API’;
$speaker='zahar';
$emotion='good';
$lang='ru-RU';
$format='mp3';
$filename = $prefix.$md5;

if (!file_exists($filename.'.alaw')) {
exec('curl "https://tts.voicetech.yandex.net/generate?format='.$format.'&lang='.$lang.'&speaker='.$speaker.'&emotion='.$emotion.'&key='.$key.'" -G --data-urlencode "text='.$text.'" > '.$filename.'.mp3');
exec('ffmpeg -i '.$filename.'.mp3 -ar 8000 -ac 1 -ab 64 '.$filename.'.wav -ar 8000 -ac 1 -ab 64 -f alaw '.$filename.'.alaw -map 0:0 -map 0:0');
}

echo 'EXEC Background "'.$filename.'" ""'."\n";
exit(0);
?>
# chmod 777 /var/lib/asterisk/agi-bin/say.php
# chown asterisk:asterisk /var/lib/asterisk/agi-bin/say.php
# chmod 777 /var/lib/asterisk/festivalcache
# chown asterisk:asterisk /var/lib/asterisk/festivalcache
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dex