From c2518e7718ce209e1ec204f4c33f8a04906c7efa Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 22 Jan 2026 15:16:00 +0100 Subject: [PATCH] #7958 @0.25 --- app/Fluidbook/Compiler/Accessibility.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { -- 2.39.5