/** * execute function. * * @access public * @return this object */ public function execute() { if ($this->encodingState > -1) { switch ($this->audio_method) { case speech::METHOD_FESTIVAL: $this->decode(); $this->initSanitise(); $this->writePlaylist(); $output = shell_exec("nice -n 19 /var/www/production/server-services/speech/tts/SB_generateAudio.sh {$this->scratch_path}{$this->uniqueID}.txt {$this->uniqueID} awb"); break; case speech::METHOD_INSIPIO: require_once dirname(__FILE__) . "/insipio.class.php"; $this->decode(); $this->initSanitise(); $path = $this->output_path . "INSIPIO-TTS-" . $this->uniqueID . "-" . 0 . ".mp3"; $language = isset($_GET['l']) ? strtolower($_GET['l']) : "en"; $in = new insipio($this->decodedData, $path, $language, $this->voice); $response = $in->send(); $this->chunks = 1; $this->writePlaylist(); // Flush any out of date fields. $this->flushCache(); break; case speech::METHOD_GOOGLE: require_once dirname(__FILE__) . "/google.class.php"; $this->initSanitise(); $path = $this->output_path . "GOOGLE-TTS-" . $this->uniqueID . "-" . 0 . ".mp3"; $language = isset($_GET['l']) ? strtolower($_GET['l']) : "en"; $google = new google($this->rawData, $path, $language); $response = $google->send(); $this->chunks = 1; $this->writePlaylist(); // Flush any out of date fields. $this->flushCache(); break; case speech::METHOD_ESPEAK: require_once dirname(__FILE__) . "/espeak.class.php"; $this->decode(); $this->initSanitise(); $path = $this->output_path . "ESPEAK-TTS-" . $this->uniqueID . "-" . 0 . ".mp3"; $language = isset($_GET['l']) ? strtolower($_GET['l']) : "en"; $in = new espeak($this->output_path . $this->uniqueID . ".txt", $path, $language, $this->voice); $response = $in->send(); $this->chunks = 1; $this->writePlaylist(); // Flush any out of date fields. $this->flushCache(); break; } // SCS fix 13/09/2011 // Don't wait for output. Version 2 of the toolbar waits for a response, which will hang the UI unless this is run in the background. // Sending to /dev/null & achieves this. Left the old command above just incase we need to put back at a later point. //exec("nice -n 19 /var/scripts/SB_generateAudio.sh {$this->scratch_path}{$this->uniqueID}.txt {$this->uniqueID} awb > /dev/null &"); if ($this->debug == 1) { file_put_contents($this->script_path . "debug/" . $this->uniqueID . ".txt", "execute:> Running generateAudio on dataset: {$this->clean}\n\n", FILE_APPEND); } if ($this->debug == 1) { file_put_contents($this->script_path . "debug/" . $this->uniqueID . ".txt", "execute:> result: " . $output . "\n\n", FILE_APPEND); } //file_put_contents($this->scratch_path . "chunks/clean-" . rand(0, 99) . ".txt", $this->returnClean() ); //echo $output; //echo "Execution string: /var/scripts/SB_generateAudio.sh {$this->scratch_path}/{$this->uniqueID}.txt {$this->uniqueID} awb"; } return $this; }