add BookReaderGetTTS.php
authorrajbot <raj@archive.org>
Thu, 30 Sep 2010 05:29:22 +0000 (05:29 +0000)
committerrajbot <raj@archive.org>
Thu, 30 Sep 2010 05:29:22 +0000 (05:29 +0000)
BookReader/BookReader.js
BookReaderIA/datanode/BookReaderGetTTS.php [new file with mode: 0644]

index f806d25..191617d 100644 (file)
@@ -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 (file)
index 0000000..0597ecc
--- /dev/null
@@ -0,0 +1,41 @@
+<?
+
+/*
+Copyright(c)2008-2010 Internet Archive. Software license AGPL version 3.
+
+This file is part of BookReader.
+
+    BookReader is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BookReader is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with BookReader.  If not, see <http://www.gnu.org/licenses/>.
+    
+    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);
+?>