拉取官方镜像(大小:4G+)

docker pull ghcr.io/coqui-ai/tts-cpu

首次启动时自动下载tacotron2-DDC-GST(大小:600M+)

docker run --rm -it -p 5002:5002 --entrypoint /bin/bash ghcr.io/coqui-ai/tts-cpu -c "python3 TTS/server/server.py --model_name tts_models/zh-CN/baker/tacotron2-DDC-GST"

或者离线下载tacotron2-DDC-GST到本地
docker run --rm -it -p 5002:5002 -v E:\docker\tts_models:/root/.local/share/tts --entrypoint /bin/bash ghcr.io/coqui-ai/tts-cpu -c "python3 TTS/server/server.py --model_name tts_models/zh-CN/baker/tacotron2-DDC-GST"

调用生成音频内容
curl -X POST "http://localhost:5002/api/tts?text=hello%20world" --output E:\docker\tts-output\hello.wav

命令生成
docker run --rm   -v E:\docker\tts_models:/root/.local/share/tts   -v E:\docker\tts-output:/root/tts-output ghcr.io/coqui-ai/tts-cpu  --text "%E4%BD%A0%E5%A5%BD"  --model_name "tts_models/zh-CN/baker/tacotron2-DDC-GST"  --out_path /root/tts-output/hello.wav

查看所有可用的预训练模型

docker run --rm -it -p 5003:5002 --entrypoint /bin/bash ghcr.io/coqui-ai/tts-cpu -c "python3 TTS/server/server.py --list_models"
 

参数解释

"text": "你好,这是一个文本转语音的测试示例。" #需要转为URL encoding,JavaScript: encodeURIComponent()
"speaker_wav": "path/to/speaker.wav",  # 可选:用于声音克隆的音频文件路径
"language": "zh-cn"                    # 可选:语言代码"language": "zh-cn" ,"en"
"model_name": "tts_models/en/ljspeech/tacotron2-DDC",  # 指定模型
"vocoder_name": "vocoder_models/en/ljspeech/hifigan_v2"  # 指定声码器

报错:

1、curl -X POST http://localhost:5002/api/tts -H "Content-Type: application/json" -d "{\"text\": \"hello world\"}"

会报错:
 File "/root/TTS/utils/synthesizer.py", line 290, in tts
    raise ValueError(
ValueError: You need to define either `text` (for sythesis) or a `reference_wav` (for voice conversion) to use the Coqui TTS API.

2、生成文件内容有重复回音:音频文件12s左右,text的内容太短或者没有加标点符号。

比如“你好。”生成没问题,“你好”生成有问题

参考:

https://blog.csdn.net/knight1287/article/details/142611894

https://github.com/coqui-ai/TTS

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐