From d1e690ada4709a4775b161a28c9283fa0902cd27 Mon Sep 17 00:00:00 2001 From: rajbot Date: Thu, 30 Sep 2010 05:29:22 +0000 Subject: [PATCH] add BookReaderGetTTS.php --- BookReader/BookReader.js | 4 +-- BookReaderIA/datanode/BookReaderGetTTS.php | 41 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 BookReaderIA/datanode/BookReaderGetTTS.php diff --git a/BookReader/BookReader.js b/BookReader/BookReader.js index f806d25..191617d 100644 --- a/BookReader/BookReader.js +++ b/BookReader/BookReader.js @@ -3884,7 +3884,7 @@ BookReader.prototype.ttsStartCB = function (data) { var snd = soundManager.createSound({ id: 'chunk'+this.ttsIndex+'-0', //url: 'http://home.us.archive.org/~rkumar/arctic.ogg', - url: 'http://'+this.server+'/getTTS.php?string=' + escape(data[0][0]) + '&format=.'+this.ttsFormat, //the .ogg is to trick SoundManager2 to use the HTML5 audio player + url: 'http://'+this.server+'/BookReader/BookReaderGetTTS.php?string=' + escape(data[0][0]) + '&format=.'+this.ttsFormat, //the .ogg is to trick SoundManager2 to use the HTML5 audio player whileloading: function(){if (this.bytesLoaded == this.bytesTotal) this.br.ttsRemovePopup();}, //onload never fires in FF... onload: function(){this.br.ttsRemovePopup();} //whileloading never fires in safari... }); @@ -3936,7 +3936,7 @@ BookReader.prototype.ttsNextPageCB = function (data) { BookReader.prototype.ttsLoadChunk = function (page, pos, string) { var snd = soundManager.createSound({ id: 'chunk'+page+'-'+pos, - url: 'http://'+this.server+'/getTTS.php?string=' + escape(string) + '&format=.'+this.ttsFormat //the .ogg is to trick SoundManager2 to use the HTML5 audio player + url: 'http://'+this.server+'/BookReader/BookReaderGetTTS.php?string=' + escape(string) + '&format=.'+this.ttsFormat //the .ogg is to trick SoundManager2 to use the HTML5 audio player }); snd.br = this; snd.load() diff --git a/BookReaderIA/datanode/BookReaderGetTTS.php b/BookReaderIA/datanode/BookReaderGetTTS.php new file mode 100644 index 0000000..0597ecc --- /dev/null +++ b/BookReaderIA/datanode/BookReaderGetTTS.php @@ -0,0 +1,41 @@ +. + + The BookReader source is hosted at http://github.com/openlibrary/bookreader/ +*/ + +$useMP3 = true; +if ('.ogg' == $_GET['format']) { + $useMP3 = false; +} + +$cmd = 'echo ' . escapeshellarg($_GET['string']); +#$cmd .= ' | /home/rkumar/dev/festival/build/festival/bin/text2wave -eval "(voice_cmu_us_slt_arctic_hts)"'; +$cmd .= ' | /home/rkumar/petabox/sw/bin/text2wave'; +if ($useMP3) { + header('Content-Type: audio/mpeg'); + $cmd .= ' |ffmpeg -i - -f mp3 -'; +} else { + header('Content-Type: application/ogg'); + $cmd .= ' |oggenc --quiet -'; +} + +passthru($cmd); +?> -- 2.20.1