ParakeetRebeccaRosario/examples/speedyspeech/baker
iclementine 2e9ffcb6d0 fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00
..
conf complete theexample for speedyspeech; fix several bugs in training module 2021-07-12 15:19:22 +08:00
README.md fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00
batch_fn.py format 2021-08-17 09:54:07 +00:00
compute_statistics.py format 2021-08-17 09:54:07 +00:00
config.py 1. use relative path in metadata.jsonl; 2021-08-16 10:01:51 +08:00
frontend.py format 2021-08-17 09:54:07 +00:00
inference.py format 2021-08-17 09:54:07 +00:00
inference.sh add inference script with paddle inference library 2021-07-29 15:13:57 +08:00
normalize.py format 2021-08-17 09:54:07 +00:00
phones.txt add WIP: speedyspeech model and example with baker dataset. 2021-07-08 16:47:08 +08:00
preprocess.py format 2021-08-17 09:54:07 +00:00
preprocess.sh fix pwg 2021-08-09 10:46:52 +00:00
run.sh fix pwg 2021-08-09 10:46:52 +00:00
sentences.txt add e2e inference script 2021-07-13 10:51:17 +08:00
speedyspeech_updater.py format 2021-08-17 09:54:07 +00:00
synthesize.py fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00
synthesize.sh fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00
synthesize_e2e.py format 2021-08-17 09:54:07 +00:00
synthesize_e2e.sh fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00
tg_utils.py format 2021-08-17 09:54:07 +00:00
tones.txt add WIP: speedyspeech model and example with baker dataset. 2021-07-08 16:47:08 +08:00
train.py fix argparse argument names, update shell scripts 2021-08-20 20:46:20 +08:00

README.md

Speedyspeech with the Baker dataset

This example contains code used to train a Speedyspeech model with Chinese Standard Mandarin Speech Copus. NOTE that we only implement the student part of the Speedyspeech model. The ground truth alignment used to train the model is extracted from the dataset.

Preprocess the dataset

Download the dataset from the official website of data-baker and extract it to ~/datasets. Then the dataset is in directory ~/datasets/BZNSYP.

Run the script for preprocessing.

bash preprocess.sh

When it is done. A dump folder is created in the current directory. The structure of the dump folder is listed below.

dump
├── dev
│   ├── norm
│   └── raw
├── test
│   ├── norm
│   └── raw
└── train
    ├── norm
    ├── raw
    └── stats.npy

The dataset is split into 3 parts, namely train, dev and test, each of which contains a norm and raw sub folder. The raw folder contains log magnitude of mel spectrogram of each utterances, while the norm folder contains normalized spectrogram. The statistics used to normalize the spectrogram is computed from the training set, which is located in dump/train/stats.npy.

Also there is a metadata.jsonl in each subfolder. It is a table-like file which contains phones, tones, durations, path of spectrogram, and id of each utterance.

Train the model

To train the model use the run.sh. It is an example script to run train.py.

bash run.sh

Or you can use train.py directly. Here's the complete help message.

usage: train.py [-h] [--config CONFIG] [--train-metadata TRAIN_METADATA]
                [--dev-metadata DEV_METADATA] [--output-dir OUTPUT_DIR]
                [--device DEVICE] [--nprocs NPROCS] [--verbose VERBOSE]

Train a Speedyspeech model with Baker Mandrin TTS dataset.

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG       config file to overwrite default config
  --train-metadata TRAIN_METADATA
                        training data
  --dev-metadata DEV_METADATA
                        dev data
  --output-dir OUTPUT_DIR
                        output dir
  --device DEVICE       device type to use
  --nprocs NPROCS       number of processes
  --verbose VERBOSE     verbose
  1. --config is a config file in yaml format to overwrite the default config, which can be found at conf/default.yaml.
  2. --train-metadata and --dev-metadata should be the metadata file in the normalized subfolder of train and dev in the dump folder.
  3. --output-dir is the directory to save the results of the experiment. Checkpoints are save in checkpoints/ inside this directory.
  4. --device is the type of the device to run the experiment, 'cpu' or 'gpu' are supported.
  5. --nprocs is the number of processes to run in parallel, note that nprocs > 1 is only supported when --device is 'gpu'.

Pretrained Models

Pretrained models can be downloaded here:

  1. Speedyspeech checkpoint. speedyspeech_baker_ckpt_0.4.zip
  2. Parallel WaveGAN checkpoint. pwg_baker_ckpt_0.4.zip, which is used as a vocoder in the end-to-end inference script.

Speedyspeech checkpoint contains files listed below.

speedyspeech_baker_ckpt_0.4
├── speedyspeech_default.yaml             # default config used to train speedyseech
├── speedy_speech_stats.npy               # statistics used to normalize spectrogram when training speedyspeech
└── speedyspeech_snapshot_iter_91800.pdz  # model parameters and optimizer states

Parallel WaveGAN checkpoint contains files listed below.

pwg_baker_ckpt_0.4
├── pwg_default.yaml              # default config used to train parallel wavegan
├── pwg_snapshot_iter_400000.pdz  # model parameters and optimizer states of parallel wavegan
└── pwg_stats.npy                 # statistics used to normalize spectrogram when training parallel wavegan

Synthesize End to End

When training is done or pretrained models are downloaded. You can run synthesize_e2e.py to synthsize.

usage: synthesize_e2e.py [-h] [--speedyspeech-config SPEEDYSPEECH_CONFIG]
                         [--speedyspeech-checkpoint SPEEDYSPEECH_CHECKPOINT]
                         [--speedyspeech-stat SPEEDYSPEECH_STAT]
                         [--pwg-config PWG_CONFIG] [--pwg-params PWG_CHECKPOINT]
                         [--pwg-stat PWG_STAT] [--text TEXT]
                         [--output-dir OUTPUT_DIR]
                         [--inference-dir INFERENCE_DIR] [--device DEVICE]
                         [--verbose VERBOSE]

Synthesize with speedyspeech & parallel wavegan.

optional arguments:
  -h, --help            show this help message and exit
  --speedyspeech-config SPEEDYSPEECH_CONFIG
                        config file for speedyspeech.
  --speedyspeech-checkpoint SPEEDYSPEECH_CHECKPOINT
                        speedyspeech checkpoint to load.
  --speedyspeech-stat SPEEDYSPEECH_STAT
                        mean and standard deviation used to normalize
                        spectrogram when training speedyspeech.
  --pwg-config PWG_CONFIG
                        config file for parallelwavegan.
  --pwg-checkpoint PWG_CHECKPOINT
                        parallel wavegan checkpoint to load.
  --pwg-stat PWG_STAT   mean and standard deviation used to normalize
                        spectrogram when training speedyspeech.
  --text TEXT           text to synthesize, a 'utt_id sentence' pair per line
  --output-dir OUTPUT_DIR
                        output dir
  --inference-dir INFERENCE_DIR
                        dir to save inference models
  --device DEVICE       device type to use
  --verbose VERBOSE     verbose
  1. --speedyspeech-config, --speedyspeech-checkpoint, --speedyspeech-stat are arguments for speedyspeech, which correspond to the 3 files in the speedyspeech pretrained model.
  2. --pwg-config, --pwg-checkpoint, --pwg-stat are arguments for speedyspeech, which correspond to the 3 files in the parallel wavegan pretrained model.
  3. --text is the text file, which contains sentences to synthesize.
  4. --output-dir is the directory to save synthesized audio files.
  5. --inference-dir is the directory to save exported model, which can be used with paddle infernece.
  6. --device is the type of device to run synthesis, 'cpu' and 'gpu' are supported. 'gpu' is recommended for faster synthesis.