瀏覽器TTS(文本轉語音)


瀏覽器可以將文本轉換成聲音,通過html5的函數實現,支持火狐、谷歌瀏覽器。IE不支持

function speckText(text){
  var speechInstance = new window.SpeechSynthesisUtterance(text);
  speechInstance.lang = 'zh';
  speechInstance.volume = 100; //聲音的音量
  speechInstance.rate = 0.7; //語速,數值,默認值是1,范圍是0.1到10
  speechInstance.pitch = 1.5; // 表示說話的音高,數值,范圍從0(最小)到2(最大)。默認值為1
  window.speechSynthesis.speak(speechInstance);
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM