From: Vincent Vanwaelscappel Date: Tue, 10 Jan 2023 18:39:48 +0000 (+0100) Subject: wait #5674 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2989cf96c145d42c6e39ba94a17e934970a86017;p=fluidbook-toolbox.git wait #5674 @0.25 --- diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index 8915f612c..3edc38821 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -1526,15 +1526,16 @@ height="0" width="0" style="display:none;visibility:hidden"> 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"> "…" => "...", ]; - $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"> } 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';