Home

Awesome

<div align="center">

StableTTS

Next-generation TTS model using flow-matching and DiT, inspired by Stable Diffusion 3.

</div>

Introduction

As the first open-source TTS model that tried to combine flow-matching and DiT, StableTTS is a fast and lightweight TTS model for chinese, english and japanese speech generation. It has 31M parameters.

✨ Huggingface demo: πŸ€—

News

2024/10: A new autoregressive TTS model is coming soon...

2024/9: πŸš€ StableTTS V1.1 Released ⭐ Audio quality is largely improved ⭐

⭐ V1.1 Release Highlights:

Pretrained models

Text-To-Mel model

Download and place the model in the ./checkpoints directory, it is ready for inference, finetuning and webui.

Model NameTask DetailsDatasetDownload Link
StableTTStext to mel600 hoursπŸ€—

Mel-To-Wav model

Choose a vocoder (vocos or firefly-gan ) and place it in the ./vocoders/pretrained directory.

Model NameTask DetailsDatasetDownload Link
Vocosmel to wav2k hoursπŸ€—
firefly-gan-basemel to wavHiFi-16khdownload from fishaudio

Installation

  1. Install pytorch: Follow the official PyTorch guide to install pytorch and torchaudio. We recommend the latest version (tested with PyTorch 2.4 and Python 3.12).

  2. Install Dependencies: Run the following command to install the required Python packages:

pip install -r requirements.txt

Inference

For detailed inference instructions, please refer to inference.ipynb

We also provide a webui based on gradio, please refer to webui.py

Training

StableTTS is designed to be trained easily. We only need text and audio pairs, without any speaker id or extra feature extraction. Here’s how to get started:

Preparing Your Data

  1. Generate Text and Audio pairs: Generate the text and audio pair filelist as ./filelists/example.txt. Some recipes of open-source datasets could be found in ./recipes.

  2. Run Preprocessing: Adjust the DataConfig in preprocess.py to set your input and output paths, then run the script. This will process the audio and text according to your list, outputting a JSON file with paths to mel features and phonemes.

Note: Process multilingual data separately by changing the language setting in DataConfig

Start training

  1. Adjust Training Configuration: In config.py, modify TrainConfig to set your file list path and adjust training parameters (such as batch_size) as needed.

  2. Start the Training Process: Launch train.py to start training your model.

Note: For finetuning, download the pretrained model and place it in the model_save_path directory specified in TrainConfig. Training script will automatically detect and load the pretrained checkpoint.

(Optional) Vocoder training

The ./vocoder/vocos folder contains the training and finetuning codes for vocos vocoder.

For other types of vocoders, we recommend to train by using fishaudio vocoder: an uniform interface for developing various vocoders. We use the same spectrogram transform so the vocoders trained is compatible with StableTTS.

Model structure

<div align="center"> <p style="text-align: center;"> <img src="./figures/structure.jpg" height="512"/> </p> </div>

References

The development of our models heavily relies on insights and code from various projects. We express our heartfelt thanks to the creators of the following:

Direct Inspirations

Matcha TTS: Essential flow-matching code.

Grad TTS: Diffusion model structure.

Stable Diffusion 3: Idea of combining flow-matching and DiT.

Vits: Code style and MAS insights, DistributedBucketSampler.

Additional References:

plowtts-pytorch: codes of MAS in training

Bert-VITS2 : numba version of MAS and modern pytorch codes of Vits

fish-speech: dataclass usage and mel-spectrogram transforms using torchaudio, gradio webui

gpt-sovits: melstyle encoder for voice clone

coqui xtts: gradio webui

Chinese Dirtionary Of DiffSinger: Multi-langs_Dictionary and atonyxu's fork

TODO

Disclaimer

Any organization or individual is prohibited from using any technology in this repo to generate or edit someone's speech without his/her consent, including but not limited to government leaders, political figures, and celebrities. If you do not comply with this item, you could be in violation of copyright laws.