a webserver for dia-1.6b TTS model
Go to file
2025-05-11 06:34:17 +00:00
app bugfix 2025-05-11 06:30:45 +00:00
conf first commit 2025-05-11 06:06:53 +00:00
logs bugfix 2025-05-11 06:30:45 +00:00
wwwroot/v1/generate first commit 2025-05-11 06:06:53 +00:00
README.md bugfix 2025-05-11 06:34:17 +00:00

TTS小模型

我们创建一个webserver 参考这里提供的安装和代码

import soundfile as sf
from dia.model import Dia

model = Dia.from_pretrained("nari-labs/Dia-1.6B")
text = "[S1] Dia is an open weights text to dialogue model. [S2] You get full control over scripts and voices. [S1] Wow. Amazing. (laughs) [S2] Try it now on Git hub or Hugging Face."
output = model.generate(text)
sf.write("simple.mp3", output, 44100)

上述代码有三个问题

  1. output的类型是np.int64不被audio格式支持

  2. sf.write不支持mp3格式需要换成wav

  3. 生成的wav文件没有语音

目前12问题解决第三个问题依然存在

依赖

模型

  1. https://github.com/descriptinc/descript-audio-codec/releases/download/0.0.1/weights.pth
  2. https://github.com/descriptinc/descript-audio-codec/releases/download/0.0.4/weights_24khz.pth
  3. https://github.com/descriptinc/descript-audio-codec/releases/download/0.0.5/weights_16khz.pth
  4. https://github.com/descriptinc/descript-audio-codec/releases/download/1.0.0/weights_44khz_16kbps.pth

模块

服务方

安装

执行以下命令

git clone https://git.kaiyuancloud.cn/yumoqing/dia16b
cd dia16b
python3 -m venv py3
source py3/bin/activate
pip install git+https://github.com/nari-labs/dia
pip install git+https://git.kaiyuancloud.cn/yumoqing/apppublic
pip install git+https://git.kaiyuancloud.cn/yumoqing/sqlor
pip install git+https://git.kaiyuancloud.cn/yumoqing/ahserver

下载依赖的模型

配置conf/config.json文件

主要修改下载模型存放目录

    "dia_model_path" : "/share/models/nari-labs/dia-1___6b",
    "dac_model_path": "/share/models/dac/weights.pth",