create_audio.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file allows creating audio files from a text.
  5. *
  6. * @package chamilo.document
  7. *
  8. * @author Juan Carlos Raña Trabado
  9. * @since 8/January/2011
  10. * TODO:clean all file
  11. */
  12. /* INIT SECTION */
  13. $language_file = array('document');
  14. require_once '../inc/global.inc.php';
  15. $_SESSION['whereami'] = 'document/createaudio';
  16. $this_section = SECTION_COURSES;
  17. require_once 'document.inc.php';
  18. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  19. $nameTools = get_lang('CreateAudio');
  20. api_protect_course_script();
  21. api_block_anonymous_users();
  22. if (api_get_setting('enabled_text2audio') == 'false'){
  23. api_not_allowed(true);
  24. }
  25. $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
  26. if (empty($document_data)) {
  27. if (api_is_in_group()) {
  28. $group_properties = GroupManager::get_group_properties(api_get_group_id());
  29. $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
  30. $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
  31. }
  32. }
  33. $document_id = $document_data['id'];
  34. $dir = $document_data['path'];
  35. //javascript jquery
  36. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery-1.4.4.min.js" type="text/javascript"></script>';
  37. //jquery textareaCounter
  38. $htmlHeadXtra[] = '<script src="../inc/lib/javascript/textareacounter/jquery.textareaCounter.plugin.js" type="text/javascript"></script>';
  39. //need jquery for hide menus
  40. $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
  41. function advanced_parameters() {
  42. if(document.getElementById(\'options\').style.display == \'none\') {
  43. document.getElementById(\'options\').style.display = \'block\';
  44. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  45. } else {
  46. document.getElementById(\'options\').style.display = \'none\';
  47. document.getElementById(\'plus_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
  48. }
  49. }
  50. function setFocus(){
  51. $("#search_title").focus();
  52. }
  53. $(document).ready(function () {
  54. setFocus();
  55. });
  56. </script>';
  57. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  58. // Please, do not modify this dirname formatting
  59. if (strstr($dir, '..')) {
  60. $dir = '/';
  61. }
  62. if ($dir[0] == '.') {
  63. $dir = substr($dir, 1);
  64. }
  65. if ($dir[0] != '/') {
  66. $dir = '/'.$dir;
  67. }
  68. if ($dir[strlen($dir) - 1] != '/') {
  69. $dir .= '/';
  70. }
  71. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
  72. if (!is_dir($filepath)) {
  73. $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
  74. $dir = '/';
  75. }
  76. //groups //TODO: clean
  77. if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != 0) {
  78. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  79. $interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
  80. $noPHP_SELF = true;
  81. $to_group_id = $_SESSION['_gid'];
  82. $group = GroupManager :: get_group_properties($to_group_id);
  83. $path = explode('/', $dir);
  84. if ('/'.$path[1] != $group['directory']) {
  85. api_not_allowed(true);
  86. }
  87. }
  88. $interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($dir).$req_gid, "name" => get_lang('Documents'));
  89. if (!$is_allowed_in_course) {
  90. api_not_allowed(true);
  91. }
  92. if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'] || is_my_shared_folder(api_get_user_id(), Security::remove_XSS($dir),api_get_session_id()))) {
  93. api_not_allowed(true);
  94. }
  95. /* Header */
  96. event_access_tool(TOOL_DOCUMENT);
  97. $display_dir = $dir;
  98. if (isset ($group)) {
  99. $display_dir = explode('/', $dir);
  100. unset ($display_dir[0]);
  101. unset ($display_dir[1]);
  102. $display_dir = implode('/', $display_dir);
  103. }
  104. // Interbreadcrumb for the current directory root path
  105. // Copied from document.php
  106. $dir_array = explode('/', $dir);
  107. $array_len = count($dir_array);
  108. $dir_acum = '';
  109. for ($i = 0; $i < $array_len; $i++) {
  110. $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
  111. //Max char 80
  112. $url_to_who = cut($dir_array[$i],80);
  113. if ($is_certificate_mode) {
  114. $interbreadcrumb[] = array('url' => $url_dir.'&selectcat='.Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who);
  115. } else {
  116. $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
  117. }
  118. $dir_acum .= $dir_array[$i].'/';
  119. }
  120. //
  121. Display :: display_header($nameTools, 'Doc');
  122. echo '<div class="actions">';
  123. echo '<a href="document.php?id='.$document_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'','32').'</a>';
  124. echo '</div>';
  125. ?>
  126. <!-- javascript and styles for textareaCounter-->
  127. <script type="text/javascript">
  128. var info;
  129. $(document).ready(function(){
  130. var options = {
  131. 'maxCharacterSize': 100,
  132. 'originalStyle': 'originalTextareaInfo',
  133. 'warningStyle' : 'warningTextareaInfo',
  134. 'warningNumber': 20,
  135. 'displayFormat' : '#input/#max'
  136. };
  137. $('#textarea').textareaCount(options, function(data){
  138. $('#textareaCallBack').html(result);
  139. });
  140. });
  141. </script>
  142. <style>
  143. .overview {
  144. background: #FFEC9D;
  145. padding: 10px;
  146. width: 90%;
  147. border: 1px solid #CCCCCC;
  148. }
  149. .originalTextareaInfo {
  150. font-size: 12px;
  151. color: #000000;
  152. text-align: right;
  153. }
  154. .warningTextareaInfo {
  155. color: #FF0000;
  156. font-weight:bold;
  157. text-align: right;
  158. }
  159. #showData {
  160. height: 70px;
  161. width: 200px;
  162. border: 1px solid #CCCCCC;
  163. padding: 10px;
  164. margin: 10px;
  165. }
  166. </style>
  167. <?php
  168. echo '<div align="center">';
  169. Display::display_icon('sound.gif', get_lang('CreateAudio')); echo get_lang('HelpText2Audio');
  170. //Google services
  171. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktext2voice" onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display=\'block\';}else{document.getElementById(\'option1\').style.display=\'none\';}"/>&nbsp;<img src="../img/file_sound.gif" title="'.get_lang('HelpGoogleAudio').'" alt="'.get_lang('GoogleAudio').'"/>&nbsp;'.get_lang('GoogleAudio').'';
  172. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error1" style="display:none;color:red"></span>';
  173. echo '<div id="option1" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  174. echo '<form id="form1" name="form1" method="post" action="'.downloadMP3_google($filepath, $dir).'" class="formw">';
  175. echo '<br/>';
  176. echo '<label>'.get_lang('Language').': ';
  177. $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  178. $sql_select = "SELECT * FROM $tbl_admin_languages";
  179. $result_select = Database::query($sql_select);
  180. echo '<select name="lang" id="select">';
  181. while ($row = Database::fetch_array($result_select)) {
  182. if (api_get_setting('platformLanguage')==$row['english_name']){
  183. echo '<option value="'.$row['isocode'].'" selected="selected">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  184. }
  185. else{
  186. echo '<option value="'.$row['isocode'].'">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  187. }
  188. }
  189. echo '</select>';
  190. echo '</label>';
  191. echo '<br/><br/>';
  192. echo '<div>'.get_lang('InsertText2Audio').'</div>';
  193. echo '<br/>';
  194. echo '<label>';
  195. echo '<textarea name="text" id="textarea" cols="70" rows="2"></textarea>';
  196. echo '</label>';
  197. echo '<br/>';
  198. echo '<label>'.get_lang('Title').': ';
  199. echo '<input name="title" type="text" size="40" maxlength="40" />';
  200. echo '</label>';
  201. echo '<br/><br/>';
  202. echo '<button class="save" type="submit" name="SendText2Audio">'.get_lang('SaveMP3').'</button>';
  203. echo '<br/>';
  204. echo '</form>';
  205. echo '</div>';
  206. //Pediaphon services
  207. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktext2voice" onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display=\'block\';}else{document.getElementById(\'option2\').style.display=\'none\';}"/>&nbsp;<img src="../img/file_sound.gif" title="'.get_lang('HelpPediaphon').'" alt="'.get_lang('Pediaphon').'"/>&nbsp;'.get_lang('Pediaphon').'';
  208. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error2" style="display:none;color:red"></span>';
  209. echo '<div id="option2" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  210. echo '<form id="form2" name="form2" method="post" action="'.downloadMP3_pediaphone($filepath, $dir).'" class="formw">';
  211. echo '<br/>';
  212. echo '<label>'.get_lang('Language').': ';
  213. $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  214. $sql_select = "SELECT * FROM $tbl_admin_languages";
  215. $result_select = Database::query($sql_select);
  216. echo '<select name="lang" id="select" onClick="update_voices(this.selectedIndex)">';
  217. while ($row = Database::fetch_array($result_select)) {
  218. if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))){
  219. if (api_get_setting('platformLanguage')==$row['english_name']){
  220. echo '<option value="'.$row['isocode'].'" selected="selected">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  221. }
  222. else{
  223. echo '<option value="'.$row['isocode'].'">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  224. }
  225. }
  226. }
  227. echo '</select>';
  228. echo '</label>';
  229. echo '<label>&nbsp;&nbsp;'.get_lang('Voice').': ';
  230. echo '<select name="voices">';
  231. echo '<option selected>'.get_lang('FirstSelectALanguage').'</option>';
  232. echo '</select>';
  233. echo '</label>';
  234. echo '<label>&nbsp;&nbsp;'.get_lang('Speed').': ';
  235. echo '<select name="speed">';
  236. echo '<option value="0.75">'.get_lang('GoFaster').'';
  237. echo '<option value="0.8">'.get_lang('Fast').'';
  238. echo '<option value="1" selected>'.get_lang('Normal').'';
  239. echo '<option value="1.2">'.get_lang('Slow').'';
  240. echo '<option value="1.6">'.get_lang('SlowDown').'';
  241. echo '</select>';
  242. echo '</label>';
  243. echo '<br/><br/>';
  244. echo '<div>'.get_lang('InsertText2Audio').'</div>';
  245. echo '<br/>';
  246. echo '<label>';
  247. echo '<textarea name="text" id="textarea" cols="70" rows="10"></textarea>';
  248. echo '</label>';
  249. echo '<br/><br/>';
  250. echo '<label>'.get_lang('Title').': ';
  251. echo '<input name="title" type="text" size="40" maxlength="40" />';
  252. echo '</label>';
  253. echo '<br/><br/>';
  254. echo '<button class="save" type="submit" name="SendText2Audio">'.get_lang('SaveMP3').'</button>';
  255. echo '<br/>';
  256. echo '</form>';
  257. echo '</div>';
  258. ?>
  259. <!-- javascript form name form2 update voices -->
  260. <script type="text/javascript">
  261. var langslist=document.form2.lang
  262. var voiceslist=document.form2.voices
  263. var voices=new Array()
  264. <!--German -->
  265. voices[0]=["<?php echo get_lang('Female').' (de1)'; ?>|de1", "<?php echo get_lang('Male').' (de2)'; ?>|de2", "<?php echo get_lang('Female').' (de3)'; ?>|de3", "<?php echo get_lang('Male').' (de4)'; ?>|de4", "<?php echo get_lang('Female').' (de5)'; ?>|de5", "<?php echo get_lang('Male').' (de6)'; ?>|de6", "<?php echo get_lang('Female').' (de7)'; ?>|de7", "<?php echo get_lang('Female').' (de8 HQ)'; ?>|de8"]
  266. <!--English -->
  267. voices[1]=["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>| us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
  268. <!--Spanish -->
  269. voices[2]=["<?php echo get_lang('Male').' (es5 HQ)'; ?>|es5"]
  270. <!--French -->
  271. voices[3]=["<?php echo get_lang('Female').' (fr8 HQ)'; ?>|fr8"]
  272. function update_voices(selectedvoicegroup){
  273. voiceslist.options.length=0
  274. for (i=0; i<voices[selectedvoicegroup].length; i++)
  275. voiceslist.options[voiceslist.options.length]=new Option(voices[selectedvoicegroup][i].split("|")[0], voices[selectedvoicegroup][i].split("|")[1])
  276. }
  277. </script>
  278. <?php
  279. //vozMe services
  280. //disabled for a time
  281. /*
  282. echo '<div>&nbsp;</div><input type="checkbox" value="1" name="checktext2voice" onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display=\'block\';}else{document.getElementById(\'option3\').style.display=\'none\';}"/>&nbsp;<img src="../img/file_sound.gif" title="'.get_lang('HelpvozMe').'" alt="'.get_lang('vozMe').'"/>&nbsp;'.get_lang('vozMe').'';
  283. echo '&nbsp;&nbsp;&nbsp;<span id="msg_error3" style="display:none;color:red"></span>';
  284. echo '<div id="option3" style="padding:4px; margin:5px; border:1px dotted; display:none;">';
  285. echo '<form id="form3" name="form3" method="post" action="http://vozme.com/text2voice.php" target="mymp3" class="formw">';
  286. echo '<br/>';
  287. echo '<label>'.get_lang('Language').': ';
  288. $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
  289. $sql_select = "SELECT * FROM $tbl_admin_languages";
  290. $result_select = Database::query($sql_select);
  291. echo '<select name="lang" id="select">';
  292. while ($row = Database::fetch_array($result_select)) {
  293. if (in_array($row['isocode'], array('ca', 'en', 'es', 'hi', 'it', 'pt'))){
  294. if (api_get_setting('platformLanguage')==$row['english_name']){
  295. echo '<option value="'.$row['isocode'].'" selected="selected">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  296. }
  297. else{
  298. echo '<option value="'.$row['isocode'].'">'.$row['original_name'].' ('.$row['english_name'].')</option>';
  299. }
  300. }
  301. }
  302. echo '</select>';
  303. echo '</label>';
  304. echo '<label>&nbsp;&nbsp;'.get_lang('Voice').': ';
  305. echo '<select name="gn" id="select1">';
  306. echo '<option value="ml">'.get_lang('Male').'</option>';
  307. echo '<option value="fm">'.get_lang('Female').'</option>';
  308. echo '</select>';
  309. echo '</label>';
  310. echo '<br/><br/>';
  311. echo '<div>'.get_lang('InsertText2Audio').'</div>';
  312. echo '<br/>';
  313. echo '<label>';
  314. echo '<textarea name="text" id="textarea" cols="70" rows="10"></textarea>';
  315. echo '</label>';
  316. echo '<br/><br/>';
  317. echo '<button class="save" type="submit" name="SendText2Audio">'.get_lang('BuildMP3').'</button>';
  318. echo '<br/>';
  319. echo '</form>';
  320. echo '</div>';
  321. */
  322. echo '</div>';
  323. Display :: display_footer();
  324. //Functions. TODO:all at one
  325. /**
  326. * This function save a post into a file mp3 from google services
  327. *
  328. * @param $filepath
  329. * @param $dir
  330. * @author Juan Carlos Raña Trabado <herodoto@telefonica.net>
  331. * @version january 2011, chamilo 1.8.8
  332. */
  333. function downloadMP3_google($filepath, $dir){
  334. //security
  335. if(!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
  336. return;
  337. }
  338. global $_course, $_user;
  339. $clean_title=trim($_POST['title']);
  340. $clean_text=trim($_POST['text']);
  341. if(empty($clean_title) || empty($clean_text)){
  342. return;
  343. }
  344. $clean_title=Security::remove_XSS($clean_title);
  345. $clean_title=Database::escape_string($clean_title);
  346. $clean_text=Security::remove_XSS($clean_text);
  347. $clean_lang=Security::remove_XSS($_POST['lang']);
  348. $AudioFilename=$clean_title.'.mp3';
  349. $documentPath = $filepath.$AudioFilename;
  350. //prev for a fine unicode, borrowed from main api TODO:clean
  351. // Safe replacements for some non-letter characters (whitout blank spaces)
  352. $search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%');
  353. $replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
  354. $filename=$clean_text;
  355. // Encoding detection.
  356. $encoding = api_detect_encoding($filename);
  357. // Converting html-entities into encoded characters.
  358. $filename = api_html_entity_decode($filename, ENT_QUOTES, $encoding);
  359. // Transliteration to ASCII letters, they are not dangerous for filesystems.
  360. $filename = api_transliterate($filename, 'x', $encoding);
  361. // Replacing remaining dangerous non-letter characters.
  362. $clean_text = str_replace($search, $replace, $filename);
  363. //adding the file
  364. if (!file_exists($documentPath)){
  365. //add new file to disk
  366. file_put_contents($documentPath, file_get_contents("http://translate.google.com/translate_tts?tl=".$clean_lang."&q=".urlencode($clean_text).""));
  367. //add document to database
  368. $current_session_id = api_get_session_id();
  369. $groupId=$_SESSION['_gid'];
  370. $file_size = filesize($documentPath);
  371. $relativeUrlPath=$dir;
  372. $doc_id = add_document($_course, $relativeUrlPath.$AudioFilename, 'file', filesize($documentPath), $AudioFilename);
  373. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
  374. }
  375. }
  376. /**
  377. * This function save a post into a file mp3 from pediaphone services
  378. *
  379. * @param $filepath
  380. * @param $dir
  381. * @author Juan Carlos Raña Trabado <herodoto@telefonica.net>
  382. * @version january 2011, chamilo 1.8.8
  383. */
  384. function downloadMP3_pediaphone($filepath, $dir){
  385. //security
  386. if(!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
  387. return;
  388. }
  389. global $_course, $_user;
  390. $clean_title=trim($_POST['title']);
  391. $clean_text=trim($_POST['text']);
  392. if(empty($clean_title) || empty($clean_text)){
  393. return;
  394. }
  395. $clean_title=Security::remove_XSS($clean_title);
  396. $clean_title=Database::escape_string($clean_title);
  397. $clean_text=Security::remove_XSS($clean_text);
  398. $clean_lang=Security::remove_XSS($_POST['lang']);
  399. $clean_voices=Security::remove_XSS($_POST['voices']);
  400. $clean_speed=Security::remove_XSS($_POST['speed']);
  401. $AudioFilename=$clean_title.'.mp3';
  402. $documentPath = $filepath.$AudioFilename;
  403. //prev for a fine unicode, borrowed from main api TODO:clean
  404. // Safe replacements for some non-letter characters (whitout blank spaces)
  405. $search = array("\0", "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%');
  406. $replace = array('', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-');
  407. $filename=$clean_text;
  408. // Encoding detection.
  409. $encoding = api_detect_encoding($filename);
  410. // Converting html-entities into encoded characters.
  411. $filename = api_html_entity_decode($filename, ENT_QUOTES, $encoding);
  412. // Transliteration to ASCII letters, they are not dangerous for filesystems.
  413. $filename = api_transliterate($filename, 'x', $encoding);
  414. // Replacing remaining dangerous non-letter characters.
  415. $clean_text = str_replace($search, $replace, $filename);
  416. //adding the file
  417. if (!file_exists($documentPath)){
  418. //add new file to disk
  419. if($clean_lang=='de'){
  420. $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
  421. }
  422. elseif($clean_lang=='en'){
  423. $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_en.cgi';
  424. }
  425. elseif($clean_lang=='es'){
  426. $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_es.cgi';
  427. }
  428. elseif($clean_lang=='fr'){
  429. $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_fr.cgi';
  430. }
  431. file_put_contents($documentPath, file_get_contents($url_pediaphon."?stimme=".$clean_voices."&inputtext=".urlencode($clean_text)."&speed=".$clean_speed."&go=Sprich"));///speed
  432. //add document to database
  433. $current_session_id = api_get_session_id();
  434. $groupId=$_SESSION['_gid'];
  435. $file_size = filesize($documentPath);
  436. $relativeUrlPath=$dir;
  437. $doc_id = add_document($_course, $relativeUrlPath.$AudioFilename, 'file', filesize($documentPath), $AudioFilename);
  438. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
  439. }
  440. }
  441. ?>