]> _ Git - cubeextranet.git/commitdiff
wait #5065 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 31 Jan 2022 18:35:02 +0000 (18:35 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 31 Jan 2022 18:35:02 +0000 (18:35 +0000)
composer.json
inc/commons/class.common.ajax.php
inc/ws/Controlleur/class.ws.droits.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 04d2d8a5521460979360d38a292c40880efa2cf4..b8ea5135629bbfeff0e33a1ecf1a54bcc877b06c 100644 (file)
@@ -12,7 +12,7 @@
   ],\r
 \r
   "require": {\r
-    "php": ">=7.2",\r
+    "php": "7.2.*",\r
     "php-mime-mail-parser/php-mime-mail-parser": "2.11.1",\r
     "jaybizzle/crawler-detect": "^1.2",\r
     "ext-mbstring": "*",\r
index 933690a321c44bea3d232e00c0d4592b542ff59f..a29acc49e799715e4b8ba661ce5a569dca207391 100644 (file)
@@ -594,8 +594,10 @@ Mot de passe : $password";
         $sheet = $phpexcel->getSheet(0);
         $maxRow = $sheet->getHighestRow(0);
 
-
         $updated = 0;
+
+        $add = [];
+
         for ($i = 1; $i <= $maxRow; $i++) {
             $ref = trim($sheet->getCellByColumnAndRow(0, $i));
             $url = trim($sheet->getCellByColumnAndRow(1, $i)->getOldCalculatedValue());
@@ -615,12 +617,21 @@ Mot de passe : $password";
             $fref = self::_formatWsReferenceRef($ref, $_POST['type']);
             $furl = self::_formatWsReferenceUrl($url, $_POST['type']);
 
-            try {
-                $delete = "DELETE FROM wsref WHERE ref='" . $core->con->escape($fref) . "' AND type='" . $core->con->escape($_POST['type']) . "'";
-                $core->con->execute($delete);
-            } catch (Exception $e) {
+            $add[$fref] = $furl;
+        }
+
+        try {
+            $refs = [];
+            foreach ($add as $fref => $furl) {
+                $refs[] = "'" . $core->con->escape($fref) . "'";
             }
 
+            $delete = "DELETE FROM wsref WHERE ref IN(" . implode(',', $refs) . ") AND type='" . $core->con->escape($_POST['type']) . "'";
+            $core->con->execute($delete);
+        } catch (Exception $e) {
+        }
+
+        foreach ($add as $fref => $furl) {
             try {
                 $c = $core->con->openCursor('wsref');
                 $c->type = $_POST['type'];
@@ -632,6 +643,7 @@ Mot de passe : $password";
 
             }
         }
+
         $x->addAlert(sprintf(__('%d liens insérés ou mis à jour'), $updated));
     }
 
index c83a5d7110d51bf18d937abd7bb7a19e969d5cac..44b727aad81c06f482d4668f297c6833e9bc69ea 100644 (file)
@@ -117,6 +117,8 @@ class wsDroits
         $advancedVoices = [\r
             __('ReadSpeaker Sophie (en-US)') => 'readspeaker:Sophie/en_us',\r
             __('ReadSpeaker Marc (en-US)') => 'readspeaker:Marc/en_us',\r
+            __('Azure Denise (fr-FR)') => 'azuretts:fr-FR/Female/fr-FR-DeniseNeural',\r
+            __('Azure Henry (fr-FR)') => 'azuretts:fr-FR/Male/fr-FR-MaleNeural',\r
         ];\r
         if ($rights->creation || $rights->revendeur) {\r
             $res = array_merge($res, $freeVoices);\r
index 5f2775b4c23506ec509ffa62999a4a80553e1ffa..ee0ca3a28feb8d388ea901bb3e9e34fba9dcb8d4 100644 (file)
@@ -1812,6 +1812,13 @@ class wsMaintenance
         }
     }
 
+    public static function azureTTSVoices()
+    {
+        $api = new \Cubist\Azure\TTS\Api('28fdfcdcc7f141b29cd9db4afc5779c5');
+        print_r($api->listVoices());
+
+    }
+
 }
 
 
index d633ca3ddd0c8dde74dcc01597851c8824596fac..5f499dfed860c76af866a490b96029fa66b3d162 100644 (file)
@@ -227,6 +227,7 @@ class wsHTML5Compiler
     public $accessibleTexts = [];
     protected $_svgSymbols = [];
     protected $_addedPDFJS = false;
+    protected $audioDescriptionTextsList = [];
 
     protected $_docDimensions = [];
 
@@ -1213,33 +1214,42 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
     protected function writeAccessibility()
     {
-        if (!$this->book->parametres->audiodescriptionTexts) {
-            return;
-        }
-        $file = $this->wdir . '/' . $this->book->parametres->audiodescriptionTexts;
-        new PHPExcel();
-        $reader = new PHPExcel_Reader_Excel2007();
-        $phpexcel = $reader->load($file);
+        if ($this->book->parametres->audiodescriptionTexts) {
 
-        $sheet = $phpexcel->getActiveSheet();
-        $maxRow = $sheet->getHighestRow(0);
+            $file = $this->wdir . '/' . $this->book->parametres->audiodescriptionTexts;
+            if (file_exists($file)) {
+                new PHPExcel();
+                $reader = new PHPExcel_Reader_Excel2007();
+                $phpexcel = $reader->load($file);
 
-        for ($i = 0; $i <= $maxRow; $i++) {
-            $page = trim($sheet->getCellByColumnAndRow(0, $i)->getValue());
-            $text = trim($sheet->getCellByColumnAndRow(1, $i)->getValue());
-            if ($page == '' || $text == '') {
-                continue;
+                $sheet = $phpexcel->getActiveSheet();
+                $maxRow = $sheet->getHighestRow(0);
+
+                for ($i = 0; $i <= $maxRow; $i++) {
+                    $page = trim($sheet->getCellByColumnAndRow(0, $i)->getValue());
+                    $text = trim($sheet->getCellByColumnAndRow(1, $i)->getValue());
+                    if ($page == '' || $text == '') {
+                        continue;
+                    }
+                    $this->audioDescriptionTextsList[$page] = $text;
+                }
             }
+        }
 
-            $replace = ['`' => "'",
+        foreach ($this->audioDescriptionTextsList as $page => $text) {
+            $replace = [
+                '`' => "'",
                 '“' => '"',
                 '”' => '"',
                 '’' => "'",
                 '—' => " - ",
                 '‘' => "'",
+                "…" => "...",
             ];
 
+            $text = trim($text);
             $text = str_replace(array_keys($replace), array_values($replace), $text);
+            $text = CubeIT_Text::cleanUTF8($text, '');
 
             if ($this->book->parametres->audiodescriptionVoice) {
                 $hash = hash('sha256', $this->book->parametres->audiodescriptionVoice . '_^_' . $text);
@@ -1250,9 +1260,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 }
 
                 $file = $dir . $fname;
-                if (!file_exists($file)) {
+
+                if ($this->book_id === '18860' && file_exists($file)) {
+                    unlink($file);
+                }
+
+                if (!file_exists($file) || filesize($file) === 0) {
                     $e = explode(':', $this->book->parametres->audiodescriptionVoice);
 
+
                     $engine = $e[0];
                     $voice = $e[1];
 
@@ -1270,6 +1286,9 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                     } else if ($engine == 'readspeaker') {
                         $e = explode('/', $voice);
                         $this->_readSpeaker($text, $e[1], $e[0], $file);
+                    } else if ($engine == 'azuretts') {
+                        $e = explode('/', $voice);
+                        $this->_azureTTS($text, $e[0], $e[1], $e[2], $file);
                     }
                 }
 
@@ -1285,6 +1304,17 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         }
     }
 
+
+    protected function _azureTTS($text, $locale, $gender, $voiceName, $output)
+    {
+        try {
+            $api = new \Cubist\Azure\TTS\Api('28fdfcdcc7f141b29cd9db4afc5779c5');
+            $api->textToSpeech($text, $locale, $gender, $voiceName, $output);
+        } catch (Exception $e) {
+            dd($e);
+        }
+    }
+
     protected function _readSpeaker($text, $language, $voice, $output)
     {
         $text_to_read = urlencode($text);
@@ -2290,8 +2320,18 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
     public function addAudiodescription($link)
     {
-        $this->config->audiodescription[$link['page']] = $link['to'];
-        $this->copyLinkFile($link['to'], 'data/audiodescription/');
+
+        $e = explode('.', $link['to']);
+        $ext = mb_strtolower(array_pop($e));
+        if ($ext === 'txt') {
+            $file = $this->wdir . '/' . $link['to'];
+            if (file_exists($file)) {
+                $this->audioDescriptionTextsList[$link['page']] = file_get_contents($file);
+            }
+        } else {
+            $this->config->audiodescription[$link['page']] = $link['to'];
+            $this->copyLinkFile($link['to'], 'data/audiodescription/');
+        }
     }
 
     protected function beforeWriteConfig()