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.com: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

相关内容

下一步

寻找更精准的朗读AI模型,让中文阅读,更加顺耳

比如讯飞语音的朗读,比这个好听多了….

~~ms-ra-forwarder~~

~~这是一个历史的, 无效的docker, 无法实现语音转化~~

version: '3'

services:
  ms-ra-forwarder:
    container_name: ms-ra-forwarder
    image: wxxxcxx/ms-ra-forwarder:latest
    restart: unless-stopped
    ports:
      - 8104:3000

~~melotts-server 也是无效的~~,无法访问外网的服务器

version: '3'
services:
    melotts-api-server:
        container_name: melotts-server
        ports:
            - 8104:8080
        environment:
            - DEFAULT_SPEED=1
            - DEFAULT_LANGUAGE=ZH
            - DEFAULT_SPEAKER_ID=ZH-Default
        image: timhagel/melotts-api-server
melotts-server  |     raise EnvironmentError(                                                                
melotts-server  | OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find i
t in the cached files and it looks like tohoku-nlp/bert-base-japanese-v3 is not the path to a directory conta
ining a file named config.json.                                                                              
melotts-server  | Checkout your internet connection or see how to run the library in offline mode at 'https:/
/huggingface.co/docs/transformers/installation#offline-mode'.                                                
melotts-server exited with code 1    

灵感来源

https://github.com/parente/espeakbox

https://github.com/kripken/speak.js

手机刷入 防沉迷 系统
小米K40

安卓 屏幕时间管理 app

手机 青少年模式

ChatGPT语音插件

Azure Text to speech API

TTS docker

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注