changed git call from https to git readonly
[atutor.git] / mods / atalker / sable_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: sable_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         if($_POST['filename']){
18                 if($_SESSION['course_id'] > 0){
19                                 $file_save = AT_SPEECH_FILES_DIR.$_POST['filename'];
20                 }else{
21                                 $file_save = AT_SPEECH_TEMPLATE_DIR.$_POST['filename'];
22                 }
23         }else{
24                 if($_SESSION['course_id'] > 0){
25                         $file_save = AT_SPEECH_FILES_DIR.$now.'.'.$_POST['file_type'];          
26                 }else{
27                         $file_save = AT_SPEECH_TEMPLATE_DIR.$now.'.'.$_POST['file_type'];       
28                 }
29         }
30
31
32         $file_in = AT_SPEECH_DIR.$now.'.sable';
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_recieve = AT_SPEECH_URL.$now.'.'.$_POST['file_type'];
37         
38
39  $postdata = serialize($_POST);
40
41  if(!$_POST['create'] && !$_POST['remove']){
42 $sable_out = '
43 <?xml version="1.0"?>
44 <!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN" "Sable.v0_2.dtd"[]>
45 <SABLE>
46  <LANGUAGE ID="'.$_POST['language'].'" CODE="ISO-8859-1">
47   <SPEAKER NAME="'.$_POST['speaker'].'">
48    <PITCH BASE="'.$_POST['base'].'" MIDDLE="'.$_POST['middle'].'" RANGE="'.$_POST['range'].'">
49     <RATE SPEED="'.$_POST['rate'].'">
50      <VOLUMN LEVEL="'.$_POST['volumn'].'">';
51         $sable_out .= stripslashes($_POST['textin']);
52         $sable_out .= '
53      </VOLUMN>
54     </RATE>
55    </PITCH>
56   </SPEAKER>
57  </LANGUAGE>
58 </SABLE>';
59
60         //write the SABLE file
61         $fp = fopen($file_in,'w');
62         if (!$fp) {
63                 echo AT_ERROR_TTS_NOT_CREATE_SABLE;
64                 exit;
65         }
66         fputs($fp, $sable_out);
67         fclose($fp);
68
69
70         if($_POST['file_type'] ==  "mp3"){
71                 $command = "text2wave $file_in -o $file_out -F 48000";
72                 if(shell_exec('lame --longhelp')){
73                         $command2 = 'lame --quiet '.$file_out.' '. $file_out_mp3;
74                 }else if (shell_exec('bladeenc -h')) {
75                         $command2 = 'bladeenc -quiet '.$file_out.' '. $file_out_mp3;    
76                 }
77                 escapeshellcmd($command);
78                 escapeshellcmd($command2);
79                 passthru($command);
80                 passthru($command2);
81                 gen_tts();
82         }else if($_POST['file_type'] ==  "ogg"){
83                 $command = "text2wave $file_in -o $file_out -F 48000";
84                 $command2 = 'oggenc -quiet '.$file_out.' '. $file_out_ogg;
85                 escapeshellcmd($command);
86                 escapeshellcmd($command2);
87                 passthru($command);
88                 passthru($command2);
89                 gen_tts();
90         
91         }else{
92                 $command = "text2wave $file_in -o $file_out -F 48000";
93                 escapeshellcmd($command);
94                 passthru($command);
95                 gen_tts();
96         }
97 }
98
99 ?>