TTS/README.md

272 lines
14 KiB
Markdown
Raw Normal View History

# <img src="https://raw.githubusercontent.com/coqui-ai/TTS/main/images/coqui-log-green-TTS.png" height="56"/>
2020-07-17 10:37:18 +00:00
2021-03-09 15:39:17 +00:00
🐸TTS is a library for advanced Text-to-Speech generation. It's built on the latest research, was designed to achieve the best trade-off among ease-of-training, speed and quality.
🐸TTS comes with [pretrained models](https://github.com/coqui-ai/TTS/wiki/Released-Models), tools for measuring dataset quality and already used in **20+ languages** for products and research projects.
2019-07-19 10:37:35 +00:00
2021-03-13 00:03:50 +00:00
[![CircleCI](https://github.com/coqui-ai/TTS/actions/workflows/main.yml/badge.svg)]()
2021-01-06 13:46:28 +00:00
[![License](<https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg>)](https://opensource.org/licenses/MPL-2.0)
2021-01-26 02:20:24 +00:00
[![PyPI version](https://badge.fury.io/py/TTS.svg)](https://badge.fury.io/py/TTS)
2021-03-07 02:58:46 +00:00
[![Covenant](https://camo.githubusercontent.com/7d620efaa3eac1c5b060ece5d6aacfcc8b81a74a04d05cd0398689c01c4463bb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6e7472696275746f72253230436f76656e616e742d76322e3025323061646f707465642d6666363962342e737667)](https://github.com/coqui-ai/TTS/blob/master/CODE_OF_CONDUCT.md)
2021-03-13 00:06:51 +00:00
[![Gitter](https://badges.gitter.im/coqui-ai/TTS.svg)](https://gitter.im/coqui-ai/TTS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
2020-07-17 10:37:18 +00:00
2021-03-18 13:57:08 +00:00
📰 [**Subscribe to 🐸Coqui.ai Newsletter**](https://coqui.ai/?subscription=true)
2021-03-18 12:13:42 +00:00
📢 [English Voice Samples](https://erogol.github.io/ddc-samples/) and [SoundCloud playlist](https://soundcloud.com/user-565970875/pocket-article-wavernn-and-tacotron2)
2018-01-22 09:48:59 +00:00
2021-03-18 12:13:42 +00:00
👩🏽‍🍳 [TTS training recipes](https://github.com/erogol/TTS_recipes)
2020-07-10 09:10:57 +00:00
📄 [Text-to-Speech paper collection](https://github.com/erogol/TTS-papers)
2020-10-15 01:49:39 +00:00
2021-01-06 13:46:28 +00:00
## 💬 Where to ask questions
Please use our dedicated channels for questions and discussion. Help is much more valuable if it's shared publicly, so that more people can benefit from it.
2018-01-22 09:48:59 +00:00
2021-01-06 13:46:28 +00:00
| Type | Platforms |
| ------------------------------- | --------------------------------------- |
| 🚨 **Bug Reports** | [GitHub Issue Tracker] |
2021-03-18 12:13:42 +00:00
| ❔ **FAQ** | [TTS/Wiki](https://github.com/coqui-ai/TTS/wiki/FAQ) |
2021-01-11 01:12:08 +00:00
| 🎁 **Feature Requests & Ideas** | [GitHub Issue Tracker] |
2021-03-13 00:06:51 +00:00
| 👩‍💻 **Usage Questions** | [Github Discussions] |
2021-03-18 12:13:42 +00:00
| 🗯 **General Discussion** | [Github Discussions] or [Gitter Room] or [Matrix Room] |
2020-05-20 15:51:42 +00:00
2021-03-05 01:46:33 +00:00
[github issue tracker]: https://github.com/coqui-ai/tts/issues
[github discussions]: https://github.com/coqui-ai/TTS/discussions
2021-03-13 00:06:51 +00:00
[gitter room]: https://gitter.im/coqui-ai/TTS?utm_source=share-link&utm_medium=link&utm_campaign=share-link
2021-03-14 15:47:48 +00:00
[matrix room]: https://matrix.to/#/!KTePhNahjgiVumkqca:matrix.org?via=matrix.org&via=bethselamin.de&via=lossy.network
2021-03-05 01:46:33 +00:00
[Tutorials and Examples]: https://github.com/coqui-ai/TTS/wiki/TTS-Notebooks-and-Tutorials
2021-01-06 13:46:28 +00:00
2021-01-11 01:12:08 +00:00
## 🔗 Links and Resources
| Type | Links |
| ------------------------------- | --------------------------------------- |
2021-03-05 01:46:33 +00:00
| 💾 **Installation** | [TTS/README.md](https://github.com/coqui-ai/TTS/tree/dev#install-tts)|
| 👩🏾‍🏫 **Tutorials and Examples** | [TTS/Wiki](https://github.com/coqui-ai/TTS/wiki/TTS-Notebooks-and-Tutorials) |
2021-03-22 15:31:17 +00:00
| 🚀 **Released Models** | [TTS Releases](https://github.com/coqui-ai/TTS/releases) and [Experimental Models](https://github.com/coqui-ai/TTS/wiki/Experimental-Released-Models)|
2021-03-05 01:46:33 +00:00
| 💻 **Docker Image** | [Repository by @synesthesiam](https://github.com/synesthesiam/docker-coqui-aitts)|
| 🖥️ **Demo Server** | [TTS/server](https://github.com/coqui-ai/TTS/tree/master/TTS/server)|
2021-03-18 12:13:42 +00:00
| 🤖 **Synthesize speech** | [TTS/README.md](https://github.com/coqui-ai/TTS#example-synthesizing-speech-on-terminal-using-the-released-models)|
2021-01-11 01:12:08 +00:00
2021-03-05 01:59:52 +00:00
## 🥇 TTS Performance
<p align="center"><img src="https://raw.githubusercontent.com/coqui-ai/TTS/main/images/TTS-performance.png" width="800" /></p>
2019-04-30 22:56:58 +00:00
2021-03-09 15:39:17 +00:00
Underlined "TTS*" and "Judy*" are 🐸TTS models
2021-03-05 01:59:52 +00:00
<!-- [Details...](https://github.com/coqui-ai/TTS/wiki/Mean-Opinion-Score-Results) -->
2019-04-30 22:56:58 +00:00
2020-05-20 14:44:52 +00:00
## Features
2020-07-15 09:08:35 +00:00
- High performance Deep Learning models for Text2Speech tasks.
2021-01-13 10:14:59 +00:00
- Text2Spec models (Tacotron, Tacotron2, Glow-TTS, SpeedySpeech).
2020-06-04 12:26:51 +00:00
- Speaker Encoder to compute speaker embeddings efficiently.
2021-01-13 10:14:59 +00:00
- Vocoder models (MelGAN, Multiband-MelGAN, GAN-TTS, ParallelWaveGAN, WaveGrad, WaveRNN)
2020-06-19 12:52:43 +00:00
- Fast and efficient model training.
- Detailed training logs on console and Tensorboard.
2020-07-15 09:08:35 +00:00
- Support for multi-speaker TTS.
- Efficient Multi-GPUs training.
- Ability to convert PyTorch models to Tensorflow 2.0 and TFLite for inference.
- Released models in PyTorch, Tensorflow and TFLite.
2020-05-20 14:44:52 +00:00
- Tools to curate Text2Speech datasets under```dataset_analysis```.
- Demo server for model testing.
- Notebooks for extensive model benchmarking.
- Modular (but not too much) code base enabling easy testing for new ideas.
2019-12-11 10:02:39 +00:00
2021-01-06 13:46:28 +00:00
## Implemented Models
### Text-to-Spectrogram
- Tacotron: [paper](https://arxiv.org/abs/1703.10135)
- Tacotron2: [paper](https://arxiv.org/abs/1712.05884)
- Glow-TTS: [paper](https://arxiv.org/abs/2005.11129)
2021-01-12 15:32:15 +00:00
- Speedy-Speech: [paper](https://arxiv.org/abs/2008.03802)
2021-01-06 13:46:28 +00:00
### Attention Methods
- Guided Attention: [paper](https://arxiv.org/abs/1710.08969)
- Forward Backward Decoding: [paper](https://arxiv.org/abs/1907.09006)
- Graves Attention: [paper](https://arxiv.org/abs/1907.09006)
- Double Decoder Consistency: [blog](https://erogol.com/solving-attention-problems-of-tts-models-with-double-decoder-consistency/)
### Speaker Encoder
- GE2E: [paper](https://arxiv.org/abs/1710.10467)
2021-01-12 15:32:15 +00:00
- Angular Loss: [paper](https://arxiv.org/pdf/2003.11982.pdf)
2018-07-11 15:40:30 +00:00
2021-01-06 13:46:28 +00:00
### Vocoders
2021-02-04 05:06:39 +00:00
- MelGAN: [paper](https://arxiv.org/abs/1910.06711)
2021-01-06 13:46:28 +00:00
- MultiBandMelGAN: [paper](https://arxiv.org/abs/2005.05106)
- ParallelWaveGAN: [paper](https://arxiv.org/abs/1910.11480)
- GAN-TTS discriminators: [paper](https://arxiv.org/abs/1909.11646)
- WaveRNN: [origin](https://github.com/fatchord/WaveRNN/)
- WaveGrad: [paper](https://arxiv.org/abs/2009.00713)
2018-09-27 13:10:15 +00:00
2021-03-09 15:39:17 +00:00
You can also help us implement more models. Some 🐸TTS related work can be found [here](https://github.com/erogol/TTS-papers).
2018-09-27 13:10:15 +00:00
2021-01-06 13:46:28 +00:00
## Install TTS
2021-03-09 15:39:17 +00:00
🐸TTS is tested on Ubuntu 18.04 with **python >= 3.6, < 3.9**.
2018-09-27 13:10:15 +00:00
2021-03-09 15:39:17 +00:00
If you are only interested in [synthesizing speech](https://github.com/coqui-ai/TTS/tree/dev#example-synthesizing-speech-on-terminal-using-the-released-models) with the released 🐸TTS models, installing from PyPI is the easiest option.
2021-01-26 02:06:58 +00:00
2021-01-27 10:26:38 +00:00
```bash
2021-01-26 02:08:45 +00:00
pip install TTS
```
2021-01-26 02:06:58 +00:00
2021-03-09 15:39:17 +00:00
If you plan to code or train models, clone 🐸TTS and install it locally.
2021-01-26 02:06:58 +00:00
2021-01-27 10:26:38 +00:00
```bash
2021-03-05 01:46:33 +00:00
git clone https://github.com/coqui-ai/TTS
2021-01-26 02:08:45 +00:00
pip install -e .
```
2018-09-27 13:10:15 +00:00
2021-03-08 13:05:39 +00:00
We use ```espeak-ng``` to convert graphemes to phonemes. You might need to install separately.
2021-02-01 11:26:21 +00:00
```bash
2021-03-08 13:05:39 +00:00
sudo apt-get install espeak-ng
2021-02-01 11:26:21 +00:00
```
2021-01-11 01:12:08 +00:00
## Directory Structure
2020-06-19 13:56:02 +00:00
```
2020-07-17 10:50:20 +00:00
|- notebooks/ (Jupyter Notebooks for model evaluation, parameter selection and data analysis.)
|- utils/ (common utilities.)
2020-07-17 10:56:42 +00:00
|- TTS
|- bin/ (folder for all the executables.)
|- train*.py (train your target model.)
|- distribute.py (train your TTS model using Multiple GPUs.)
|- compute_statistics.py (compute dataset statistics for normalization.)
|- convert*.py (convert target torch model to TF.)
|- tts/ (text to speech models)
|- layers/ (model layer definitions)
|- models/ (model definitions)
|- tf/ (Tensorflow 2 utilities and model implementations)
|- utils/ (model specific utilities.)
|- speaker_encoder/ (Speaker Encoder models.)
|- (same)
|- vocoder/ (Vocoder models.)
|- (same)
2020-06-19 13:56:02 +00:00
```
2020-07-17 10:56:42 +00:00
## Sample Model Output
2019-05-28 12:25:02 +00:00
Below you see Tacotron model state after 16K iterations with batch-size 32 with LJSpeech dataset.
2018-09-27 13:10:15 +00:00
2018-09-27 13:27:08 +00:00
> "Recent research at Harvard has shown meditating for as little as 8 weeks can actually increase the grey matter in the parts of the brain responsible for emotional regulation and learning."
2018-09-27 13:10:15 +00:00
2020-02-26 15:14:10 +00:00
Audio examples: [soundcloud](https://soundcloud.com/user-565970875/pocket-article-wavernn-and-tacotron2)
2018-09-27 13:47:13 +00:00
2019-09-10 10:32:37 +00:00
<img src="images/example_model_output.png?raw=true" alt="example_output" width="400"/>
2018-09-27 13:10:15 +00:00
2018-12-18 00:30:15 +00:00
## Datasets and Data-Loading
2021-03-09 15:39:17 +00:00
🐸TTS provides a generic dataloader easy to use for your custom dataset.
2020-07-17 10:37:18 +00:00
You just need to write a simple function to format the dataset. Check ```datasets/preprocess.py``` to see some examples.
2020-07-15 09:20:23 +00:00
After that, you need to set ```dataset``` fields in ```config.json```.
2018-12-18 00:30:15 +00:00
2021-03-09 15:39:17 +00:00
Some of the public datasets that we successfully applied 🐸TTS:
2018-01-26 11:05:24 +00:00
- [LJ Speech](https://keithito.com/LJ-Speech-Dataset/)
- [Nancy](http://www.cstr.ed.ac.uk/projects/blizzard/2011/lessac_blizzard2011/)
2019-05-16 16:34:05 +00:00
- [TWEB](https://www.kaggle.com/bryanpark/the-world-english-bible-speech-dataset)
2019-01-21 14:05:16 +00:00
- [M-AI-Labs](http://www.caito.de/2019/01/the-m-ailabs-speech-dataset/)
2019-07-11 13:36:25 +00:00
- [LibriTTS](https://openslr.org/60/)
2019-09-20 10:41:20 +00:00
- [Spanish](https://drive.google.com/file/d/1Sm_zyBo67XHkiFhcRSQ4YaHPYM0slO_e/view?usp=sharing) - thx! @carlfm01
2018-01-22 09:48:59 +00:00
2021-01-22 01:30:32 +00:00
## Example: Synthesizing Speech on Terminal Using the Released Models.
2021-03-09 15:39:17 +00:00
After the installation, 🐸TTS provides a CLI interface for synthesizing speech using pre-trained models. You can either use your own model or the release models under 🐸TTS.
2021-01-22 01:30:32 +00:00
2021-03-09 15:39:17 +00:00
Listing released 🐸TTS models.
2021-01-27 10:26:38 +00:00
```bash
2021-01-27 10:21:50 +00:00
tts --list_models
```
2021-01-22 01:30:32 +00:00
Run a tts and a vocoder model from the released model list. (Simply copy and paste the full model names from the list as arguments for the command below.)
2021-01-27 10:26:38 +00:00
```bash
2021-01-27 10:21:50 +00:00
tts --text "Text for TTS" \
--model_name "<type>/<language>/<dataset>/<model_name>" \
--vocoder_name "<type>/<language>/<dataset>/<model_name>" \
--out_path folder/to/save/output/
```
2021-01-22 01:30:32 +00:00
Run your own TTS model (Using Griffin-Lim Vocoder)
2021-01-27 10:26:38 +00:00
```bash
2021-01-27 10:21:50 +00:00
tts --text "Text for TTS" \
--model_path path/to/model.pth.tar \
--config_path path/to/config.json \
--out_path output/path/speech.wav
```
2021-01-22 01:30:32 +00:00
Run your own TTS and Vocoder models
2021-01-27 10:26:38 +00:00
```bash
2021-01-27 10:21:50 +00:00
tts --text "Text for TTS" \
--model_path path/to/config.json \
--config_path path/to/model.pth.tar \
--out_path output/path/speech.wav \
--vocoder_path path/to/vocoder.pth.tar \
--vocoder_config_path path/to/vocoder_config.json
```
2021-01-22 01:30:32 +00:00
2021-01-25 10:16:20 +00:00
**Note:** You can use ```./TTS/bin/synthesize.py``` if you prefer running ```tts``` from the TTS project folder.
2021-01-22 01:30:32 +00:00
2021-01-11 01:12:08 +00:00
## Example: Training and Fine-tuning LJ-Speech Dataset
2020-06-04 12:26:51 +00:00
Here you can find a [CoLab](https://gist.github.com/erogol/97516ad65b44dbddb8cd694953187c5b) notebook for a hands-on example, training LJSpeech. Or you can manually follow the guideline below.
2018-12-19 11:40:02 +00:00
2020-06-04 12:26:51 +00:00
To start with, split ```metadata.csv``` into train and validation subsets respectively ```metadata_train.csv``` and ```metadata_val.csv```. Note that for text-to-speech, validation performance might be misleading since the loss value does not directly measure the voice quality to the human ear and it also does not measure the attention module performance. Therefore, running the model with new sentences and listening to the results is the best way to go.
2018-07-11 15:40:30 +00:00
```
shuf metadata.csv > metadata_shuf.csv
head -n 12000 metadata_shuf.csv > metadata_train.csv
2018-12-28 16:14:37 +00:00
tail -n 1100 metadata_shuf.csv > metadata_val.csv
2018-07-11 15:40:30 +00:00
```
To train a new model, you need to define your own ```config.json``` to define model details, trainin configuration and more (check the examples). Then call the corressponding train script.
2018-01-26 11:05:24 +00:00
For instance, in order to train a tacotron or tacotron2 model on LJSpeech dataset, follow these steps.
2021-01-27 10:26:38 +00:00
```bash
python TTS/bin/train_tacotron.py --config_path TTS/tts/configs/config.json
```
2018-01-26 11:05:24 +00:00
2018-09-27 13:10:15 +00:00
To fine-tune a model, use ```--restore_path```.
2018-05-25 12:51:14 +00:00
2021-01-27 10:26:38 +00:00
```bash
python TTS/bin/train_tacotron.py --config_path TTS/tts/configs/config.json --restore_path /path/to/your/model.pth.tar
```
2020-07-17 10:56:42 +00:00
To continue an old training run, use ```--continue_path```.
2021-01-27 10:26:38 +00:00
```bash
python TTS/bin/train_tacotron.py --continue_path /path/to/your/run_folder/
```
2018-05-25 12:51:14 +00:00
For multi-GPU training, call ```distribute.py```. It runs any provided train script in multi-GPU setting.
2018-01-26 11:05:24 +00:00
2021-01-27 10:26:38 +00:00
```bash
CUDA_VISIBLE_DEVICES="0,1,4" python TTS/bin/distribute.py --script train_tacotron.py --config_path TTS/tts/configs/config.json
```
2018-01-26 11:05:24 +00:00
Each run creates a new output folder accomodating used ```config.json```, model checkpoints and tensorboard logs.
2018-09-27 13:10:15 +00:00
In case of any error or intercepted execution, if there is no checkpoint yet under the output folder, the whole folder is going to be removed.
2018-01-26 11:05:24 +00:00
2019-05-28 12:25:02 +00:00
You can also enjoy Tensorboard, if you point Tensorboard argument```--logdir``` to the experiment folder.
2018-02-22 13:22:27 +00:00
2021-03-05 01:46:33 +00:00
## Contribution guidelines
Please follow the steps below as you send a PR to 🐸. It helps us to keep things organized.
2019-07-19 10:37:35 +00:00
2021-03-06 17:35:08 +00:00
1. Create a new branch.
2. Implement your changes.
3. (if applicable) Add [Google Style](https://google.github.io/styleguide/pyguide.html#381-docstrings) docstrings.
4. (if applicable) Implement a test case under ```tests``` folder.
2021-03-08 13:05:39 +00:00
5. (Optional but Prefered) Run tests.
2021-03-06 17:35:08 +00:00
```bash
./run_tests.sh
```
2021-03-13 16:57:40 +00:00
6. Run the ```pylint``` linter.
2019-07-19 10:37:35 +00:00
```bash
pip install pylint cardboardlint
cardboardlinter --refspec master
```
7. Send a PR to ```dev``` branch, explain what the change is about.
2021-03-08 13:05:39 +00:00
8. Let us discuss until we make it perfect :) 💪.
9. We merge it to the ```dev``` branch once things look good.
Feel free to ping us at any step you need help using our communication channels.
2021-03-06 17:35:08 +00:00
[Here](https://github.com/firstcontributions/first-contributions) is a good resource for complete beginners.
2019-07-19 10:37:35 +00:00
2018-05-10 22:40:34 +00:00
2020-09-22 11:10:59 +00:00
### Acknowledgement
2019-07-11 13:36:25 +00:00
- https://github.com/keithito/tacotron (Dataset pre-processing)
2019-09-10 10:32:37 +00:00
- https://github.com/r9y9/tacotron_pytorch (Initial Tacotron architecture)
2020-07-17 10:58:24 +00:00
- https://github.com/kan-bayashi/ParallelWaveGAN (vocoder library)
2020-09-22 11:10:59 +00:00
- https://github.com/jaywalnut310/glow-tts (Original Glow-TTS implementation)
2020-11-09 16:57:33 +00:00
- https://github.com/fatchord/WaveRNN/ (Original WaveRNN implementation)