This example contains code used to train a Tacotron2 model with AISHELL-3. The trained model can be used in Voice Cloning Task, We refer to the model structure of Transfer Learning from Speaker Verification to Multispeaker Text-To-Speech Synthesis. The general steps are as follows:
Tacotron2
because the transcriptions are not needed, we use more datasets, refer to ge2e.Tacotron2
which will be concated with encoder outputs.Download AISHELL-3 from it's Official Website and extract it to ~/datasets
. Then the dataset is in the directory ~/datasets/data_aishell3
.
We use MFA2.x to get phonemes for Tacotron2, the durations of MFA are not needed here. You can download from here aishell3_alignment_tone.tar.gz, or train your MFA model reference to mfa example (use MFA1.x now) of our repo.
We use pretrained GE2E model to generate speaker embedding for each sentence.
Download pretrained GE2E model from here ge2e_ckpt_0.3.zip, and unzip
it.
Assume the path to the dataset is ~/datasets/data_aishell3
.
Assume the path to the MFA result of AISHELL-3 is ./aishell3_alignment_tone
.
Assume the path to the pretrained ge2e model is ./ge2e_ckpt_0.3
.
Run the command below to
metadata.jsonl
../run.sh
You can choose a range of stages you want to run, or set stage
equal to stop-stage
to use only one stage, for example, running the following command will only preprocess the dataset.
./run.sh --stage 0 --stop-stage 0
CUDA_VISIBLE_DEVICES=${gpus} ./local/preprocess.sh ${conf_path} ${ge2e_ckpt_path}
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
├── embed
│ ├── SSB0005
│ ├── SSB0009
│ ├── ...
│ └── ...
├── phone_id_map.txt
├── speaker_id_map.txt
├── test
│ ├── norm
│ └── raw
└── train
├── norm
├── raw
└── speech_stats.npy
The embed
contains the generated speaker embedding for each sentence in AISHELL-3, which has the same file structure with wav files and the format is .npy
.
The computing time of utterance embedding can be x hours.
The dataset is split into 3 parts, namely train
, dev
, and test
, each of which contains a norm
and raw
subfolder. The raw folder contains speech features of each utterance, while the norm folder contains normalized ones. The statistics used to normalize features are 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 that contains phones, text_lengths, speech_lengths, durations, the path of speech features, speaker, and id of each utterance.
The preprocessing step is very similar to that one of tts0, but there is one more ge2e/inference
step here.
./local/train.sh
calls ${BIN_DIR}/train.py
.
CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${train_output_path}
The training step is very similar to that one of tts0, but we should set --voice-cloning=True
when calling ${BIN_DIR}/train.py
.
We use parallel wavegan as the neural vocoder. Download pretrained parallel wavegan model from pwg_aishell3_ckpt_0.5.zip and unzip it.
unzip pwg_aishell3_ckpt_0.5.zip
Parallel WaveGAN checkpoint contains files listed below.
pwg_aishell3_ckpt_0.5
├── default.yaml # default config used to train parallel wavegan
├── feats_stats.npy # statistics used to normalize spectrogram when training parallel wavegan
└── snapshot_iter_1000000.pdz # generator parameters of parallel wavegan
./local/synthesize.sh
calls ${BIN_DIR}/../synthesize.py
, which can synthesize waveform from metadata.jsonl
.
CUDA_VISIBLE_DEVICES=${gpus} ./local/synthesize.sh ${conf_path} ${train_output_path} ${ckpt_name}
The synthesizing step is very similar to that one of tts0, but we should set --voice-cloning=True
when calling ${BIN_DIR}/../synthesize.py
.
Assume there are some reference audios in ./ref_audio
ref_audio
├── 001238.wav
├── LJ015-0254.wav
└── audio_self_test.mp3
./local/voice_cloning.sh
calls ${BIN_DIR}/../voice_cloning.py
CUDA_VISIBLE_DEVICES=${gpus} ./local/voice_cloning.sh ${conf_path} ${train_output_path} ${ckpt_name} ${ge2e_params_path} ${ref_audio_dir}
Model | Step | eval/loss | eval/l1_loss | eval/mse_loss | eval/bce_loss | eval/attn_loss |
---|---|---|---|---|---|---|
default | 2(gpu) x 37596 | 0.58704 | 0.39623 | 0.15073 | 0.039 | 1.9981e-04 |
Tacotron2 checkpoint contains files listed below.
(There is no need for speaker_id_map.txt
here )
tacotron2_aishell3_ckpt_vc0_0.2.0
├── default.yaml # default config used to train tacotron2
├── phone_id_map.txt # phone vocabulary file when training tacotron2
├── snapshot_iter_37596.pdz # model parameters and optimizer states
└── speech_stats.npy # statistics used to normalize spectrogram when training tacotron2
We strongly recommend that you use FastSpeech2 + AISHELL-3 Voice Cloning which works better.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。