init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
39
lib/tts.php
Normal file
39
lib/tts.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?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.com/translate_tts?q={$text}");
|
||||
}
|
||||
}
|
||||
|
||||
function setText($text) {
|
||||
$text = trim($text);
|
||||
if(!empty($text)) {
|
||||
$text = urlencode($text);
|
||||
$this->mp3data = file_get_contents("http://translate.google.com/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; }
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue