TTS-Text-to-speech-服务docker搭建-转化文本内容为语音

转化文本内容为语音,TTS,生成中文语音,朗读全文,多语言支持

有什么用

转化文本内容为语音,转化网站内容为语音,朗读,生成中文语音

怎么用

<div> 
<button onclick="synthesizeSpeech()">朗读全文</button>
</div>
<audio controls id="audioPlayer">Your browser does not support the audio element.</audio>      
<script>
  function synthesizeSpeech() { 
    var inputText = document.getElementsByClassName('post-block')[0].innerText;
    var voice = "ZH";
    var url = 'https://tts.carlzeng.top:3/speech?text=' + encodeURIComponent(inputText) + '&voice=' + voice;
    var audioPlayer = document.getElementById('audioPlayer');          
    audioPlayer.src = url;
    audioPlayer.load();
    audioPlayer.play();
  }
</script>
  1. 把以上这个html内容加到html页面中(或者模版中)
  2. 编辑/修改一下inputText的内容来源为需要朗读的文本内容。

实现过程

TTS docker, eSpeak TTS server for WebSpeech

方案有许多,但都不够亲民,或者不支持中文普通话

https://github.com/synesthesiam/opentts
docker run -it -p 5500:5500 synesthesiam/opentts:zh --no-espeak
弊端:不支持中文,无法包含英语

预览全流程 Setup a Text to Speech Engine(ON YOUR COMPUTER)

新的方案:

Text-to-speach server
https://github.com/parente/espeakbox

http://192.168.6.203:8089/speech?text=排查Nginx Proxy Manager,反向代理,让网站变成HTTPS&voice=ZH

Text-to-speach server
https://github.com/parente/espeakbox

Docker的具体位置

https://hub.docker.com/r/parente/espeakbox

posted @ 2024-01-16 09:39  CarlZeng  阅读(146)  评论(0编辑  收藏  举报