Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuj Sharma committed May 21, 2018
1 parent a9edb01 commit b69ff7b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/WatsonTts.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ public function tts($text, $format = null, $language = null, $voice = null)

$this->prepareOutputFile();

$this->processWatsonTtsCurl();
try {
return $this->processWatsonTtsCurl();
} catch (Exception $exception) {
throw new Exception($exception->getMessage());
}
}

/**
Expand Down Expand Up @@ -233,10 +237,19 @@ private function processWatsonTtsCurl()
throw new Exception('Error with curl response: '.curl_error($ch));
}
curl_close($ch);
fclose($output_file);

if ($result && is_file($this->output_file_path))
return $this->output_file_path;

print_r($result);
throw new Exception('Error creating file');
}

/**
* prepare watson url to append /v1/synthesize if not provided
*
* @param $watson_url
*/
private function _prepareWatsonUrl($watson_url)
{
$trim_url = rtrim($watson_url, '/');
Expand Down

0 comments on commit b69ff7b

Please sign in to comment.