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 = [
'`' => "'",
'“' => '"',
"…" => "...",
];
- $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)) {
}
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';