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: sable_reader.php 5123 2005-07-12 14:59:03Z greg $
15 // Get the time to use as a default filename
17 if($_POST['filename']){
18 if($_SESSION['course_id'] > 0){
19 $file_save = AT_SPEECH_FILES_DIR.$_POST['filename'];
21 $file_save = AT_SPEECH_TEMPLATE_DIR.$_POST['filename'];
24 if($_SESSION['course_id'] > 0){
25 $file_save = AT_SPEECH_FILES_DIR.$now.'.'.$_POST['file_type'];
27 $file_save = AT_SPEECH_TEMPLATE_DIR.$now.'.'.$_POST['file_type'];
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'];
39 $postdata = serialize($_POST);
41 if(!$_POST['create'] && !$_POST['remove']){
44 <!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN" "Sable.v0_2.dtd"[]>
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']);
60 //write the SABLE file
61 $fp = fopen($file_in,'w');
63 echo AT_ERROR_TTS_NOT_CREATE_SABLE;
66 fputs($fp, $sable_out);
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;
77 escapeshellcmd($command);
78 escapeshellcmd($command2);
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);
92 $command = "text2wave $file_in -o $file_out -F 48000";
93 escapeshellcmd($command);