2017-05-30 4 views
0

Est-il possible d'utiliser l'API de synthèse vocale hors ligne? Si oui, puis-je utiliser plusieurs langues ou simplement la langue par défaut? J'ai essayé ce code et il fonctionne en ligne, mais il ne fonctionne pas hors ligne. Comment puis-je le faire fonctionner en ligne?Langages hors ligne de l'API de synthèse vocale

<html> 
    <head> 
     <title>Index</title> 
    </head> 

<p id = "1"></p> 


<script src="../js/jquery-3.2.1.js"></script>   


<script type="text/javascript"> 

    $(document).ready(function() { 
     document.addEventListener("keydown", function (e) { 
      var audio = document.getElementById("myAudio"); 
      if (e.keyCode ===49 || e.keyCode ===97) { //1 is pressed     
      mySpeech(); 
      }    
     }); 
     }) 
    function mySpeech(){ 
     var msg = new SpeechSynthesisUtterance(); 
     var voices = window.speechSynthesis.getVoices(); 
     msg.voiceURI = 'native'; 
     msg.lang = 'it-IT' 
     //msg.voice = voices[$('#voices').val()]; 
     msg.rate = 1; // 0 to 1 
     msg.pitch = 1; // 0 to 2 
     msg.text = "hello world";  
     speechSynthesis.speak(msg); 
    } 

    </script> 

</body> 

Répondre

1

Les seules langues qui fonctionnent en mode hors connexion sont les voix locales du navigateur.