]> _ Git - cubeextranet.git/commitdiff
wip #3747 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 30 Jun 2020 11:12:32 +0000 (11:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 30 Jun 2020 11:12:32 +0000 (11:12 +0000)
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index c6a78da36356e421dc1b7e0cc639e7a69594ceed..7b35ccecce1f6f03fdccc7e6d5936ed8fbb88048 100644 (file)
@@ -461,8 +461,8 @@ class wsBookParametres extends wsParametres
         $this->fields['product_tweet'] = array('type' => 'textarea', 'default' => '%short%', 'editable' => true, 'label' => __("Contenu Partage court"), 'hint' => __('Contenu du partagé sur les partages courts'));
         $this->forms['product_zoom'] = ['label' => __('Zooms produits'), 'fieldsnames' => array_merge(["product_zoom_references", '|', 'product_zoom_buttons_order'], $f, ['|', 'product_share_enabled', 'product_share_link', 'product_email_title', 'product_email_body', 'product_tweet'])];
 
-        $this->fields['audiodescriptionTexts'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Contenus textuels pour l\'audiodescription'), 'fileFilter' => $seoFilter];
-        $this->fields['audiodescriptionVoice'] = ['type' => 'combo', 'datas' => wsDroits::getTTSVoices(), 'editable' => true, 'default' => true, 'label' => __('Voix pour l\'audiodescription')];
+        $this->fields['audiodescriptionTexts'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Contenus textuels pour l\'audiodescription ou les lecteurs d\'écran'), 'fileFilter' => $seoFilter];
+        $this->fields['audiodescriptionVoice'] = ['type' => 'combo', 'datas' => wsDroits::getTTSVoices(), 'editable' => true, 'default' => '', 'label' => __('Voix pour l\'audiodescription')];
         $this->forms['accessibility'] = ['label' => __('Accessibilité'),
             'fieldsnames' => ['audiodescriptionTexts', 'audiodescriptionVoice']
         ];
@@ -709,8 +709,5 @@ class wsBookParametres extends wsParametres
 
         $this->forms['downloads'] = array('label' => __('Versions disponibles au téléchargement'),
             'fieldsnames' => $fields);
-
-
     }
-
 }
index 73dc8b0d8c6422d3fd4c5b3ff15e50bc700e1d35..b67d731961af7d24a3ef0f9691462d0740294f4d 100644 (file)
@@ -703,7 +703,7 @@ class wsHTML5Compiler
 
     protected function writeAccessibility()
     {
-        if ($this->book->parametres->audiodescriptionTexts == '' || $this->book->parametres->audiodescriptionVoice == '') {
+        if (!$this->book->parametres->audiodescriptionTexts) {
             return;
         }
         $file = $this->wdir . '/' . $this->book->parametres->audiodescriptionTexts;
@@ -731,39 +731,41 @@ class wsHTML5Compiler
 
             $text = str_replace(array_keys($replace), array_values($replace), $text);
 
-            $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text);
-            $fname = $hash . '.mp3';
-            $dir = WS_BOOKS . '/audiodescription/';
-            if (!file_exists($dir)) {
-                mkdir($dir, 0777, true);
-            }
+            if( $this->book->parametres->audiodescriptionVoice) {
+                $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text);
+                $fname = $hash . '.mp3';
+                $dir = WS_BOOKS . '/audiodescription/';
+                if (!file_exists($dir)) {
+                    mkdir($dir, 0777, true);
+                }
 
-            $file = $dir . $fname;
-            if (!file_exists($file)) {
-                $e = explode(':', $this->book->parametres->audiodescriptionVoice);
+                $file = $dir . $fname;
+                if (!file_exists($file)) {
+                    $e = explode(':', $this->book->parametres->audiodescriptionVoice);
 
-                $engine = $e[0];
-                $voice = $e[1];
+                    $engine = $e[0];
+                    $voice = $e[1];
 
-                if ($engine == 'festival') {
-                    $tmp = CubeIT_Files::tempnam() . '.wav';
-                    $tmptext = CubeIT_Files::tempnam() . '.txt';
+                    if ($engine == 'festival') {
+                        $tmp = CubeIT_Files::tempnam() . '.wav';
+                        $tmptext = CubeIT_Files::tempnam() . '.txt';
 
-                    file_put_contents($tmptext, $text);
-                    $cmd = "text2wave -o $tmp $tmptext -eval \"($voice)\"";
-                    `$cmd`;
+                        file_put_contents($tmptext, $text);
+                        $cmd = "text2wave -o $tmp $tmptext -eval \"($voice)\"";
+                        `$cmd`;
 
-                    `lame $tmp $file`;
-                    unlink($tmp);
-                    unlink($tmptext);
-                } else if ($engine == 'readspeaker') {
-                    $e = explode('/', $voice);
-                    $this->_readSpeaker($text, $e[1], $e[0], $file);
+                        `lame $tmp $file`;
+                        unlink($tmp);
+                        unlink($tmptext);
+                    } else if ($engine == 'readspeaker') {
+                        $e = explode('/', $voice);
+                        $this->_readSpeaker($text, $e[1], $e[0], $file);
+                    }
                 }
-            }
 
-            $this->config->audiodescription[$page] = $fname;
-            $this->vdir->copy($file, 'data/audiodescription/' . $fname);
+                $this->config->audiodescription[$page] = $fname;
+                $this->vdir->copy($file, 'data/audiodescription/' . $fname);
+            }
         }
     }