Home

Awesome

Cotatron — Official PyTorch Implementation

Checkout our new project: Realistic Voice Conversion by Assembling Modern Speech Synthesis Techniques https://github.com/mindslab-ai/assem-vc

Cotatron: Transcription-Guided Speech Encoder for Any-to-Many Voice Conversion without Parallel Data<br> Seung-won Park, Doo-young Kim, Myun-chul Joe @ SNU, MINDsLab Inc.

Paper: https://arxiv.org/abs/2005.03295 (To appear in INTERSPEECH 2020)<br> Audio Samples: https://mindslab-ai.github.io/cotatron<br>

Update: Enjoy our pre-trained model with Google Colab notebook!

Abstract: We propose Cotatron, a transcription-guided speech encoder for speaker-independent linguistic representation. Cotatron is based on the multispeaker TTS architecture and can be trained with conventional TTS datasets. We train a voice conversion system to reconstruct speech with Cotatron features, which is similar to the previous methods based on Phonetic Posteriorgram (PPG). By training and evaluating our system with 108 speakers from the VCTK dataset, we outperform the previous method in terms of both naturalness and speaker similarity. Our system can also convert speech from speakers that are unseen during training, and utilize ASR to automate the transcription with minimal reduction of the performance. Audio samples are available at https://mindslab-ai.github.io/cotatron, and the code with a pre-trained model will be made available soon.

Requirements

This repository was tested with following environment:

The requirements are highlighted in requirements.txt.

Datasets

Preparing Data

Note: The mel-spectrograms calculated from audio file will be saved as **.pt at first, and then loaded from disk afterwards.

Preparing Metadata

Following a format from NVIDIA/tacotron2, the metadata should be formatted like:

path_to_wav|transcription|speaker_id
path_to_wav|transcription|speaker_id
...

Metadata for LibriTTS train-clean-100 split and VCTK corpus are already prepared at datasets/metadata. If you wish to use a custom data, you need to make the metadata as shown above.

Training

Training our VC system is consisted of two steps: (1) training Cotatron, (2) training VC decoder on top of Cotatron.

git clone https://github.com/mindslab-ai/cotatron
cd cotatron

There are three yaml files in the config folder, which are configuration template for each model. They must be edited to match your training requirements (dataset, metadata, etc.).

cp config/global/default.yaml config/global/config.yaml
cp config/cota/default.yaml config/cota/config.yaml
cp config/vc/default.yaml config/vc/config.yaml

Here, all files with name other than default.yaml will be ignored from git (see .gitignore).

1. Training Cotatron

To train the Cotatron, run this command:

python cotatron_trainer.py -c <path_to_global_config_yaml> <path_to_cotatron_config_yaml> \
                           -g <gpus> -n <run_name>

Here are some example commands that might help you understand the arguments:

# train from scratch with name "my_runname"
python cotatron_trainer.py -c config/global/config.yaml config/cota/config.yaml \
                           -g 0 -n my_runname

Optionally, you can resume the training from previously saved checkpoint by adding -p <checkpoint_path> argument.

2. Training VC decoder

After the Cotatron is sufficiently trained (i.e., producing stable alignment + converged loss), the VC decoder can be trained on top of it.

python synthesizer_trainer.py -c <path_to_global_config_yaml> <path_to_vc_config_yaml> \
                              -g <gpus> -n <run_name>

The optional checkpoint argument is also available for VC decoder.

Monitoring via Tensorboard

The progress of training with loss values and validation output can be monitored with tensorboard. By default, the logs will be stored at logs/cota or logs/vc, which can be modified by editing log.log_dir parameter at config yaml file.

tensorboard --log_dir logs/cota --bind_all # Cotatron - Scalars, Images, Hparams, Projector will be shown.
tensorboard --log_dir logs/vc --bind_all # VC decoder - Scalars, Images, Hparams will be shown.

Inference

We provide a Jupyter Notebook script to provide the code for inference and show some visualizations with resulting audio.

Results

According to the user study done in MTurk, our Cotatron-based VC system performs significantly better than previous method in terms of both naturalness (MOS) and speaker similarity (DMOS). The objective results on speaker similarity (SCA) contradicts that from subjective results. See section 4.1 from our paper for details.

ApproachMOSDMOSSCA
Source as Target4.28 ± 0.111.71 ± 0.220.9%
Target as Target4.28 ± 0.114.78 ± 0.0899.4%
Blow (previous method)2.41 ± 0.141.95 ± 0.1686.8%
Cotatron w/o residual encoder (Ours)3.18 ± 0.144.06 ± 0.1773.3%
Cotatron w/ residual encoder (Ours)3.41 ± 0.143.89 ± 0.1878.5%

Implementation details

Here are some noteworthy details of implementation, which could not be included in our paper due to the lack of space:

Since the length of training samples are not identical, they are zero-padded to match the batch's max length for GPU efficiency. Therefore, the output of every convolutional layer is masked to prevent the results of the padded areas from affecting the non-padded area. Please refer to appendix A.1 of Binkowski et al. (GAN-TTS, 2020).

We exclude the padded area from the statistics calculation for the instance normalization layer of the residual encoder. See modules/padded_instancenorm.py.

License

BSD 3-Clause License.

Citation & Contact

@article{park2020cotatron,
  title   = {Cotatron: Transcription-Guided Speech Encoder for Any-to-Many Voice Conversion without Parallel Data},
  author  = {Park, Seung-won and Kim, Doo-young and Joe, Myun-chul},
  journal = {arXiv preprint arXiv:2005.03295},
  year    = {2020},
}

If you have a question or any kind of inquiries, please contact Seung-won Park at yyyyy@snu.ac.kr

Repository structure

│  .gitignore
│  cotatron.py
│  cotatron_trainer.py      # Trainer file for Cotatron
|  LICENSE
│  README.md
│  requirements.txt
│  synthesizer.py
│  synthesizer_trainer.py   # Trainer file for VC decoder (named as "synthesizer")
│
├─config
│  ├─cota
│  │      default.yaml      # configuration template for Cotatron
│  │
│  ├─global
│  │      default.yaml      # configuration template for both Cotatron and VC decoder
│  │
│  └─vc
│         default.yaml      # configuration template for VC decoder
│
├─datasets                  # TextMelDataset and text preprocessor
│  │  cmudict-0.7b_fix.txt  # Modified version of CMUDict, for representation mixing (https://arxiv.org/abs/1811.07240)
|  |  resample_delete.sh    # Shellscript for audio resampling
│  │  text_mel_dataset.py
│  │  __init__.py
│  │
│  ├─metadata
│  │       (omitted)        # Refer to README.md within the folder.
│  │
│  └─text
│          cleaners.py
│          cmudict.py
|          LICENSE
│          numbers.py
│          symbols.py
│          __init__.py
├─docs                      # Audio samples and code for webpage https://mindslab-ai.github.io/cotatron
|      (omitted)
│
├─melgan                    # MelGAN vocoder w/o training code (https://arxiv.org/abs/1910.06711)
│      generator.py
|      LICENSE
│      res_stack.py
│
├─modules                   # All modules that compose model, including mel.py
│      attention.py         # Implementation of DCA (https://arxiv.org/abs/1910.10288)
│      classifier.py
│      cond_bn.py
│      encoder.py
│      mel.py               # Code for calculating mel-spectrogram from raw audio
│      padded_instancenorm.py
│      residual.py
│      tts_decoder.py
│      vc_decoder.py
│      zoneout.py
│      __init__.py
│
└─utils                     # Misc. code snippets, usually for logging
        loggers.py
        plotting.py
        utils.py

References

This implementation uses code from following repositories:

This README and the webpage for the audio samples are inspired by:

The audio samples on our webpage are partially derived from: