changed git call from https to git readonly
[atutor.git] / mods / atalker / text_reader.php
1 <?php
2 /****************************************************************/
3 /* ATalker                                                                                                      */
4 /****************************************************************/
5 /* Copyright (c) 2002-2005 by Greg Gay       */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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 $
14
15         // Get the time to use as a default filename
16         $now = time();
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'];
21                 }else{
22                                 $file_save = AT_SPEECH_TEMPLATE_DIR.$_POST['filename'];
23                 }
24         }else{
25                 if($_SESSION['course_id'] > 0){
26                         $file_save = AT_SPEECH_FILES_DIR.$now.'.'.$_POST['file_type'];          
27                 }else{
28                         $file_save = AT_SPEECH_TEMPLATE_DIR.$now.'.'.$_POST['file_type'];       
29                 }
30
31         }
32
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';
39
40         
41         // Build the Scheme file. Lots more can be done here to customize voices
42         $scheme_in .= "(";
43         $scheme_in .= $_POST['voice'];
44         $scheme_in .= ")\n";
45         $scheme_in .= "(";
46         $scheme_in .= "Parameter.set 'Duration_Stretch ".$_POST['duration'];
47         $scheme_in .= ")";
48         
49         // create a scheme file with the voice properties
50         $fp = fopen($scheme_out,'w');
51         if (!$fp) {
52                 echo AT_ERROR_TTS_NOT_CREATE_SCHEME;
53                 exit;
54         }
55         fputs($fp, $scheme_in);
56         fclose($fp);
57         
58         //$file_props = "-mode --tts -eval ".AT_SPEECH_DIR.$now.".scm";
59
60         if(!$_POST['create'] && !$_POST['remove']){
61         
62                 //create a text file from the inputted text
63                 $fp = fopen($file_in,'w');
64                 if (!$fp) {
65                         echo AT_ERROR_TTS_NOT_CREATE_TEXT;
66                         exit;
67                 }
68                 fputs($fp, $_POST['textin']);
69                 fclose($fp);
70         
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;    
77                         }
78                         
79                         escapeshellcmd($command);
80                         escapeshellcmd($command2);
81                         passthru($command);
82                         passthru($command2);
83                         gen_tts();
84                         
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);
90                         passthru($command);
91                         passthru($command2);
92                         gen_tts();
93                         
94                 }else{
95                         $command = "text2wave $file_props $file_in -o $file_out -F 48000 -scale ".$_POST['volumn']."";
96                         escapeshellcmd($command);
97                         passthru($command);
98                         gen_tts();
99                         
100                 
101                 }
102         }
103 ?>