|
| 1 | +# Model: wav2vec2 + DNN + CTC |
| 2 | +# Augmentation: SpecAugment |
| 3 | +# Authors: Titouan Parcollet 2021 |
| 4 | +# Mirco Ravanelli 2021 |
| 5 | +# Sangeet Sagar 2022 |
| 6 | +# ################################ |
| 7 | + |
| 8 | +# Seed needs to be set at top of yaml, before objects with parameters are made |
| 9 | +seed: 8200 |
| 10 | +__set_seed: !apply:torch.manual_seed [!ref <seed>] |
| 11 | +output_folder: !ref results/wav2vec2_ctc_de/<seed> |
| 12 | +wer_file: !ref <output_folder>/wer.txt |
| 13 | +save_folder: !ref <output_folder>/save |
| 14 | +train_log: !ref <output_folder>/train_log.txt |
| 15 | + |
| 16 | +# URL for the LARGE Fairseq German wav2vec2 model. |
| 17 | +wav2vec2_hub: facebook/wav2vec2-large-xlsr-53-german |
| 18 | + |
| 19 | +# Dataset prep parameters |
| 20 | +data_folder: !PLACEHOLDER |
| 21 | +train_tsv_file: !ref <data_folder>/train.tsv |
| 22 | +dev_tsv_file: !ref <data_folder>/dev.tsv |
| 23 | +test_tsv_file: !ref <data_folder>/test.tsv |
| 24 | +accented_letters: True |
| 25 | +language: de |
| 26 | +train_csv: !ref <save_folder>/train.csv |
| 27 | +valid_csv: !ref <save_folder>/dev.csv |
| 28 | +test_csv: !ref <save_folder>/test.csv |
| 29 | +skip_prep: False |
| 30 | + |
| 31 | +# We remove utterance slonger than 10s in the train/dev/test sets as |
| 32 | +# longer sentences certainly correspond to "open microphones". |
| 33 | +avoid_if_longer_than: 10.0 |
| 34 | + |
| 35 | +# Training parameters |
| 36 | +number_of_epochs: 45 |
| 37 | +lr: 1.0 |
| 38 | +lr_wav2vec: 0.0001 |
| 39 | +sorting: ascending |
| 40 | +auto_mix_prec: False |
| 41 | +sample_rate: 16000 |
| 42 | +ckpt_interval_minutes: 30 # save checkpoint every N min |
| 43 | + |
| 44 | +# With data_parallel batch_size is split into N jobs |
| 45 | +# With DDP batch_size is multiplied by N jobs |
| 46 | +# Must be 6 per GPU to fit 16GB of VRAM |
| 47 | +batch_size: 8 |
| 48 | +test_batch_size: 8 |
| 49 | +dataloader_num_workers: 8 |
| 50 | +test_num_workers: 8 |
| 51 | + |
| 52 | +dataloader_options: |
| 53 | + batch_size: !ref <batch_size> |
| 54 | + num_workers: !ref <dataloader_num_workers> |
| 55 | +test_dataloader_options: |
| 56 | + batch_size: !ref <test_batch_size> |
| 57 | + num_workers: !ref <test_num_workers> |
| 58 | + |
| 59 | +# BPE parameters |
| 60 | +token_type: char # ["unigram", "bpe", "char"] |
| 61 | +character_coverage: 1.0 |
| 62 | + |
| 63 | +# Model parameters |
| 64 | +# activation: !name:torch.nn.LeakyReLU |
| 65 | +dnn_neurons: 1024 |
| 66 | +wav2vec_output_dim: !ref <dnn_neurons> |
| 67 | +freeze_wav2vec: False |
| 68 | +dropout: 0.15 |
| 69 | + |
| 70 | +# Outputs |
| 71 | +output_neurons: 32 # BPE size, index(blank/eos/bos) = 0 |
| 72 | + |
| 73 | +# Be sure that the bos and eos index match with the BPEs ones |
| 74 | +blank_index: 0 |
| 75 | +bos_index: 1 |
| 76 | +eos_index: 2 |
| 77 | + |
| 78 | +# Functions and classes |
| 79 | +epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter |
| 80 | + limit: !ref <number_of_epochs> |
| 81 | + |
| 82 | +augmentation: !new:speechbrain.lobes.augment.TimeDomainSpecAugment |
| 83 | + sample_rate: !ref <sample_rate> |
| 84 | + speeds: [95, 100, 105] |
| 85 | + |
| 86 | +enc: !new:speechbrain.nnet.containers.Sequential |
| 87 | + input_shape: [null, null, !ref <wav2vec_output_dim>] |
| 88 | + linear1: !name:speechbrain.nnet.linear.Linear |
| 89 | + n_neurons: !ref <dnn_neurons> |
| 90 | + bias: True |
| 91 | + bn1: !name:speechbrain.nnet.normalization.BatchNorm1d |
| 92 | + activation: !new:torch.nn.LeakyReLU |
| 93 | + drop: !new:torch.nn.Dropout |
| 94 | + p: !ref <dropout> |
| 95 | + linear2: !name:speechbrain.nnet.linear.Linear |
| 96 | + n_neurons: !ref <dnn_neurons> |
| 97 | + bias: True |
| 98 | + bn2: !name:speechbrain.nnet.normalization.BatchNorm1d |
| 99 | + activation2: !new:torch.nn.LeakyReLU |
| 100 | + drop2: !new:torch.nn.Dropout |
| 101 | + p: !ref <dropout> |
| 102 | + linear3: !name:speechbrain.nnet.linear.Linear |
| 103 | + n_neurons: !ref <dnn_neurons> |
| 104 | + bias: True |
| 105 | + bn3: !name:speechbrain.nnet.normalization.BatchNorm1d |
| 106 | + activation3: !new:torch.nn.LeakyReLU |
| 107 | + |
| 108 | +wav2vec2: !new:speechbrain.lobes.models.huggingface_wav2vec.HuggingFaceWav2Vec2 |
| 109 | + source: !ref <wav2vec2_hub> |
| 110 | + output_norm: True |
| 111 | + freeze: !ref <freeze_wav2vec> |
| 112 | + save_path: !ref <save_folder>/wav2vec2_checkpoint |
| 113 | + |
| 114 | +##### |
| 115 | +# Uncomment this block if you prefer to use a Fairseq pretrained model instead |
| 116 | +# of a HuggingFace one. Here, we provide an URL that is obtained from the |
| 117 | +# Fairseq github for the multilingual XLSR. |
| 118 | +# |
| 119 | +#wav2vec2_url: https://dl.fbaipublicfiles.com/fairseq/wav2vec/wav2vec_vox_960h_pl.pt |
| 120 | +#wav2vec2: !new:speechbrain.lobes.models.fairseq_wav2vec.FairseqWav2Vec2 |
| 121 | +# pretrained_path: !ref <wav2vec2_url> |
| 122 | +# output_norm: True |
| 123 | +# freeze: False |
| 124 | +# save_path: !ref <save_folder>/wav2vec2_checkpoint/model.pt |
| 125 | + |
| 126 | +ctc_lin: !new:speechbrain.nnet.linear.Linear |
| 127 | + input_size: !ref <dnn_neurons> |
| 128 | + n_neurons: !ref <output_neurons> |
| 129 | + |
| 130 | +log_softmax: !new:speechbrain.nnet.activations.Softmax |
| 131 | + apply_log: True |
| 132 | + |
| 133 | +ctc_cost: !name:speechbrain.nnet.losses.ctc_loss |
| 134 | + blank_index: !ref <blank_index> |
| 135 | + |
| 136 | +modules: |
| 137 | + wav2vec2: !ref <wav2vec2> |
| 138 | + enc: !ref <enc> |
| 139 | + ctc_lin: !ref <ctc_lin> |
| 140 | + |
| 141 | +model: !new:torch.nn.ModuleList |
| 142 | + - [!ref <enc>, !ref <ctc_lin>] |
| 143 | + |
| 144 | +model_opt_class: !name:torch.optim.Adadelta |
| 145 | + lr: !ref <lr> |
| 146 | + rho: 0.95 |
| 147 | + eps: 1.e-8 |
| 148 | + |
| 149 | +wav2vec_opt_class: !name:torch.optim.Adam |
| 150 | + lr: !ref <lr_wav2vec> |
| 151 | + |
| 152 | +lr_annealing_model: !new:speechbrain.nnet.schedulers.NewBobScheduler |
| 153 | + initial_value: !ref <lr> |
| 154 | + improvement_threshold: 0.0025 |
| 155 | + annealing_factor: 0.8 |
| 156 | + patient: 0 |
| 157 | + |
| 158 | +lr_annealing_wav2vec: !new:speechbrain.nnet.schedulers.NewBobScheduler |
| 159 | + initial_value: !ref <lr_wav2vec> |
| 160 | + improvement_threshold: 0.0025 |
| 161 | + annealing_factor: 0.9 |
| 162 | + patient: 0 |
| 163 | + |
| 164 | +checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer |
| 165 | + checkpoints_dir: !ref <save_folder> |
| 166 | + recoverables: |
| 167 | + wav2vec2: !ref <wav2vec2> |
| 168 | + model: !ref <model> |
| 169 | + scheduler_model: !ref <lr_annealing_model> |
| 170 | + scheduler_wav2vec: !ref <lr_annealing_wav2vec> |
| 171 | + counter: !ref <epoch_counter> |
| 172 | + |
| 173 | +train_logger: !new:speechbrain.utils.train_logger.FileTrainLogger |
| 174 | + save_file: !ref <train_log> |
| 175 | + |
| 176 | +error_rate_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats |
| 177 | + |
| 178 | +cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats |
| 179 | + split_tokens: True |
0 commit comments