From e509653498cc45e5fd1f6ec5cc84fa1d29b4a937 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 22 Jan 2026 15:52:34 +0100 Subject: [PATCH] #7958 @0.25 --- .env.prod | 3 ++- app/Fluidbook/Compiler/Accessibility.php | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.env.prod b/.env.prod index 7ee634b55..f1cdbffb1 100644 --- a/.env.prod +++ b/.env.prod @@ -65,7 +65,8 @@ SCORM_CLOUD_APP_ID=VAAROP2RFR SCORM_CLOUD_SECRET_KEY=7PHpD9pQk4aIjUnlKgF8s89CGlhkIucZHJ3zMXuQ SCORM_CLOUD_PREFIX=toolbox_ -AZURE_TTS_API_KEY=adae11ef11d94aa98f31b2c233c1be7a +AZURE_TTS_API_KEY=8RGdBNPGbrAuWktO5Ge6H1MI3tOUjN1zjAwkji0hYfE0PO1HjSKnJQQJ99CAAC5T7U2XJ3w3AAAYACOG2Ne7 +AZURE_TTS_API_KEY_0=adae11ef11d94aa98f31b2c233c1be7a AZURE_TRANSLATE_API_KEY=cef76c262b9b4eecab57c84695081c67 BACKPACK_LOCALES=en,fr diff --git a/app/Fluidbook/Compiler/Accessibility.php b/app/Fluidbook/Compiler/Accessibility.php index 18d06b078..f5e1355d9 100644 --- a/app/Fluidbook/Compiler/Accessibility.php +++ b/app/Fluidbook/Compiler/Accessibility.php @@ -132,14 +132,25 @@ trait Accessibility protected function _azureTTS($text, $locale, $gender, $voiceName, $output) { + if(!$text){ + return; + } + $api = new \Cubist\Azure\TTS\Api(env('AZURE_TTS_API_KEY')); try { - $api = new \Cubist\Azure\TTS\Api(env('AZURE_TTS_API_KEY')); $api->textToSpeech($text, $locale, $gender, $voiceName, $output); - if (!file_exists($output) || filesize($output) < 100) { - throw new Exception('Error while making tts (' . $output . ') : ' . $text . ', ' . $locale . ', ' . $gender . ', ' . $voiceName); - } } catch (Exception $e) { + $message = $e->getMessage(); } + if (!file_exists($output) || filesize($output) < 100) { + if (file_exists($output)) { + if (!isset($message)) { + $message = file_get_contents($output); + } + unlink($output); + } + throw new Exception('Error while making tts (' . $output . ') : ' . $text . ', ' . $locale . ', ' . $gender . ', ' . $voiceName . ' // ' . ($message ?? "")); + } + } public function getLinkAlternativeText($link, $returnJobs = false) -- 2.39.5