2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2005 by Greg Gay */
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
13 // $Id: text_reader.php 5123 2005-07-12 14:59:03Z greg $
15 // Get the time to use as a default filename
17 // Otherwise use the file name entered by the user
18 if($_POST['filename']){
19 if($_SESSION['course_id'] > 0){
20 $file_save = AT_SPEECH_FILES_DIR.$_POST['filename'];
22 $file_save = AT_SPEECH_TEMPLATE_DIR.$_POST['filename'];
25 if($_SESSION['course_id'] > 0){
26 $file_save = AT_SPEECH_FILES_DIR.$now.'.'.$_POST['file_type'];
28 $file_save = AT_SPEECH_TEMPLATE_DIR.$now.'.'.$_POST['file_type'];
33 $file_out = AT_SPEECH_DIR.'/'.$now.'.wav';
34 $file_out_mp3 = AT_SPEECH_DIR.$now.'.mp3';
35 $file_out_ogg = AT_SPEECH_DIR.$now.'.ogg';
36 $file_in = AT_SPEECH_DIR.$now.'.txt';
37 $file_recieve = AT_SPEECH_URL.$now.'.'.$_POST['file_type'];
38 $scheme_out = AT_SPEECH_DIR.$now.'.scm';
41 // Build the Scheme file. Lots more can be done here to customize voices
43 $scheme_in .= $_POST['voice'];
46 $scheme_in .= "Parameter.set 'Duration_Stretch ".$_POST['duration'];
49 // create a scheme file with the voice properties
50 $fp = fopen($scheme_out,'w');
52 echo AT_ERROR_TTS_NOT_CREATE_SCHEME;
55 fputs($fp, $scheme_in);
58 //$file_props = "-mode --tts -eval ".AT_SPEECH_DIR.$now.".scm";
60 if(!$_POST['create'] && !$_POST['remove']){
62 //create a text file from the inputted text
63 $fp = fopen($file_in,'w');
65 echo AT_ERROR_TTS_NOT_CREATE_TEXT;
68 fputs($fp, $_POST['textin']);
71 if($_POST['file_type'] == "mp3"){
72 $command = "text2wave $file_props $file_in -o $file_out -F 48000 -scale ".$_POST['volumn']."";
73 if(shell_exec('lame --longhelp')){
74 $command2 = 'lame --quiet '.$file_out.' '. $file_out_mp3;
75 }else if (shell_exec('bladeenc -h')) {
76 $command2 = 'bladeenc -quiet '.$file_out.' '. $file_out_mp3;
79 escapeshellcmd($command);
80 escapeshellcmd($command2);
85 }else if($_POST['file_type'] == "ogg"){
86 $command = "text2wave $file_props $file_in -o $file_out -F 48000 -scale ".$_POST['volumn']."";
87 $command2 = 'oggenc -quiet '.$file_out.' '. $file_out_ogg;
88 escapeshellcmd($command);
89 escapeshellcmd($command2);
95 $command = "text2wave $file_props $file_in -o $file_out -F 48000 -scale ".$_POST['volumn']."";
96 escapeshellcmd($command);