许可协议: mit
标签:
VITS:基于对抗学习的条件变分自编码器端到端文本转语音系统
VITS是一种端到端语音合成模型,能够根据输入文本序列预测对应的语音波形。该模型采用条件变分自编码器(VAE)架构,包含后验编码器、解码器和条件先验模块。本仓库提供在LJ Speech数据集上训练的官方VITS模型权重。
模型详情
VITS(Variational Inference with adversarial learning for end-to-end Text-to-Speech)是基于对抗学习的端到端语音合成模型。其核心架构包含:
- 基于流模型(flow-based module)的频谱特征预测系统:由Transformer文本编码器和多重耦合层构成
- 反卷积层堆栈:采用类似HiFi-GAN声码器的结构进行频谱解码
- 随机时长预测器:针对文本到语音一对多映射特性设计,支持同一文本生成不同节奏的语音
模型通过结合变分下界损失和对抗损失进行端到端训练。在推理阶段,文本编码通过时长预测模块进行上采样,再经由流模块和HiFi-GAN解码器转换为波形。由于时长预测器的随机性,模型具有非确定性,需固定随机种子才能复现相同结果。
数据版本
提供两种训练版本:
使用方式
从🤗 Transformers 4.33版本开始支持该模型:
pip install --upgrade transformers accelerate
from transformers import VitsModel, AutoTokenizer
import torch
model = VitsModel.from_pretrained("kakao-enterprise/vits-ljs")
tokenizer = AutoTokenizer.from_pretrained("kakao-enterprise/vits-ljs")
text = "Hey, it's Hugging Face on the phone"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
output = model(**inputs).waveform
保存或播放音频:
import scipy
scipy.io.wavfile.write("output.wav", rate=model.config.sampling_rate, data=output)
from IPython.display import Audio
Audio(output, rate=model.config.sampling_rate)
引用文献
@inproceedings{kim2021conditional,
title={"Conditional Variational Autoencoder with Adversarial Learning for End-to-end Text-to-speech"},
author={Kim, Jaehyeon and Kong, Jungil and Son, Juhee},
booktitle={ICML},
pages={5530--5540},
year={2021},
organization={PMLR}
}
许可声明
本模型采用MIT许可协议。