diff --git a/README.md b/README.md index 532b24cc3..da413001a 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Developers can have a try of our model with only a few lines of code. A tiny DeepSpeech2 **Speech-to-Text** model training on toy set of LibriSpeech: ```shell -cd examples/tiny/s0/ +cd examples/tiny/asr0/ # source the environment source path.sh source ../../../utils/parse_options.sh @@ -177,20 +177,20 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle Aishell DeepSpeech2 RNN + Conv based Models - deepspeech2-aishell + deepspeech2-aishell Transformer based Attention Models - u2.transformer.conformer-aishell + u2.transformer.conformer-aishell Librispeech Transformer based Attention Models - deepspeech2-librispeech / transformer.conformer.u2-librispeech / transformer.conformer.u2-kaldi-librispeech + deepspeech2-librispeech / transformer.conformer.u2-librispeech / transformer.conformer.u2-kaldi-librispeech @@ -199,7 +199,7 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle THCHS30 MFA - mfa-thchs30 + mfa-thchs30 @@ -213,7 +213,7 @@ The current hyperlinks redirect to [Previous Parakeet](https://github.com/Paddle TIMIT Unified Streaming & Non-streaming Two-pass - u2-timit + u2-timit diff --git a/dataset/ted_en_zh/ted_en_zh.py b/dataset/ted_en_zh/ted_en_zh.py index 9a3ba3b31..2d1fc6710 100644 --- a/dataset/ted_en_zh/ted_en_zh.py +++ b/dataset/ted_en_zh/ted_en_zh.py @@ -28,7 +28,7 @@ import soundfile parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( - "--src_dir", + "--src-dir", default="", type=str, help="Directory to kaldi splited data. (default: %(default)s)") diff --git a/demos/README.md b/demos/README.md new file mode 100644 index 000000000..2183c1f2d --- /dev/null +++ b/demos/README.md @@ -0,0 +1 @@ +# Demos for PaddleSpeech diff --git a/demos/style_fs2/README.md b/demos/style_fs2/README.md new file mode 100644 index 000000000..b9b0469f8 --- /dev/null +++ b/demos/style_fs2/README.md @@ -0,0 +1,8 @@ +# Style FastSpeech2 +You can change the `pitch`、`duration` and `energy` of `FastSpeech2`. + +Run the following command line to get started: +``` +./run.sh +``` +For more details, please see `style_syn.py` diff --git a/docs/tutorial/tts/tts_tutorial.ipynb b/docs/tutorial/tts/tts_tutorial.ipynb index 587924cda..2bb407beb 100644 --- a/docs/tutorial/tts/tts_tutorial.ipynb +++ b/docs/tutorial/tts/tts_tutorial.ipynb @@ -252,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 25, "metadata": { "scrolled": true }, @@ -261,8 +261,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" + "env: CUDA_VISIBLE_DEVICES=0\n" ] } ], @@ -284,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 28, "metadata": { "scrolled": true }, @@ -317,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 30, "metadata": { "scrolled": true }, @@ -596,11 +595,19 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 31, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Frontend done!\n" + ] + } + ], "source": [ "# 传入 phones_dict 会把相应的 phones 转换成 phone_ids\n", "frontend = Frontend(phone_vocab_path=phones_dict)\n", @@ -619,25 +626,11 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 35, "metadata": { "scrolled": true }, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Building prefix dict from the default dictionary ...\n", - "DEBUG:jieba:Building prefix dict from the default dictionary ...\n", - "Loading model from cache /tmp/jieba.cache\n", - "DEBUG:jieba:Loading model from cache /tmp/jieba.cache\n", - "Loading model cost 5.331 seconds.\n", - "DEBUG:jieba:Loading model cost 5.331 seconds.\n", - "Prefix dict has been built successfully.\n", - "DEBUG:jieba:Prefix dict has been built successfully.\n" - ] - }, { "name": "stdout", "output_type": "stream", @@ -701,8 +694,10 @@ "

\n", "在本教程中,我们使用 `FastSpeech2` 作为声学模型。\n", "![FastSpeech2](source/fastspeech2.png)\n", + "\n", "PaddleSpeech TTS 实现的 FastSpeech2 与论文不同的地方在于,我们使用的的是 phone 级别的 `pitch` 和 `energy`(与 FastPitch 类似)。\n", "![FastPitch](source/fastpitch.png)\n", + "\n", "更多关于[声学模型的发展及改进](https://paddlespeech.readthedocs.io/en/latest/tts/models_introduction.html)。" ] }, @@ -1020,13 +1015,16 @@ "odim = fastspeech2_config.n_mels\n", "model = FastSpeech2(\n", " idim=vocab_size, odim=odim, **fastspeech2_config[\"model\"])\n", - "\n", - "model.set_state_dict(paddle.load(fastspeech2_checkpoint)[\"main_params\"]) # 加载预训练模型参数\n", - "model.eval() # 推理阶段不启用 batch norm 和 dropout\n", + "# 加载预训练模型参数\n", + "model.set_state_dict(paddle.load(fastspeech2_checkpoint)[\"main_params\"])\n", + "# 推理阶段不启用 batch norm 和 dropout\n", + "model.eval()\n", "stat = np.load(fastspeech2_stat)\n", - "mu, std = stat # 读取数据预处理阶段数据集的均值和标准差\n", + "# 读取数据预处理阶段数据集的均值和标准差\n", + "mu, std = stat\n", "mu, std = paddle.to_tensor(mu), paddle.to_tensor(std)\n", - "fastspeech2_normalizer = ZScore(mu, std) # 构造归一化的新模型\n", + "# 构造归一化的新模型\n", + "fastspeech2_normalizer = ZScore(mu, std)\n", "fastspeech2_inference = FastSpeech2Inference(fastspeech2_normalizer, model)\n", "fastspeech2_inference.eval()\n", "print(fastspeech2_inference)\n", @@ -1153,16 +1151,18 @@ ], "source": [ "vocoder = PWGGenerator(**pwg_config[\"generator_params\"])\n", - "\n", - "vocoder.set_state_dict(paddle.load(pwg_checkpoint)[\"generator_params\"]) # 模型加载预训练参数\n", + "# 模型加载预训练参数\n", + "vocoder.set_state_dict(paddle.load(pwg_checkpoint)[\"generator_params\"]) \n", "vocoder.remove_weight_norm()\n", - "vocoder.eval() # 推理阶段不启用 batch norm 和 dropout\n", - "\n", - "stat = np.load(pwg_stat) # 读取数据预处理阶段数据集的均值和标准差\n", + "# 推理阶段不启用 batch norm 和 dropout\n", + "vocoder.eval()\n", + "# 读取数据预处理阶段数据集的均值和标准差\n", + "stat = np.load(pwg_stat)\n", "mu, std = stat\n", "mu, std = paddle.to_tensor(mu), paddle.to_tensor(std)\n", "pwg_normalizer = ZScore(mu, std)\n", - "pwg_inference = PWGInference(pwg_normalizer, vocoder) # 构建归一化的模型\n", + "# 构建归一化的模型\n", + "pwg_inference = PWGInference(pwg_normalizer, vocoder)\n", "pwg_inference.eval()\n", "print(\"Parallel WaveGAN done!\")" ] @@ -1266,7 +1266,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 36, "metadata": {}, "outputs": [ { diff --git a/examples/aishell/asr1/READEME.md b/examples/aishell/asr1/READEME.md new file mode 100644 index 000000000..2eea233da --- /dev/null +++ b/examples/aishell/asr1/READEME.md @@ -0,0 +1,341 @@ +# Transformer/Conformer ASR with Aishell + +This example contains code used to train a Transformer or [Conformer](http://arxiv.org/abs/2008.03802) model with [Aishell dataset](http://www.openslr.org/resources/33) + +## Overview + +All the scirpts you need are in ```run.sh```. There are several stages in ```run.sh```, and each stage has its function. + +| Stage | Function | +| :---- | :----------------------------------------------------------- | +| 0 | Process data. It includes:
(1) Download the dataset
(2) Caculate the CMVN of the train dataset
(3) Get the vocabulary file
(4) Get the manifest files of the train, development and test dataset | +| 1 | Train the model | +| 2 | Get the final model by averaging the top-k models, set k = 1 means choose the best model | +| 3 | Test the final model performance | +| 4 | Get ctc alignment of test data using the final model | +| 5 | Infer the single audio file | + + +You can choose to run a range of stages by setting ```stage``` and ```stop_stage ```. + +For example, if you want to execute the code in stage 2 and stage 3, you can run this script: + +```bash +bash run.sh --stage 2 --stop_stage 3 +``` + +Or you can set ```stage``` equal to ```stop-stage``` to only run one stage. +For example, if you only want to run ```stage 0```, you can use the script below: + +```bash +bash run.sh --stage 0 --stop_stage 0 +``` + + + +The document below will describe the scripts in ```run.sh``` in detail. + +## The Environment Variables + +The path.sh contains the environment variables. + +```bash +source path.sh +``` + +This script needs to be run firstly. And another script is also needed: + +```bash +source ${MAIN_ROOT}/utils/parse_options.sh +``` + +It will support the way of using```--varibale value``` in the shell scripts. + + + +## The Local Variables + +Some local variables are set in ```run.sh```. +```gpus``` denotes the GPU number you want to use. If you set ```gpus=```, it means you only use CPU. + +```stage``` denotes the number of stage you want to start from in the expriments. +```stop stage```denotes the number of stage you want to end at in the expriments. + +```conf_path``` denotes the config path of the model. + +```avg_num``` denotes the number K of top-K models you want to average to get the final model. + +```audio file``` denotes the file path of the single file you want to infer in stage 6 + +```ckpt``` denotes the checkpoint prefix of the model, e.g. "conformer" + +You can set the local variables (except ```ckpt```) when you use ```run.sh``` + +For example, you can set the ```gpus``` and ``avg_num`` when you use the command line.: + +```bash +bash run.sh --gpus 0,1 --avg_num 20 +``` + + + +## Stage 0: Data Processing + +To use this example, you need to process data firstly and you can use stage 0 in ```run.sh``` to do this. The code is shown below: + +```bash + if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then + # prepare data + bash ./local/data.sh || exit -1 + fi +``` + +Stage 0 is for processing the data. + +If you only want to process the data. You can run + +```bash +bash run.sh --stage 0 --stop_stage 0 +``` + +You can also just run these scripts in your command line. + +```bash +source path.sh +bash ./local/data.sh +``` + +After processing the data, the ``data`` directory will look like this: + +```bash +data/ +|-- dev.meta +|-- lang_char +| `-- vocab.txt +|-- manifest.dev +|-- manifest.dev.raw +|-- manifest.test +|-- manifest.test.raw +|-- manifest.train +|-- manifest.train.raw +|-- mean_std.json +|-- test.meta +`-- train.meta +``` + + + +## Stage 1: Model Training + +If you want to train the model. you can use stage 1 in ```run.sh```. The code is shown below. + +```bash +if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then + # train model, all `ckpt` under `exp` dir + CUDA_VISIBLE_DEVICES=${gpus} ./local/train.sh ${conf_path} ${ckpt} + fi +``` + +If you want to train the model, you can use the script below to execute stage 0 and stage 1: + +```bash +bash run.sh --stage 0 --stop_stage 1 +``` + +or you can run these scripts in the command line (only use CPU). + +```bash +source path.sh +bash ./local/data.sh +CUDA_VISIBLE_DEVICES= ./local/train.sh conf/conformer.yaml conformer +``` + + + +## Stage 2: Top-k Models Averaging + +After training the model, we need to get the final model for testing and inference. In every epoch, the model checkpoint is saved, so we can choose the best model from them based on the validation loss or we can sort them and average the parameters of the top-k models to get the final model. We can use stage 2 to do this, and the code is shown below: + +```bash + if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then + # avg n best model + avg.sh best exp/${ckpt}/checkpoints ${avg_num} + fi +``` + +The ```avg.sh``` is in the ```../../../utils/``` which is define in the ```path.sh```. +If you want to get the final model, you can use the script below to execute stage 0, stage 1, and stage 2: + +```bash +bash run.sh --stage 0 --stop_stage 2 +``` + +or you can run these scripts in the command line (only use CPU). + +```bash +source path.sh +bash ./local/data.sh +CUDA_VISIBLE_DEVICES= ./local/train.sh conf/conformer.yaml conformer +avg.sh best exp/conformer/checkpoints 20 +``` + + + +## Stage 3: Model Testing + +The test stage is to evaluate the model performance. The code of test stage is shown below: + +```bash + if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then + # test ckpt avg_n + CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + fi +``` + +If you want to train a model and test it, you can use the script below to execute stage 0, stage 1, stage 2, and stage 3 : + +```bash +bash run.sh --stage 0 --stop_stage 3 +``` + +or you can run these scripts in the command line (only use CPU). + +```bash +source path.sh +bash ./local/data.sh +CUDA_VISIBLE_DEVICES= ./local/train.sh conf/conformer.yaml conformer +avg.sh best exp/conformer/checkpoints 20 +CUDA_VISIBLE_DEVICES= ./local/test.sh conf/conformer.yaml exp/conformer/checkpoints/avg_20 +``` + + + +## Pretrained Model + +You can get the pretrained transfomer or conformer using the scripts below: + +```bash +Conformer: +wget https://deepspeech.bj.bcebos.com/release2.1/aishell/s1/aishell.release.tar.gz + +Chunk Conformer: +wget https://deepspeech.bj.bcebos.com/release2.1/aishell/s1/aishell.chunk.release.tar.gz + +Transfomer: +wget https://paddlespeech.bj.bcebos.com/s2t/aishell/asr1/transformer.model.tar.gz + +``` + +using the ```tar``` scripts to unpack the model and then you can use the script to test the modle. + +For example: + +``` +wget https://paddlespeech.bj.bcebos.com/s2t/aishell/asr1/transformer.model.tar.gz +tar xzvf transformer.model.tar.gz +source path.sh +# If you have process the data and get the manifest file, you can skip the following 2 steps +bash local/data.sh --stage -1 --stop_stage -1 +bash local/data.sh --stage 2 --stop_stage 2 + +CUDA_VISIBLE_DEVICES= ./local/test.sh conf/transformer.yaml exp/transformer/checkpoints/avg_20 +``` + + + +The performance of the released models are shown below: + +### Conformer + +| Model | Params | Config | Augmentation | Test set | Decode method | Loss | CER | +| --------- | ------ | ------------------- | ---------------- | -------- | ---------------------- | ---- | -------- | +| conformer | 47.07M | conf/conformer.yaml | spec_aug + shift | test | attention | - | 0.059858 | +| conformer | 47.07M | conf/conformer.yaml | spec_aug + shift | test | ctc_greedy_search | - | 0.062311 | +| conformer | 47.07M | conf/conformer.yaml | spec_aug + shift | test | ctc_prefix_beam_search | - | 0.062196 | +| conformer | 47.07M | conf/conformer.yaml | spec_aug + shift | test | attention_rescoring | - | 0.054694 | + + +### Chunk Conformer + +Need set `decoding.decoding_chunk_size=16` when decoding. + +| Model | Params | Config | Augmentation | Test set | Decode method | Chunk Size & Left Chunks | Loss | CER | +| --------- | ------ | ------------------------- | ---------------- | -------- | ---------------------- | ------------------------ | ---- | -------- | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention | 16, -1 | - | 0.061939 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_greedy_search | 16, -1 | - | 0.070806 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | ctc_prefix_beam_search | 16, -1 | - | 0.070739 | +| conformer | 47.06M | conf/chunk_conformer.yaml | spec_aug + shift | test | attention_rescoring | 16, -1 | - | 0.059400 | + + +### Transformer + +| Model | Params | Config | Augmentation | Test set | Decode method | Loss | CER | +| ----------- | ------ | --------------------- | ------------ | -------- | ---------------------- | ----------------- | -------- | +| transformer | 31.95M | conf/transformer.yaml | spec_aug | test | attention | 3.858648955821991 | 0.057293 | +| transformer | 31.95M | conf/transformer.yaml | spec_aug | test | ctc_greedy_search | 3.858648955821991 | 0.061837 | +| transformer | 31.95M | conf/transformer.yaml | spec_aug | test | ctc_prefix_beam_search | 3.858648955821991 | 0.061685 | +| transformer | 31.95M | conf/transformer.yaml | spec_aug | test | attention_rescoring | 3.858648955821991 | 0.053844 | + + + +## Stage 4: CTC Alignment + +If you want to get the alignment between the audio and the text, you can use the ctc alignment. The code of this stage is shown below: + +```bash + if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then + # ctc alignment of test data + CUDA_VISIBLE_DEVICES=0 ./local/align.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 + fi +``` + +If you want to train the model, test it and do the alignment, you can use the script below to execute stage 0, stage 1, stage 2, and stage 3 : + +```bash +bash run.sh --stage 0 --stop_stage 4 +``` + +or if you only need to train a model and do the alignment, you can use these scripts to escape stage 3(test stage): + +```bash +bash run.sh --stage 0 --stop_stage 2 +bash run.sh --stage 4 --stop_stage 4 +``` + +or you can also use these scripts in the command line (only use CPU). + +```bash +source path.sh +bash ./local/data.sh +CUDA_VISIBLE_DEVICES= ./local/train.sh conf/conformer.yaml conformer +avg.sh best exp/conformer/checkpoints 20 +# test stage is optional +CUDA_VISIBLE_DEVICES= ./local/test.sh conf/conformer.yaml exp/conformer/checkpoints/avg_20 +CUDA_VISIBLE_DEVICES= ./local/align.sh conf/conformer.yaml exp/conformer/checkpoints/avg_20 +``` + + + +## Stage 5: Single Audio File Inference + +In some situations, you want to use the trained model to do the inference for the single audio file. You can use stage 5. The code is shown below + +```bash + if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then + # test a single .wav file + CUDA_VISIBLE_DEVICES=0 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 + fi +``` + +you can train the model by yourself using ```bash run.sh --stage 0 --stop_stage 3```, or you can download the pretrained model through the script below: + +```bash +wget https://paddlespeech.bj.bcebos.com/s2t/aishell/asr1/transformer.model.tar.gz +tar xzvf transformer.model.tar.gz +``` + +You need to prepare an audio file, please confirm the sample rate of the audio is 16K. Assume the path of the audio file is ```data/test_audio.wav```, you can get the result by running the script below. + +```bash +CUDA_VISIBLE_DEVICES= ./local/test_hub.sh conf/transformer.yaml exp/transformer/checkpoints/avg_20 data/test_audio.wav +``` diff --git a/examples/aishell/asr1/run.sh b/examples/aishell/asr1/run.sh index 1464f2c91..d9c0ee3e0 100644 --- a/examples/aishell/asr1/run.sh +++ b/examples/aishell/asr1/run.sh @@ -4,7 +4,7 @@ set -e gpus=0,1,2,3 stage=0 -stop_stage=100 +stop_stage=50 conf_path=conf/conformer.yaml avg_num=20 audio_file=data/demo_01_03.wav @@ -15,7 +15,6 @@ avg_ckpt=avg_${avg_num} ckpt=$(basename ${conf_path} | awk -F'.' '{print $1}') echo "checkpoint name ${ckpt}" - if [ ${stage} -le 0 ] && [ ${stop_stage} -ge 0 ]; then # prepare data bash ./local/data.sh || exit -1 @@ -41,18 +40,20 @@ if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then CUDA_VISIBLE_DEVICES=0 ./local/align.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 fi -# if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then -# # export ckpt avg_n -# CUDA_VISIBLE_DEVICES=0 ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit -# fi - # Optionally, you can add LM and test it with runtime. -if [ ${stage} -le 6 ] && [ ${stop_stage} -ge 6 ]; then +if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then # test a single .wav file CUDA_VISIBLE_DEVICES=0 ./local/test_hub.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 fi -if [ ${stage} -le 7 ] && [ ${stop_stage} -ge 7 ]; then +# Not supported at now!!! +if [ ${stage} -le 51 ] && [ ${stop_stage} -ge 51 ]; then + # export ckpt avg_n + CUDA_VISIBLE_DEVICES=0 ./local/export.sh ${conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} exp/${ckpt}/checkpoints/${avg_ckpt}.jit +fi + +# Need further installation! Read the install.md to complete further installation +if [ ${stage} -le 101 ] && [ ${stop_stage} -ge 101 ]; then echo "warning: deps on kaldi and srilm, please make sure installed." # train lm and build TLG ./local/tlg.sh --corpus aishell --lmtype srilm diff --git a/examples/aishell3/vc1/README.md b/examples/aishell3/vc1/README.md index 974b84cad..676678c99 100644 --- a/examples/aishell3/vc1/README.md +++ b/examples/aishell3/vc1/README.md @@ -21,7 +21,7 @@ We use [MFA2.x](https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner) You can download from here [aishell3_alignment_tone.tar.gz](https://paddlespeech.bj.bcebos.com/MFA/AISHELL-3/with_tone/aishell3_alignment_tone.tar.gz), or train your own MFA model reference to [mfa example](https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/examples/other/mfa) (use MFA1.x now) of our repo. ## Pretrained GE2E Model -We use pretrained GE2E model to generate spwaker embedding for each sentence. +We use pretrained GE2E model to generate speaker embedding for each sentence. Download pretrained GE2E model from here [ge2e_ckpt_0.3.zip](https://bj.bcebos.com/paddlespeech/Parakeet/released_models/ge2e/ge2e_ckpt_0.3.zip), and `unzip` it. diff --git a/examples/csmsc/voc3/conf/default.yaml b/examples/csmsc/voc3/conf/default.yaml index cc27220fc..5dda835ae 100644 --- a/examples/csmsc/voc3/conf/default.yaml +++ b/examples/csmsc/voc3/conf/default.yaml @@ -6,8 +6,7 @@ # This configuration is based on full-band MelGAN but the hop size and sampling # rate is different from the paper (16kHz vs 24kHz). The number of iteraions # is not shown in the paper so currently we train 1M iterations (not sure enough -# to converge). The optimizer setting is based on @dathudeptrai advice. -# https://github.com/kan-bayashi/ParallelWaveGAN/issues/143#issuecomment-632539906 +# to converge). ########################################################### # FEATURE EXTRACTION SETTING # @@ -136,4 +135,4 @@ eval_interval_steps: 1000 # Interval steps to evaluate the network # OTHER SETTING # ########################################################### num_snapshots: 10 # max number of snapshots to keep while training -seed: 42 # random seed for paddle, random, and np.random \ No newline at end of file +seed: 42 # random seed for paddle, random, and np.random diff --git a/examples/csmsc/voc3/conf/finetune.yaml b/examples/csmsc/voc3/conf/finetune.yaml index 80ab6bed7..302274019 100644 --- a/examples/csmsc/voc3/conf/finetune.yaml +++ b/examples/csmsc/voc3/conf/finetune.yaml @@ -6,8 +6,7 @@ # This configuration is based on full-band MelGAN but the hop size and sampling # rate is different from the paper (16kHz vs 24kHz). The number of iteraions # is not shown in the paper so currently we train 1M iterations (not sure enough -# to converge). The optimizer setting is based on @dathudeptrai advice. -# https://github.com/kan-bayashi/ParallelWaveGAN/issues/143#issuecomment-632539906 +# to converge). ########################################################### # FEATURE EXTRACTION SETTING # diff --git a/examples/librispeech/asr1/RESULTS.md b/examples/librispeech/asr1/RESULTS.md index 19300adea..a5257c9d4 100644 --- a/examples/librispeech/asr1/RESULTS.md +++ b/examples/librispeech/asr1/RESULTS.md @@ -21,7 +21,7 @@ ## Transformer | Model | Params | Config | Augmentation| Test set | Decode method | Loss | WER | | --- | --- | --- | --- | --- | --- | --- | --- | -| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | attention | 6.725063021977743 | 0.047417 | -| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | ctc_greedy_search | 6.725063021977743 | 0.053922 | -| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | ctc_prefix_beam_search | 6.725063021977743 | 0.053180 | -| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | attention_rescoring | 6.725063021977743 | 0.041026 | \ No newline at end of file +| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | attention | 6.484564081827799 | 0.044355 | +| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | ctc_greedy_search | 6.484564081827799 | 0.050479 | +| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | ctc_prefix_beam_search | 6.484564081827799 | 0.049890 | +| transformer | 32.52 M | conf/transformer.yaml | spec_aug | test-clean | attention_rescoring | 6.484564081827799 | 0.039200 | \ No newline at end of file diff --git a/examples/librispeech/asr1/conf/transformer.yaml b/examples/librispeech/asr1/conf/transformer.yaml index 1806f3fd6..0cc0dae63 100644 --- a/examples/librispeech/asr1/conf/transformer.yaml +++ b/examples/librispeech/asr1/conf/transformer.yaml @@ -1,3 +1,40 @@ +# network architecture +model: + cmvn_file: + cmvn_file_type: "json" + # encoder related + encoder: transformer + encoder_conf: + output_size: 256 # dimension of attention + attention_heads: 4 + linear_units: 2048 # the number of units of position-wise feed forward + num_blocks: 12 # the number of encoder blocks + dropout_rate: 0.1 + positional_dropout_rate: 0.1 + attention_dropout_rate: 0.0 + input_layer: conv2d # encoder input type, you can chose conv2d, conv2d6 and conv2d8 + normalize_before: true + + # decoder related + decoder: transformer + decoder_conf: + attention_heads: 4 + linear_units: 2048 + num_blocks: 6 + dropout_rate: 0.1 + positional_dropout_rate: 0.1 + self_attention_dropout_rate: 0.0 + src_attention_dropout_rate: 0.0 + + # hybrid CTC/attention + model_conf: + ctc_weight: 0.3 + ctc_dropoutrate: 0.0 + ctc_grad_norm_type: null + lsm_weight: 0.1 # label smoothing option + length_normalized_loss: false + + # https://yaml.org/type/float.html data: train_manifest: data/manifest.train @@ -36,43 +73,6 @@ collator: num_workers: 2 -# network architecture -model: - cmvn_file: - cmvn_file_type: "json" - # encoder related - encoder: transformer - encoder_conf: - output_size: 256 # dimension of attention - attention_heads: 4 - linear_units: 2048 # the number of units of position-wise feed forward - num_blocks: 12 # the number of encoder blocks - dropout_rate: 0.1 - positional_dropout_rate: 0.1 - attention_dropout_rate: 0.0 - input_layer: conv2d # encoder input type, you can chose conv2d, conv2d6 and conv2d8 - normalize_before: true - - # decoder related - decoder: transformer - decoder_conf: - attention_heads: 4 - linear_units: 2048 - num_blocks: 6 - dropout_rate: 0.1 - positional_dropout_rate: 0.1 - self_attention_dropout_rate: 0.0 - src_attention_dropout_rate: 0.0 - - # hybrid CTC/attention - model_conf: - ctc_weight: 0.3 - ctc_dropoutrate: 0.0 - ctc_grad_norm_type: null - lsm_weight: 0.1 # label smoothing option - length_normalized_loss: false - - training: n_epoch: 120 accum_grad: 4 diff --git a/examples/librispeech/asr2/RESULTS.md b/examples/librispeech/asr2/RESULTS.md index 41655565d..4cb2d2872 100644 --- a/examples/librispeech/asr2/RESULTS.md +++ b/examples/librispeech/asr2/RESULTS.md @@ -3,9 +3,9 @@ ## Transformer -| Model | Params | GPUS | Averaged Model | Config | Augmentation| Loss | -| --- | --- | --- | --- | --- | --- | -| transformer | 32.52 M | 8 Tesla V100-SXM2-32GB | 10-best val_loss | conf/transformer.yaml | spec_aug | 6.3197922706604 | +| Model | Params | GPUS | Averaged Model | Config | Augmentation| Loss | +| :-: | :-: | :------------: | :------------: | :-: | :-: | :-: | +| transformer | 32.52M | 8 Tesla V100-SXM2-32GB | 10-best val_loss | conf/transformer.yaml | spec_aug | 6.3197922706604 | ### Attention Rescore diff --git a/examples/librispeech/asr2/conf/transformer.yaml b/examples/librispeech/asr2/conf/transformer.yaml index 4a50183a9..3e9350abc 100644 --- a/examples/librispeech/asr2/conf/transformer.yaml +++ b/examples/librispeech/asr2/conf/transformer.yaml @@ -31,7 +31,7 @@ model: model_conf: ctc_weight: 0.3 ctc_dropoutrate: 0.0 - ctc_grad_norm_type: batch + ctc_grad_norm_type: null lsm_weight: 0.1 # label smoothing option length_normalized_loss: false diff --git a/examples/ted_en_zh/st0/conf/transformer_joint_noam.yaml b/examples/ted_en_zh/st0/conf/transformer_mtl_noam.yaml similarity index 99% rename from examples/ted_en_zh/st0/conf/transformer_joint_noam.yaml rename to examples/ted_en_zh/st0/conf/transformer_mtl_noam.yaml index 8256f7160..7e886cca3 100644 --- a/examples/ted_en_zh/st0/conf/transformer_joint_noam.yaml +++ b/examples/ted_en_zh/st0/conf/transformer_mtl_noam.yaml @@ -86,7 +86,7 @@ training: scheduler_conf: warmup_steps: 25000 lr_decay: 1.0 - log_interval: 5 + log_interval: 50 checkpoint: kbest_n: 50 latest_n: 5 diff --git a/examples/ted_en_zh/st0/local/data.sh b/examples/ted_en_zh/st0/local/data.sh index 097cd3a85..c4de1749e 100755 --- a/examples/ted_en_zh/st0/local/data.sh +++ b/examples/ted_en_zh/st0/local/data.sh @@ -42,7 +42,7 @@ if [ ${stage} -le -1 ] && [ ${stop_stage} -ge -1 ]; then # generate manifests python3 ${TARGET_DIR}/ted_en_zh/ted_en_zh.py \ --manifest_prefix="data/manifest" \ - --src_dir="${data_dir}" + --src-dir="${data_dir}" echo "Complete raw data pre-process." fi @@ -76,8 +76,9 @@ if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then --spm_vocab_size=${nbpe} \ --spm_mode ${bpemode} \ --spm_model_prefix ${bpeprefix} \ + --spm_character_coverage 1. \ --vocab_path="${dict_dir}/vocab.txt" \ - --text_keys 'text' 'text1' \ + --text_keys 'text' \ --manifest_paths="data/manifest.train.raw" if [ $? -ne 0 ]; then diff --git a/examples/ted_en_zh/st0/run.sh b/examples/ted_en_zh/st0/run.sh index fb4bc3388..bc5ee4e60 100755 --- a/examples/ted_en_zh/st0/run.sh +++ b/examples/ted_en_zh/st0/run.sh @@ -5,7 +5,7 @@ source path.sh gpus=0,1,2,3 stage=0 stop_stage=100 -conf_path=conf/transformer_joint_noam.yaml +conf_path=conf/transformer_mtl_noam.yaml avg_num=5 data_path=./TED_EnZh # path to unzipped data source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; diff --git a/examples/ted_en_zh/st1/cmd.sh b/examples/ted_en_zh/st1/cmd.sh new file mode 100644 index 000000000..7b70ef5e0 --- /dev/null +++ b/examples/ted_en_zh/st1/cmd.sh @@ -0,0 +1,89 @@ +# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ====== +# Usage: .pl [options] JOB=1: +# e.g. +# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB +# +# Options: +# --time