]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5674 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Jan 2023 18:39:48 +0000 (19:39 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Jan 2023 18:39:48 +0000 (19:39 +0100)
app/Jobs/FluidbookCompiler.php

index 8915f612c364b37e1ec0699a434181b2832fc57a..3edc388215dc31a536ff595b72863a72b6e3fb9b 100644 (file)
@@ -1526,15 +1526,16 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 for ($i = 0; $i <= $maxRow; $i++) {
                     $page = trim($sheet->getCellByColumnAndRow(0, $i)->getValue());
                     $text = trim($sheet->getCellByColumnAndRow(1, $i)->getValue());
+                    $voice = trim($sheet->getCellByColumnAndRow(2, $i)->getValue());
                     if ($page == '' || $text == '') {
                         continue;
                     }
-                    $this->audioDescriptionTextsList[$page] = $text;
+                    $this->audioDescriptionTextsList[$page] = ['text' => $text, 'voice' => $voice];
                 }
             }
         }
 
-        foreach ($this->audioDescriptionTextsList as $page => $text) {
+        foreach ($this->audioDescriptionTextsList as $page => $data) {
             $replace = [
                 '`' => "'",
                 '“' => '"',
@@ -1545,12 +1546,14 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 "…" => "...",
             ];
 
-            $text = trim($text);
+            $text = trim($data['text']);
             $text = str_replace(array_keys($replace), array_values($replace), $text);
             $text = Text::cleanUTF8($text, '');
 
-            if ($this->fluidbookSettings->audiodescriptionVoice) {
-                $hash = hash('sha256', $this->fluidbookSettings->audiodescriptionVoice . '_^_' . $text);
+            $voiceInfos = $data['voice'] ? !$this->fluidbookSettings->audiodescriptionVoice;
+
+            if ($voiceInfos) {
+                $hash = hash('sha256', $voiceInfos . '_^_' . $text);
                 $fname = $hash . '.mp3';
                 $dir = WS_BOOKS . '/audiodescription/';
                 if (!file_exists($dir)) {
@@ -1564,11 +1567,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 }
 
                 if (!file_exists($file) || filesize($file) === 0) {
-                    $e = explode(':', $this->fluidbookSettings->audiodescriptionVoice);
-
+                    $e = explode(':', $voiceInfos);s
 
-                    $engine = $e[0];
-                    $voice = $e[1];
+                    if (count($e) === 1) {
+                        $engine = 'azuretts';
+                        $voice = $voiceInfos;
+                    } else {
+                        $engine = $e[0];
+                        $voice = $e[1];
+                    }
 
                     if ($engine == 'festival') {
                         $tmp = Files::tempnam() . '.wav';