65 lines
2.1 KiB
Markdown
65 lines
2.1 KiB
Markdown
# TTS小模型
|
||
我们创建一个webserver, 参考[这里](https://huggingface.com/nari-labs/dia-1.6b)提供的安装和代码
|
||
```
|
||
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文件没有语音
|
||
|
||
目前1,2,问题解决,第三个问题依然存在
|
||
|
||
## 依赖
|
||
|
||
### 模型
|
||
* nari-labs/dia-1.6b
|
||
下载地址:https://huggingface.com/nari-labs/dia-1.6b
|
||
|
||
* dac/weights.pth
|
||
下载地址:i
|
||
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
|
||
|
||
### 模块
|
||
服务方
|
||
* [dia](https://github.com/nari-labs/dia)
|
||
* [appPublic](https://git.kaiyuancloud.cn/yumoqing/apppublic)
|
||
* [sqlor](https://git.kaiyuancloud.cn/yumoqing/sqlor)
|
||
* [ahserever](https://git.kaiyuancloud.cn/yumoqing/ahserver)
|
||
客户方
|
||
* [bricks](https://git.kaiyuancloud.cn/yumoqing/bricks)
|
||
|
||
## 安装
|
||
执行以下命令
|
||
```
|
||
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",
|
||
```
|
||
|