]> _ Git - fluidbook-toolbox.git/commitdiff
#7958 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Jan 2026 14:16:00 +0000 (15:16 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Jan 2026 14:16:00 +0000 (15:16 +0100)
app/Fluidbook/Compiler/Accessibility.php

index f7b091bbf97481df36ae48efe94d9e472873b5a9..18d06b078f90a0a38fe9b1e67810761e98f77acf 100644 (file)
@@ -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) {