];
$text = trim($data['text']);
+ $text = preg_replace('/!\[[^)]*\)/', '', $text);
$text = str_replace(array_keys($replace), array_values($replace), $text);
$text = Text::cleanUTF8($text, '');
}
$ttsText = Api::stripNonSSMLTags($text);
+
+
$hash = hash('sha256', $engine . ':' . $voice . '_^_' . $ttsText);
$fname = $hash . '.mp3';
$dir = Files::mkdir($this->getFluidbook()->protected_path('audiodescription'));
try {
$api = new \Cubist\Azure\TTS\Api(env('AZURE_TTS_API_KEY'));
$api->textToSpeech($text, $locale, $gender, $voiceName, $output);
- if (!file_exists($output)) {
+ if (!file_exists($output) || filesize($output) < 100) {
throw new Exception('Error while making tts (' . $output . ') : ' . $text . ', ' . $locale . ', ' . $gender . ', ' . $voiceName);
}
} catch (Exception $e) {