|
| 1 | +# DiffGAN-TTS - PyTorch Implementation |
| 2 | + |
| 3 | +PyTorch implementation of [DiffGAN-TTS: High-Fidelity and Efficient Text-to-Speech with Denoising Diffusion GANs](https://arxiv.org/abs/2201.11972) |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + <img src="img/model_1.png" width="80%"> |
| 7 | +</p> |
| 8 | + |
| 9 | +<p align="center"> |
| 10 | + <img src="img/model_2.png" width="80%"> |
| 11 | +</p> |
| 12 | + |
| 13 | +# Repository Status |
| 14 | +- [x] Naive Version of DiffGAN-TTS |
| 15 | +- [x] Active Shallow Diffusion Mechanism: DiffGAN-TTS (two-stage) |
| 16 | + |
| 17 | +## Audio Samples |
| 18 | +Audio samples are available at [/demo](https://github.com/keonlee9420/DiffGAN-TTS/tree/main/demo). |
| 19 | + |
| 20 | +# Quickstart |
| 21 | + |
| 22 | +***DATASET*** refers to the names of datasets such as `LJSpeech` and `VCTK` in the following documents. |
| 23 | + |
| 24 | +***MODEL*** refers to the types of model (choose from '**naive**', '**aux**', '**shallow**'). |
| 25 | + |
| 26 | +## Dependencies |
| 27 | +You can install the Python dependencies with |
| 28 | +``` |
| 29 | +pip3 install -r requirements.txt |
| 30 | +``` |
| 31 | + |
| 32 | +## Inference |
| 33 | + |
| 34 | +You have to download the [pretrained models](https://drive.google.com/drive/folders/14EqKdfq3hTCg8BQ1ZTc8aJwwnpkFOAzh?usp=sharing) and put them in |
| 35 | +- ``output/ckpt/DATASET_naive/`` for '**naive**' model. |
| 36 | +- ``output/ckpt/DATASET_shallow/`` for '**shallow**' model. Please note that the checkpoint of the '**shallow**' model contains both '**shallow**' and '**aux**' models, and these two models will share all directories except results throughout the whole process. |
| 37 | + |
| 38 | +For a **single-speaker TTS**, run |
| 39 | +``` |
| 40 | +python3 synthesize.py --text "YOUR_DESIRED_TEXT" --model MODEL --restore_step RESTORE_STEP --mode single --dataset DATASET |
| 41 | +``` |
| 42 | + |
| 43 | +For a **multi-speaker TTS**, run |
| 44 | +``` |
| 45 | +python3 synthesize.py --text "YOUR_DESIRED_TEXT" --model MODEL --speaker_id SPEAKER_ID --restore_step RESTORE_STEP --mode single --dataset DATASET |
| 46 | +``` |
| 47 | + |
| 48 | +The dictionary of learned speakers can be found at `preprocessed_data/DATASET/speakers.json`, and the generated utterances will be put in `output/result/`. |
| 49 | + |
| 50 | +## Batch Inference |
| 51 | +Batch inference is also supported, try |
| 52 | + |
| 53 | +``` |
| 54 | +python3 synthesize.py --source preprocessed_data/DATASET/val.txt --model MODEL --restore_step RESTORE_STEP --mode batch --dataset DATASET |
| 55 | +``` |
| 56 | +to synthesize all utterances in ``preprocessed_data/DATASET/val.txt``. |
| 57 | + |
| 58 | + |
| 59 | +## Controllability |
| 60 | +The pitch/volume/speaking rate of the synthesized utterances can be controlled by specifying the desired pitch/energy/duration ratios. |
| 61 | +For example, one can increase the speaking rate by 20 % and decrease the volume by 20 % by |
| 62 | + |
| 63 | +``` |
| 64 | +python3 synthesize.py --text "YOUR_DESIRED_TEXT" --model MODEL --restore_step RESTORE_STEP --mode single --dataset DATASET --duration_control 0.8 --energy_control 0.8 |
| 65 | +``` |
| 66 | + |
| 67 | +Please note that the controllability is originated from [FastSpeech2](https://arxiv.org/abs/2006.04558) and not a vital interest of DiffGAN-TTS. |
| 68 | + |
| 69 | +# Training |
| 70 | + |
| 71 | +## Datasets |
| 72 | + |
| 73 | +The supported datasets are |
| 74 | + |
| 75 | +- [LJSpeech](https://keithito.com/LJ-Speech-Dataset/): a **single-speaker** English dataset consists of 13100 short audio clips of a female speaker reading passages from 7 non-fiction books, approximately 24 hours in total. |
| 76 | + |
| 77 | +- [VCTK](https://datashare.ed.ac.uk/handle/10283/3443): The CSTR VCTK Corpus includes speech data uttered by 110 English speakers (**multi-speaker TTS**) with various accents. Each speaker reads out about 400 sentences, which were selected from a newspaper, the rainbow passage and an elicitation paragraph used for the speech accent archive. |
| 78 | + |
| 79 | +## Preprocessing |
| 80 | + |
| 81 | +- For a **multi-speaker TTS** with external speaker embedder, download [ResCNN Softmax+Triplet pretrained model](https://drive.google.com/file/d/1F9NvdrarWZNktdX9KlRYWWHDwRkip_aP) of [philipperemy's DeepSpeaker](https://github.com/philipperemy/deep-speaker) for the speaker embedding and locate it in `./deepspeaker/pretrained_models/`. |
| 82 | +- Run |
| 83 | + ``` |
| 84 | + python3 prepare_align.py --dataset DATASET |
| 85 | + ``` |
| 86 | + for some preparations. |
| 87 | +
|
| 88 | + For the forced alignment, [Montreal Forced Aligner](https://montreal-forced-aligner.readthedocs.io/en/latest/) (MFA) is used to obtain the alignments between the utterances and the phoneme sequences. |
| 89 | + Pre-extracted alignments for the datasets are provided [here](https://drive.google.com/drive/folders/1fizpyOiQ1lG2UDaMlXnT3Ll4_j6Xwg7K?usp=sharing). |
| 90 | + You have to unzip the files in `preprocessed_data/DATASET/TextGrid/`. Alternately, you can [run the aligner by yourself](https://montreal-forced-aligner.readthedocs.io/en/latest/user_guide/workflows/index.html). |
| 91 | +
|
| 92 | + After that, run the preprocessing script by |
| 93 | + ``` |
| 94 | + python3 preprocess.py --dataset DATASET |
| 95 | + ``` |
| 96 | +
|
| 97 | +## Training |
| 98 | +
|
| 99 | +You can train three types of model: '**naive**', '**aux**', and '**shallow**'. |
| 100 | +
|
| 101 | +- Training Naive Version ('**naive**'): |
| 102 | +
|
| 103 | + Train the naive version with |
| 104 | + ``` |
| 105 | + python3 train.py --model naive --dataset DATASET |
| 106 | + ``` |
| 107 | +
|
| 108 | +- Training Basic Acoustic Model for Shallow Version ('**aux**'): |
| 109 | +
|
| 110 | + To train the shallow version, we need a pre-trained FastSpeech2. The below command will let you train the FastSpeech2 modules, including Auxiliary (Mel) Decoder. |
| 111 | + ``` |
| 112 | + python3 train.py --model aux --dataset DATASET |
| 113 | + ``` |
| 114 | +
|
| 115 | +- Training Shallow Version ('**shallow**'): |
| 116 | +
|
| 117 | + To leverage pre-trained FastSpeech2, including Auxiliary (Mel) Decoder, you must pass `--restore_step` with the final step of auxiliary FastSpeech2 training as the following command. |
| 118 | + ``` |
| 119 | + python3 train.py --model shallow --restore_step RESTORE_STEP --dataset DATASET |
| 120 | + ``` |
| 121 | + For example, if the last checkpoint is saved at 200000 steps during the auxiliary training, you have to set `--restore_step` with `200000`. Then it will load and freeze the aux model and then continue the training under the active shallow diffusion mechanism. |
| 122 | +
|
| 123 | +# TensorBoard |
| 124 | +
|
| 125 | +Use |
| 126 | +``` |
| 127 | +tensorboard --logdir output/log/DATASET |
| 128 | +``` |
| 129 | +
|
| 130 | +to serve TensorBoard on your localhost. |
| 131 | +The loss curves, synthesized mel-spectrograms, and audios are shown. |
| 132 | +
|
| 133 | +## Naive Diffusion |
| 134 | +
|
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | +
|
| 139 | +## Shallow Diffusion |
| 140 | +
|
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | +
|
| 145 | +# Notes |
| 146 | +
|
| 147 | +- In addition to the Diffusion Decoder, the Variance Adaptor is also conditioned on speaker information. |
| 148 | +- Unconditional and Conditional output of the JCU discriminator is averaged during each of loss calculation as [VocGAN](https://www.isca-speech.org/archive/pdfs/interspeech_2020/yang20_interspeech.pdf) did. |
| 149 | +- Some differences on the Data and Preprocessing compared to the original paper: |
| 150 | + - Using VCTK (109 speakers) instead of Mandarin Chinese of 228 speakers. |
| 151 | + - Following [DiffSpeech](https://github.com/keonlee9420/DiffSinger)'s audio config, e.g., sample rate is 22050Hz rather than 24,000Hz. |
| 152 | + - Also, following [DiffSpeech](https://github.com/keonlee9420/DiffSinger)'s variance extraction and modeling. |
| 153 | +- `lambda_fm` is fixed to a scala value since the dynamically scaled scalar computed as L_recon/L_fm makes the model explode. |
| 154 | +- Two options for embedding for the **multi-speaker TTS** setting: training speaker embedder from scratch or using a pre-trained [philipperemy's DeepSpeaker](https://github.com/philipperemy/deep-speaker) model (as [STYLER](https://github.com/keonlee9420/STYLER) did). You can toggle it by setting the config (between `'none'` and `'DeepSpeaker'`). |
| 155 | +- DeepSpeaker on VCTK dataset shows clear identification among speakers. The following figure shows the T-SNE plot of extracted speaker embedding. |
| 156 | +
|
| 157 | +<p align="center"> |
| 158 | + <img src="./preprocessed_data/VCTK/spker_embed_tsne.png" width="40%"> |
| 159 | +</p> |
| 160 | +
|
| 161 | +# Citation |
| 162 | +
|
| 163 | +Please cite this repository by the "[Cite this repository](https://github.blog/2021-08-19-enhanced-support-citations-github/)" of **About** section (top right of the main page). |
| 164 | +
|
| 165 | +# References |
| 166 | +- [keonlee9420's DiffSinger](https://github.com/keonlee9420/DiffSinger) |
| 167 | +- [keonlee9420's Comprehensive-Transformer-TTS](https://github.com/keonlee9420/Comprehensive-Transformer-TTS) |
| 168 | +- [LynnHo' DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch](https://github.com/LynnHo/DCGAN-LSGAN-WGAN-GP-DRAGAN-Pytorch) |
| 169 | +- [Denoising Diffusion Probabilistic Models](https://arxiv.org/abs/2006.11239) |
| 170 | +- [Tackling the Generative Learning Trilemma with Denoising Diffusion GANs](https://arxiv.org/abs/2112.07804) |
| 171 | +- [DiffSinger: Singing Voice Synthesis via Shallow Diffusion Mechanism](https://arxiv.org/abs/2105.02446) |
0 commit comments