TTS/README.md

215 lines
12 KiB
Markdown
Raw Normal View History

2019-02-12 14:59:10 +00:00
<p align="center"><img src="https://user-images.githubusercontent.com/1402048/52643646-c2102980-2edd-11e9-8c37-b72f3c89a640.png" data-canonical-src="![TTS banner](https://user-images.githubusercontent.com/1402048/52643646-c2102980-2edd-11e9-8c37-b72f3c89a640.png =250x250)
" width="320" height="95" /></p>
2020-07-17 10:37:18 +00:00
<br/>
2020-07-15 09:13:33 +00:00
<p align='center'>
<img src="https://travis-ci.org/mozilla/TTS.svg?branch=dev"/>
<a href='https://discourse.mozilla.org/c/tts'><img src="https://img.shields.io/badge/discourse-online-green.svg"/></a>
2020-07-17 10:37:18 +00:00
<a href='https://opensource.org/licenses/MPL-2.0'> <img src="https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg"/></a>
2020-07-15 09:13:33 +00:00
</p>
2019-07-19 10:37:35 +00:00
2020-07-17 10:37:18 +00:00
<br/>
This project is a part of [Mozilla Common Voice](https://voice.mozilla.org/en).
2020-07-15 09:14:46 +00:00
Mozilla TTS aims a deep learning based Text2Speech engine, low in cost and high in quality.
2018-01-22 09:48:59 +00:00
2020-07-10 09:10:57 +00:00
You can check some of synthesized voice samples from [here](https://erogol.github.io/ddc-samples/).
If you are new, you can also find [here](http://www.erogol.com/text-speech-deep-learning-architectures/) a brief post about some of TTS architectures and [here](https://github.com/erogol/TTS-papers) list of up-to-date research papers.
2018-01-22 09:48:59 +00:00
2020-05-20 15:51:42 +00:00
[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/0)](https://sourcerer.io/fame/erogol/erogol/TTS/links/0)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/1)](https://sourcerer.io/fame/erogol/erogol/TTS/links/1)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/2)](https://sourcerer.io/fame/erogol/erogol/TTS/links/2)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/3)](https://sourcerer.io/fame/erogol/erogol/TTS/links/3)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/4)](https://sourcerer.io/fame/erogol/erogol/TTS/links/4)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/5)](https://sourcerer.io/fame/erogol/erogol/TTS/links/5)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/6)](https://sourcerer.io/fame/erogol/erogol/TTS/links/6)[![](https://sourcerer.io/fame/erogol/erogol/TTS/images/7)](https://sourcerer.io/fame/erogol/erogol/TTS/links/7)
2020-06-04 12:26:51 +00:00
## TTS Performance
2019-08-16 12:28:11 +00:00
<p align="center"><img src="https://camo.githubusercontent.com/9fa79f977015e55eb9ec7aa32045555f60d093d3/68747470733a2f2f646973636f757273652d706161732d70726f64756374696f6e2d636f6e74656e742e73332e6475616c737461636b2e75732d656173742d312e616d617a6f6e6177732e636f6d2f6f7074696d697a65642f33582f362f342f363432386639383065396563373531633234386535393134363038393566373838316165633063365f325f363930783339342e706e67"/></p>
2019-04-30 22:56:58 +00:00
2019-08-16 12:28:11 +00:00
[Details...](https://github.com/mozilla/TTS/wiki/Mean-Opinion-Score-Results)
2019-04-30 22:56:58 +00:00
## Provided Models and Methods
Text-to-Spectrogram:
- Tacotron: [paper](https://arxiv.org/abs/1703.10135)
- Tacotron2: [paper](https://arxiv.org/abs/1712.05884)
Attention Methods:
2020-06-19 14:55:44 +00:00
- 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)
Vocoders:
- MelGAN: [paper](https://arxiv.org/abs/1710.10467)
- MultiBandMelGAN: [paper](https://arxiv.org/abs/2005.05106)
- GAN-TTS discriminators: [paper](https://arxiv.org/abs/1909.11646)
You can also help us implement more models. Some TTS related work can be found [here](https://github.com/erogol/TTS-papers).
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.
- Text2Spec models (Tacotron, Tacotron2).
2020-06-04 12:26:51 +00:00
- Speaker Encoder to compute speaker embeddings efficiently.
2020-07-15 09:08:35 +00:00
- Vocoder models (MelGAN, Multiband-MelGAN, GAN-TTS, ParallelWaveGAN)
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
2020-07-15 09:08:35 +00:00
## Main Requirements and Installation
2018-01-23 13:18:09 +00:00
Highly recommended to use [miniconda](https://conda.io/miniconda.html) for easier installation.
* python>=3.6
2020-07-15 09:08:35 +00:00
* pytorch>=1.4.1
* tensorflow>=2.2
2018-05-10 22:40:34 +00:00
* librosa
* tensorboard
* tensorboardX
* matplotlib
* unidecode
2018-07-11 15:40:30 +00:00
2019-02-12 15:10:22 +00:00
Install TTS using ```setup.py```. It will install all of the requirements automatically and make TTS available to all the python environment as an ordinary python module.
2018-09-27 13:10:15 +00:00
```python setup.py develop```
Or you can use ```requirements.txt``` to install the requirements only.
```pip install -r requirements.txt```
2020-06-19 13:56:02 +00:00
### Directory Structure
```
2020-07-17 10:50:20 +00:00
|- 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.)
|- notebooks/ (Jupyter Notebooks for model evaluation, parameter selection and data analysis.)
|- utils/ (common utilities.)
|- 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
```
### Docker
A barebone `Dockerfile` exists at the root of the project, which should let you quickly setup the environment. By default, it will start the server and let you query it. Make sure to use `nvidia-docker` to use your GPUs. Make sure you follow the instructions in the [`server README`](server/README.md) before you build your image so that the server can find the model within the image.
```
docker build -t mozilla-tts .
nvidia-docker run -it --rm -p 5002:5002 mozilla-tts
```
2018-05-10 22:40:34 +00:00
## Checkpoints and Audio Samples
2019-06-24 08:35:59 +00:00
Please visit [our wiki.](https://github.com/mozilla/TTS/wiki/Released-Models)
2018-04-03 10:02:47 +00:00
2018-09-27 13:10:15 +00:00
## Example Model Outputs
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
2020-07-15 09:08:35 +00:00
## [Mozilla TTS Tutorials and Notebooks](https://github.com/mozilla/TTS/wiki/TTS-Notebooks-and-Tutorials)
2018-09-27 13:10:15 +00:00
2018-12-18 00:30:15 +00:00
## Datasets and Data-Loading
2020-07-17 10:37:18 +00:00
TTS provides a generic dataloader easy to use for your custom dataset.
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
2020-07-15 09:20:23 +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
## Training and Fine-tuning LJ-Speech
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
```
2019-03-07 01:01:41 +00:00
To train a new model, you need to define your own ```config.json``` file (check the example) and call with the command below. You also set the model architecture in ```config.json```.
2018-01-26 11:05:24 +00:00
```train.py --config_path config.json```
2018-09-27 13:10:15 +00:00
To fine-tune a model, use ```--restore_path```.
2018-05-25 12:51:14 +00:00
```train.py --config_path config.json --restore_path /path/to/your/model.pth.tar```
2019-02-28 13:26:06 +00:00
For multi-GPU training use ```distribute.py```. It enables process based multi-GPU training where each process uses a single GPU.
2018-01-26 11:05:24 +00:00
2019-02-28 13:26:06 +00:00
```CUDA_VISIBLE_DEVICES="0,1,4" distribute.py --config_path config.json```
2018-01-26 11:05:24 +00:00
Each run creates a new output folder and ```config.json``` is copied under this folder.
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
2019-07-19 10:37:35 +00:00
## Contribution guidelines
This repository is governed by Mozilla's code of conduct and etiquette guidelines. For more details, please read the [Mozilla Community Participation Guidelines.](https://www.mozilla.org/about/governance/policies/participation/)
Please send your Pull Request to ```dev``` branch. Before making a Pull Request, check your changes for basic mistakes and style problems by using a linter. We have cardboardlinter setup in this repository, so for example, if you've made some changes and would like to run the linter on just the changed code, you can use the follow command:
```bash
pip install pylint cardboardlint
cardboardlinter --refspec master
```
2019-07-22 18:58:45 +00:00
## Collaborative Experimentation Guide
2020-06-04 12:26:51 +00:00
If you like to use TTS to try a new idea and like to share your experiments with the community, we urge you to use the following guideline for a better collaboration.
2019-07-22 18:58:45 +00:00
(If you have an idea for better collaboration, let us know)
- Create a new branch.
2020-06-04 12:26:51 +00:00
- Open an issue pointing your branch.
2019-07-22 18:58:45 +00:00
- Explain your experiment.
- Share your results as you proceed. (Tensorboard log files, audio results, visuals etc.)
- Use LJSpeech dataset (for English) if you like to compare results with the released models. (It is the most open scalable dataset for quick experimentation)
## [Contact/Getting Help](https://github.com/mozilla/TTS/wiki/Contact-and-Getting-Help)
2018-05-10 22:40:34 +00:00
2018-10-17 13:47:40 +00:00
## Major TODOs
- [x] Implement the model.
- [x] Generate human-like speech on LJSpeech dataset.
2019-01-06 17:10:44 +00:00
- [x] Generate human-like speech on a different dataset (Nancy) (TWEB).
2019-02-18 12:42:33 +00:00
- [x] Train TTS with r=1 successfully.
2019-03-06 13:19:34 +00:00
- [x] Enable process based distributed training. Similar to (https://github.com/fastai/imagenet-fast/).
2019-11-12 11:44:37 +00:00
- [x] Adapting Neural Vocoder. TTS works with WaveRNN and ParallelWaveGAN (https://github.com/erogol/WaveRNN and https://github.com/erogol/ParallelWaveGAN)
- [ ] Multi-speaker embedding.
- [ ] Model optimization (model export, model pruning etc.)
2018-10-17 13:47:40 +00:00
2019-05-28 12:25:02 +00:00
<!--## References
2018-05-10 22:40:34 +00:00
- [Efficient Neural Audio Synthesis](https://arxiv.org/pdf/1802.08435.pdf)
- [Attention-Based models for speech recognition](https://arxiv.org/pdf/1506.07503.pdf)
- [Generating Sequences With Recurrent Neural Networks](https://arxiv.org/pdf/1308.0850.pdf)
- [Char2Wav: End-to-End Speech Synthesis](https://openreview.net/pdf?id=B1VWyySKx)
- [VoiceLoop: Voice Fitting and Synthesis via a Phonological Loop](https://arxiv.org/pdf/1707.06588.pdf)
- [WaveRNN](https://arxiv.org/pdf/1802.08435.pdf)
2018-07-11 15:40:30 +00:00
- [Faster WaveNet](https://arxiv.org/abs/1611.09482)
2018-05-10 22:40:34 +00:00
- [Parallel WaveNet](https://arxiv.org/abs/1711.10433)
2019-05-28 12:25:02 +00:00
-->
2018-07-11 15:40:30 +00:00
2019-07-11 13:36:25 +00:00
### References
- 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)