From: Vincent Vanwaelscappel Date: Thu, 22 Jan 2026 14:16:00 +0000 (+0100) Subject: #7958 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c2518e7718ce209e1ec204f4c33f8a04906c7efa;p=fluidbook-toolbox.git #7958 @0.25 --- diff --git a/app/Fluidbook/Compiler/Accessibility.php b/app/Fluidbook/Compiler/Accessibility.php index f7b091bbf..18d06b078 100644 --- a/app/Fluidbook/Compiler/Accessibility.php +++ b/app/Fluidbook/Compiler/Accessibility.php @@ -77,6 +77,7 @@ trait Accessibility ]; $text = trim($data['text']); + $text = preg_replace('/!\[[^)]*\)/', '', $text); $text = str_replace(array_keys($replace), array_values($replace), $text); $text = Text::cleanUTF8($text, ''); @@ -95,6 +96,8 @@ trait Accessibility } $ttsText = Api::stripNonSSMLTags($text); + + $hash = hash('sha256', $engine . ':' . $voice . '_^_' . $ttsText); $fname = $hash . '.mp3'; $dir = Files::mkdir($this->getFluidbook()->protected_path('audiodescription')); @@ -132,7 +135,7 @@ trait Accessibility 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) {