Google translate bloque en cas d'utilisation importante (mais qui est en fait une vingtaine d'utilsiation par IP), j'utilise maintenant voicerss qui a l'avantage de coder directement en wav au format utilisable par asterisk (don pas besoin de MPG123)
Autre solution fonctionnelle avec un AGI. dans le dial plan exten=123,1,agi(c.agi,bonjour le monde)
il faut créer un compte gratuit sous voicerss et mettre a jour la clé dans le code AGI
le fichier AGI
#!/usr/bin/php -q
<?php
ob_implicit_flush(true);
set_time_limit(6);
$in = fopen("php://stdin","r");
$stdlog = fopen("volume1/scripts/Asterisk/my_agi.log", "w");
$debug = false;
function read() {
global $in, $debug, $stdlog;
$input = str_replace("\n", "", fgets($in, 4096));
if ($debug) fputs($stdlog, "read: $input\n");
return $input;
}
function errlog($line) {
global $err;
echo "VERBOSE \"$line\"\n";
}
function write($line) {
global $debug, $stdlog;
if ($debug) fputs($stdlog, "write: $line\n");
echo $line."\n";
}
// parse agi headers into array
while ($env=read()) {
$s = split(": ",$env);
$agi[str_replace("agi_","",$s[0])] = trim($s[1]);
if (($env == "") || ($env == "\n")) {
break;
}
}
$tt = $_SERVER['argv'][1];
$soun = exec('echo -n '.$tt.' | /opt/bin/md5deep');
$sound = $soun.".wav";
$fichier = "/volume1/scripts/wav/".$soun;
if (file_exists($fichier)) {
echo "Le fichier $filename existe.";
} else {
$tts = '"https://api.voicerss.org?key=xxxxxxxxxxxxxxxsrc='.urlencode($tt).'&hl=fr-fr&c=wav&f=8khz_16bit_mono"';
$cmd= ' curl '.$tts.' > /volume1/scripts/wav/'.$sound;
exec ($cmd);
}
$file = "/volume1/scripts/wav/".$soun;
echo "VERBOSE \"Here we go!\" 2\n";
read();
errlog("Call from ".$agi['channel']." - Calling phone");
read();
write("EXEC PLAYBACK $file "); // X is the escape digit. since X is not DTMF, no exit is possible
read();
// clean up file handlers etc.
fclose($in);
fclose($stdlog);
exit;
?>