Merge raj's read to me feature.
[bookreader.git] / BookReaderIA / datanode / BookReaderGetTTS.php
1 <?
2
3 /*
4 Copyright(c)2008-2010 Internet Archive. Software license AGPL version 3.
5
6 This file is part of BookReader.
7
8     BookReader is free software: you can redistribute it and/or modify
9     it under the terms of the GNU Affero General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12
13     BookReader is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU Affero General Public License for more details.
17
18     You should have received a copy of the GNU Affero General Public License
19     along with BookReader.  If not, see <http://www.gnu.org/licenses/>.
20     
21     The BookReader source is hosted at http://github.com/openlibrary/bookreader/
22 */
23
24 $useMP3 = true;
25 if ('.ogg' == $_GET['format']) {
26     $useMP3 = false;
27 }
28
29 $cmd = 'echo ' . escapeshellarg($_GET['string']);
30 #$cmd .= ' | /home/rkumar/dev/festival/build/festival/bin/text2wave -eval "(voice_cmu_us_slt_arctic_hts)"';
31 $cmd .= ' | /home/rkumar/petabox/sw/bin/text2wave';
32 if ($useMP3) {
33     header('Content-Type: audio/mpeg');
34     $cmd .= ' |ffmpeg -i - -f mp3 -';
35 } else {
36     header('Content-Type: application/ogg');
37     $cmd .= ' |oggenc --quiet -';
38 }
39
40 passthru($cmd);
41 ?>