Hallo,
bin zufällig auf diese TTS-Klasse gestoßen. Sie benutzt die SPrachausgabe der Übersetzungsfunktion von google und speichert den Text als mp3.
Für andere Sprachen einfach die Domain-Endung anpassen.
Code stammt von dieser Seite: Google’s Text to Speech API : A PHP Wrapper Class | maSnun’s blog
<?php
// FileName: tts.php
/*
* A PHP Class that converts Text into Speech using Google's Text to Speech API
*
* Author:
* Abu Ashraf Masnun
* http://masnun.com
*
*/
class TextToSpeech {
public $mp3data;
function __construct($text="") {
$text = trim($text);
if(!empty($text)) {
$text = urlencode($text);
$this->mp3data = file_get_contents("http://translate.google.de/translate_tts?q={$text}");
}
}
function setText($text) {
$text = trim($text);
if(!empty($text)) {
$text = urlencode($text);
$this->mp3data = file_get_contents("http://translate.google.de/translate_tts?q={$text}");
return $mp3data;
} else { return false; }
}
function saveToFile($filename) {
$filename = trim($filename);
if(!empty($filename)) {
return file_put_contents($filename,$this->mp3data);
} else { return false; }
}
}
?>
Hier ein Beispiel:
<?php
require "tts.php";
$path = IPS_GetKernelDir()."/media/";
$tts = new TextToSpeech("Hallo Welt!");
$tts->saveToFile($path."test_tts.mp3");
?>