A fast Text-to-Speech (TTS) model. Work well for English, Mandarin/Chinese, Japanese, Korean, Russian and Tibetan (so far). 快速语音合成模型,适用于英语、普通话/中文、日语、韩语、俄语和藏语(当前已测试)。
简体中文 | English
[TOC]
.
|--- config/ # 配置文件
|--- default.yaml
|--- ...
|--- datasets/ # 数据处理
|--- encoder/ # 声纹编码器
|--- voice_encoder.py
|--- ...
|--- helpers/ # 一些辅助类
|--- trainer.py
|--- synthesizer.py
|--- ...
|--- logdir/ # 训练过程保存目录
|--- losses/ # 一些损失函数
|--- models/ # 合成模型
|--- layers.py
|--- duration.py
|--- parallel.py
|--- pretrained/ # 预训练模型(LJSpeech 数据集)
|--- samples/ # 合成样例
|--- utils/ # 一些通用方法
|--- vocoder/ # 声码器
|--- melgan.py
|--- ...
|--- wandb/ # Wandb 保存目录
|--- extract-duration.py
|--- extract-embedding.py
|--- LICENSE
|--- prepare-dataset.py # 准备脚本
|--- README.md
|--- README_en.md
|--- requirements.txt # 依赖文件
|--- synthesize.py # 合成脚本
|--- train-duration.py # 训练脚本
|--- train-parallel.py
部分合成样例见这里。
部分预训练模型见这里。
步骤(1):克隆仓库
$ git clone https://github.com/atomicoo/ParallelTTS.git
步骤(2):安装依赖
$ conda create -n ParallelTTS python=3.7.9
$ conda activate ParallelTTS
$ pip install -r requirements.txt
步骤(3):合成语音
$ python synthesize.py \
--checkpoint ./pretrained/ljspeech-parallel-epoch0100.pth \
--melgan_checkpoint ./pretrained/ljspeech-melgan-epoch3200.pth \
--input_texts ./samples/english/synthesize.txt \
--outputs_dir ./outputs/
如果要合成其他语种的语音,需要通过 --config
指定相应的配置文件。
步骤(1):准备数据
$ python prepare-dataset.py
通过 --config
可以指定配置文件,默认的 default.yaml
针对 LJSpeech 数据集。
步骤(2):训练对齐模型
$ python train-duration.py
步骤(3):提取持续时间
$ python extract-duration.py
通过 --ground_truth
可以指定是否利用对齐模型生成 Ground-Truth 声谱图。
步骤(4):训练合成模型
$ python train-parallel.py
通过 --ground_truth
可以指定是否使用 Ground-Truth 声谱图进行模型训练。
如果使用 TensorBoardX,则运行如下命令:
$ tensorboard --logdir logdir/[DIR]/
强烈推荐使用 Wandb(Weights & Biases),只需在上述训练命令中增加 --enable_wandb
选项。
TODO:待补充
训练速度:对于 LJSpeech 数据集,设置批次尺寸为 64,可以在单张 8GB 显存的 GTX 1080 显卡上进行训练,训练 ~8h(~300 epochs)后即可合成质量较高的语音。
合成速度:以下测试在 CPU @ Intel Core i7-8550U / GPU @ NVIDIA GeForce MX150 下进行,每段合成音频在 8 秒左右(约 20 词)
批次尺寸 | Spec (GPU) |
Audio (GPU) |
Spec (CPU) |
Audio (CPU) |
---|---|---|---|---|
1 | 0.042 | 0.218 | 0.100 | 2.004 |
2 | 0.046 | 0.453 | 0.209 | 3.922 |
4 | 0.053 | 0.863 | 0.407 | 7.897 |
8 | 0.062 | 2.386 | 0.878 | 14.599 |
注意,没有进行多次测试取平均值,结果仅供参考。
vocoder
代码取自 ParallelWaveGAN,由于声学特征提取方式不兼容,需要进行转化,具体转化代码见这里。