dd3434 commited on
Commit
0f88e30
·
verified ·
1 Parent(s): 7bd145d

Add StreamAlign R=32 tokenizer stack (mirror of js1044k/streamalign-r32-tokenizer)

Browse files
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - speech
5
+ - speech-tokenizer
6
+ - streaming
7
+ - rvq
8
+ - streamalign
9
+ library_name: pytorch
10
+ ---
11
+
12
+ # StreamAlign R=32 RVQ Speech Tokenizer
13
+
14
+ Streaming speech tokenizer reproducing the StreamAlign paper recipe:
15
+ a char-level RNN-T aligner (frozen encoder) with a word-aligned acoustic
16
+ head quantized by a plain ResidualVQ (**R=32 layers, codebook 512,
17
+ dim 256**), decoding to CosyVoice3 speech tokens for streaming
18
+ reconstruction (chunk_size=4, left_context=32).
19
+
20
+ ## Checkpoint
21
+
22
+ `final.pt` = phase-C (cosine) epoch 13. Dict keys:
23
+ `{epoch, hubert_state_dict, optimizer_state_dict, train_loss}`.
24
+ Load `hubert_state_dict` into
25
+ `models/model_tokenizer.py::Data2VecSemanticAcousticModel`
26
+ (streamASR, branch `refactor/tokenizer-r32`) with env
27
+ `RVQ_R=32 RVQ_CODEBOOK_SIZE=512`.
28
+
29
+ ## Training (3-phase, global batch 16)
30
+
31
+ | phase | trainer | LR | epochs |
32
+ |---|---|---|---|
33
+ | A continuous (RVQ_BYPASS=1) | train_tokenizer.py | 1e-4 | 15 |
34
+ | B RVQ on (subalign-init from A) | train_tokenizer.py | 1e-4 | 14 |
35
+ | C cosine finetune (from B) | train_tokenizer_cosine.py | 1e-5 -> 0 | 13 |
36
+
37
+ Data: LibriSpeech 960h + Emilia-EN 400h subset (precomputed CosyVoice3
38
+ features). Pipeline: `scripts/train_tokenizer_r32_pipeline.sh`.
39
+
40
+ ## Results (LibriSpeech test-clean 2620, streaming reconstruction)
41
+
42
+ | metric | value | note |
43
+ |---|---|---|
44
+ | WER | 4.43% | whisper-large-v3 (paper: 4.41%) |
45
+ | CER | 1.92% | |
46
+ | UTMOS | 4.23 | versa pseudo_mos |
47
+ | SECS | 0.585 | versa speaker, RawNet3 |
48
+
49
+ ## Dependencies at inference
50
+
51
+ Frozen char RNN-T encoder ckpt (stage 1), word/BPE streaming ASR +
52
+ tokenizer, boundary classifier, CosyVoice3-0.5B vocoder. See
53
+ `train_tokenizer_r32_pipeline.sh eval` for the exact wiring.
alignment.yaml ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated 2026-02-02 from:
2
+ # /gallery_rijks/jinyoung.park/streamalign/streamASR/hparams/train_chunk_streaming.yaml
3
+ # yamllint disable
4
+ # ############################################################################
5
+ # Model: E2E ASR with Conformer Transducer (Character-level)
6
+ # Encoder: Conformer with Dynamic Chunk Training
7
+ # Decoder: LSTM + greedy/beam search
8
+ # Tokens: Character-level (no BPE)
9
+ # Losses: Transducer + CTC (optional)
10
+ # Training: Librispeech
11
+ #
12
+ # Modified for character-level prediction and CER evaluation
13
+ # ############################################################################
14
+
15
+ seed: 3407
16
+ __set_seed: !apply:speechbrain.utils.seed_everything [3407]
17
+ output_folder: results/conformer_transducer_char/3407
18
+ output_wer_folder: results/conformer_transducer_char/3407/
19
+ save_folder: results/conformer_transducer_char/3407/save
20
+ train_log: results/conformer_transducer_char/3407/train_log.txt
21
+
22
+ # Data files
23
+ data_folder: /gallery_rijks/jinyoung.park/datasets/LibriTTS
24
+
25
+ # Files to hold the manifest data
26
+ train_json: !ref <save_folder>/train.json
27
+ valid_json: !ref <save_folder>/valid.json
28
+ test_json: !ref <save_folder>/test.json
29
+
30
+ # Data splits
31
+ train_split: ["train-clean-100", "train-clean-360", "train-other-500"]
32
+ valid_split: ["dev-clean", "dev-other"]
33
+ test_split: ["test-clean", "test-other"]
34
+
35
+ skip_prep: false
36
+ ckpt_interval_minutes: 5
37
+ ####################### Training Parameters ####################################
38
+
39
+ number_of_epochs: 100
40
+ warmup_steps: 25000
41
+ num_workers: 4
42
+ batch_size_valid: 4
43
+ lr: 0.0008
44
+ weight_decay: 0.01
45
+ number_of_ctc_epochs: 60
46
+ ctc_weight: 0.3
47
+ ce_weight: 0.0
48
+ max_grad_norm: 5.0
49
+ loss_reduction: batchmean
50
+ precision: fp16
51
+
52
+ batch_size: 8
53
+ grad_accumulation_factor: 4
54
+ sorting: random
55
+ avg_checkpoints: 10
56
+
57
+ # Feature parameters
58
+ sample_rate: 16000
59
+ n_fft: 512
60
+ n_mels: 80
61
+ win_length: 32
62
+
63
+ # ============================================================================
64
+ # Streaming & Dynamic Chunk Training
65
+ # ============================================================================
66
+ streaming: true
67
+
68
+ dynchunktrain_config_sampler: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfigRandomSampler
69
+ chunkwise_prob: 0.6
70
+ chunk_size_min: 8
71
+ chunk_size_max: 32
72
+ limited_left_context_prob: 0.75
73
+ left_context_chunks_min: 2
74
+ left_context_chunks_max: 32
75
+ # Validation uses same streaming config as test
76
+ valid_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
77
+ chunk_size: 16
78
+ left_context_size: 8
79
+ # Test config with specific streaming parameters
80
+ test_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
81
+ chunk_size: 16
82
+ left_context_size: 8
83
+
84
+ # Dataloader options
85
+ train_dataloader_opts:
86
+ batch_size: 8
87
+ num_workers: 4
88
+
89
+ valid_dataloader_opts:
90
+ batch_size: 4
91
+
92
+ test_dataloader_opts:
93
+ batch_size: 4
94
+
95
+ # Dynamic batching
96
+ dynamic_batching: true
97
+ max_batch_len: 150
98
+ max_batch_len_val: 50
99
+ num_bucket: 200
100
+
101
+ dynamic_batch_sampler:
102
+ max_batch_len: 150
103
+ max_batch_len_val: 50
104
+ num_buckets: 200
105
+ shuffle_ex: true
106
+ batch_ordering: random
107
+ max_batch_ex: 256
108
+
109
+ ####################### Model Parameters #######################################
110
+
111
+ # Transformer/Conformer
112
+ d_model: 512
113
+ joint_dim: 640
114
+ nhead: 8
115
+ num_encoder_layers: 12
116
+ num_decoder_layers: 0
117
+ d_ffn: 2048
118
+ transformer_dropout: 0.1
119
+ activation: &id005 !name:torch.nn.GELU
120
+
121
+
122
+ # ============================================================================
123
+ # Character-level output
124
+ # 72 characters + blank = 73 tokens (CTC_VOCAB_SIZE)
125
+ # space/punct/a-z/accented (0-71) + blank (72)
126
+ # ============================================================================
127
+ output_neurons: 73
128
+
129
+ # Decoder
130
+ dec_dim: 512
131
+ dec_emb_dropout: 0.2
132
+ dec_dropout: 0.1
133
+ attention_type: RelPosMHAXL
134
+
135
+ # Decoding parameters
136
+ blank_index: 72
137
+ bos_index: 72
138
+ eos_index: 72
139
+ pad_index: 72
140
+ beam_size: 10
141
+ nbest: 1
142
+ state_beam: 2.3
143
+ expand_beam: 2.3
144
+
145
+ # If True uses torchaudio loss
146
+ use_torchaudio: false
147
+
148
+ epoch_counter: &id019 !new:speechbrain.utils.epoch_loop.EpochCounter
149
+
150
+ limit: 100
151
+
152
+ normalize: &id013 !new:speechbrain.processing.features.InputNormalization
153
+ norm_type: global
154
+ update_until_epoch: 4
155
+
156
+ compute_features: &id021 !new:speechbrain.lobes.features.Fbank
157
+ sample_rate: 16000
158
+ n_fft: 512
159
+ n_mels: 80
160
+ win_length: 32
161
+
162
+ ############################## Augmentations ###################################
163
+
164
+ speed_perturb: &id001 !new:speechbrain.augment.time_domain.SpeedPerturb
165
+ orig_freq: 16000
166
+ speeds: [95, 100, 105]
167
+
168
+ wav_augment: !new:speechbrain.augment.augmenter.Augmenter
169
+ min_augmentations: 1
170
+ max_augmentations: 1
171
+ augment_prob: 1.0
172
+ augmentations: [*id001]
173
+
174
+ time_drop: &id002 !new:speechbrain.augment.freq_domain.SpectrogramDrop
175
+ drop_length_low: 12
176
+ drop_length_high: 20
177
+ drop_count_low: 5
178
+ drop_count_high: 5
179
+ replace: zeros
180
+
181
+ freq_drop: &id003 !new:speechbrain.augment.freq_domain.SpectrogramDrop
182
+ drop_length_low: 20
183
+ drop_length_high: 25
184
+ drop_count_low: 2
185
+ drop_count_high: 2
186
+ replace: zeros
187
+ dim: 2
188
+
189
+ time_warp: &id004 !new:speechbrain.augment.freq_domain.Warping
190
+
191
+ fea_augment: !new:speechbrain.augment.augmenter.Augmenter
192
+ parallel_augment: false
193
+ concat_original: false
194
+ repeat_augment: 1
195
+ shuffle_augmentations: false
196
+ min_augmentations: 3
197
+ max_augmentations: 3
198
+ augment_prob: 1.0
199
+ augmentations: [*id002, *id003, *id004]
200
+
201
+ ############################## Pretrained ###################################
202
+ pretrained_source: speechbrain/asr-streaming-conformer-librispeech
203
+ pretrained_save: results/conformer_transducer_char/3407/pretrained
204
+
205
+
206
+ ############################## Models ##########################################
207
+
208
+ CNN: &id007 !new:speechbrain.lobes.models.convolution.ConvolutionFrontEnd
209
+ input_shape: (8, 10, 80)
210
+ num_blocks: 2
211
+ num_layers_per_block: 1
212
+ out_channels: (64, 32)
213
+ kernel_sizes: (3, 3)
214
+ strides: (2, 2)
215
+ residuals: (False, False)
216
+
217
+ Transformer: &id006 !new:models.TransformerASR.TransformerASR
218
+
219
+ input_size: 640
220
+ tgt_vocab: 73
221
+ d_model: 512
222
+ nhead: 8
223
+ num_encoder_layers: 12
224
+ num_decoder_layers: 0
225
+ d_ffn: 2048
226
+ dropout: 0.1
227
+ activation: *id005
228
+ encoder_module: conformer
229
+ attention_type: RelPosMHAXL
230
+ normalize_before: true
231
+ output_hidden_states: true
232
+ causal: false
233
+
234
+ enc: &id008 !new:models.TransformerASR.EncoderWrapper
235
+ transformer: *id006
236
+ proj_ctc: &id014 !new:speechbrain.nnet.linear.Linear
237
+ input_size: 640
238
+ n_neurons: 73
239
+
240
+ proj_enc: &id016 !new:speechbrain.nnet.linear.Linear
241
+
242
+ input_size: 512
243
+ n_neurons: 640
244
+ bias: false
245
+
246
+ proj_dec: &id015 !new:speechbrain.nnet.linear.Linear
247
+ input_size: 512
248
+ n_neurons: 640
249
+ bias: false
250
+
251
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
252
+ blank_index: 72
253
+ reduction: batchmean
254
+
255
+ # Character embedding (output_neurons - 1 because blank is handled separately)
256
+ emb: &id009 !new:speechbrain.nnet.embedding.Embedding
257
+ num_embeddings: 73
258
+ consider_as_one_hot: true
259
+ blank_id: 72
260
+
261
+ dec: &id010 !new:speechbrain.nnet.RNN.LSTM
262
+ input_shape: [null, null, 72]
263
+ hidden_size: 512
264
+ num_layers: 1
265
+ re_init: true
266
+
267
+ ce_cost: !name:speechbrain.nnet.losses.nll_loss
268
+ label_smoothing: 0.1
269
+
270
+ Tjoint: &id011 !new:speechbrain.nnet.transducer.transducer_joint.Transducer_joint
271
+ joint: sum
272
+ nonlinearity: *id005
273
+ transducer_lin: &id012 !new:speechbrain.nnet.linear.Linear
274
+ input_size: 640
275
+ n_neurons: 73
276
+ bias: false
277
+
278
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
279
+ apply_log: true
280
+
281
+ transducer_cost: !name:speechbrain.nnet.losses.transducer_loss
282
+ blank_index: 72
283
+ use_torchaudio: false
284
+
285
+ modules:
286
+ CNN: *id007
287
+ enc: *id008
288
+ emb: *id009
289
+ dec: *id010
290
+ Tjoint: *id011
291
+ transducer_lin: *id012
292
+ normalize: *id013
293
+ proj_ctc: *id014
294
+ proj_dec: *id015
295
+ proj_enc: *id016
296
+ model: &id017 !new:torch.nn.ModuleList
297
+ - [*id007, *id008, *id009, *id010, *id016, *id015, *id014, *id012]
298
+ Greedysearcher: &id020 !new:speechbrain.decoders.transducer.TransducerBeamSearcher
299
+ decode_network_lst: [*id009, *id010, *id015]
300
+ tjoint: *id011
301
+ classifier_network: [*id012]
302
+ blank_id: 72
303
+ beam_size: 1
304
+ nbest: 1
305
+
306
+ Beamsearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
307
+ decode_network_lst: [*id009, *id010, *id015]
308
+ tjoint: *id011
309
+ classifier_network: [*id012]
310
+ blank_id: 72
311
+ beam_size: 10
312
+ nbest: 1
313
+ state_beam: 2.3
314
+ expand_beam: 2.3
315
+
316
+ opt_class: !name:torch.optim.AdamW
317
+ lr: 0.0008
318
+ betas: (0.9, 0.98)
319
+ eps: 1.e-8
320
+ weight_decay: 0.01
321
+
322
+ noam_annealing: &id018 !new:speechbrain.nnet.schedulers.NoamScheduler
323
+ lr_initial: 0.0008
324
+ n_warmup_steps: 25000
325
+
326
+
327
+ ############################## Logging and Checkpointing #######################
328
+
329
+ checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer
330
+ checkpoints_dir: results/conformer_transducer_char/3407/save
331
+ recoverables:
332
+ model: *id017
333
+ scheduler: *id018
334
+ normalizer: *id013
335
+ counter: *id019
336
+ train_logger: !new:speechbrain.utils.train_logger.WandBLogger
337
+ initializer: !name:wandb.init
338
+ project: streamingAlign
339
+ name: subalign
340
+ dir: results/conformer_transducer_char/3407/wandb
341
+ reinit: true
342
+ resume: false
343
+
344
+ # CER computer (character-level)
345
+ cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
346
+ split_tokens: true
347
+
348
+ ############################## Streaming Inference #############################
349
+
350
+ # Streaming configuration for inference
351
+ # chunk_size: frames per chunk (8 frames ≈ 320ms after 4x subsampling)
352
+ # left_context_size: number of left context chunks
353
+ streaming_chunk_size: 16
354
+ streaming_left_context: 8
355
+
356
+ # Create streaming context for the decoder
357
+ make_decoder_streaming_context: !name:speechbrain.decoders.transducer.TransducerGreedySearcherStreamingContext
358
+
359
+ # Streaming decoding function
360
+ decoding_function: !name:speechbrain.decoders.transducer.TransducerBeamSearcher.transducer_greedy_decode_streaming
361
+ - *id020
362
+ fea_streaming_extractor: !new:speechbrain.lobes.features.StreamingFeatureWrapper
363
+ module: !new:speechbrain.nnet.containers.LengthsCapableSequential
364
+ - *id021
365
+ - *id013
366
+ - *id007
367
+ properties: !apply:speechbrain.utils.filter_analysis.stack_filter_properties
368
+ - [*id021, *id007]
alignment_model/CKPT.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # yamllint disable
2
+ CER: 1.2645221513421072
3
+ end-of-epoch: true
4
+ epoch: 10
5
+ unixtime: 1786244238.4986734
alignment_model/model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed0fef7ab7b7e9e0c4f0606e1b778cccc38e0eb3a70f3e7688f84e13e8bd7eca
3
+ size 317974879
alignment_model/normalizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ed0e5ca389f2b8567fae0d954d3e16cbedcd95fb4f00fc65b45a1892903d276
3
+ size 2557
boundary_classifier/best_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5f03e0d79f33c678434197b64048614acb25c83d5f3202927f363ded0a76fdc
3
+ size 5793461
boundary_classifier/best_precision_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0dbf0d1829c16e9e3efaeaad8d7d01857bd451859407efd102d17adbbcc3f3ba
3
+ size 5793725
rvq_tokenizer/final.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3789ae92cc1afedb96145db25f29fd5cd01aac577a27de7a13a1f6eafe03d669
3
+ size 946819549
streaming_asr/chunk_streaming_word_fastemit.yaml ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ############################################################################
2
+ # Model: E2E ASR with transformer and transducer
3
+ # Encoder: Conformer
4
+ # Decoder: LSTM + beamsearch + RNNLM
5
+ # Tokens: BPE with unigram
6
+ # losses: Transducer + CTC (optional) + CE (optional)
7
+ # Training: Librispeech 960h
8
+ # Authors: Titouan Parcollet 2023, Abdel HEBA, Mirco Ravanelli, Sung-Lin Yeh 2020
9
+ # ############################################################################
10
+
11
+ # Seed needs to be set at top of yaml, before objects with parameters are made
12
+
13
+ seed: 3415
14
+ __set_seed: !apply:speechbrain.utils.seed_everything [3415]
15
+ output_folder: results/conformer_transducer_char/3415_fastemit
16
+ output_wer_folder: results/conformer_transducer_char/3415_fastemit/
17
+ save_folder: results/conformer_transducer_char/3407/save
18
+ checkpoint_folder: results/conformer_transducer_char/3415_fastemit/save
19
+ train_log: results/conformer_transducer_char/3415_fastemit/train_log.txt
20
+ pretrain_source: speechbrain/asr-streaming-conformer-librispeech
21
+ pretrain_folder: results/conformer_transducer_char/3415_fastemit/pretrained
22
+
23
+ # Data files
24
+ data_folder: /gallery_rijks/jinyoung.park/datasets/LibriSpeech
25
+ emilia_data_folder: /gallery_goya/kangwook.kim/datasets/Emilia-Dataset/Emilia/EN
26
+ emilia_train_csv: /gallery_rijks/jinyoung.park/datasets/Emilia/emilia_en_400h.csv
27
+
28
+ # CSV files (LibriSpeech, pre-existing from 3409 save)
29
+ train_csv:
30
+ - results/conformer_transducer_char/3409/train-clean-100.csv
31
+ - results/conformer_transducer_char/3409/train-clean-360.csv
32
+ - results/conformer_transducer_char/3409/train-other-500.csv
33
+
34
+ valid_csv: results/conformer_transducer_char/3409/dev-clean.csv
35
+
36
+ test_csv:
37
+ - results/conformer_transducer_char/3409/test-clean.csv
38
+ - results/conformer_transducer_char/3409/test-other.csv
39
+
40
+ ckpt_interval_minutes: 5
41
+ # Language model (LM) pretraining
42
+ # NB: To avoid mismatch, the speech recognizer must be trained with the same
43
+ # tokenizer used for LM training. Here, we download everything from the
44
+ # speechbrain HuggingFace repository. However, a local path pointing to a
45
+ # directory containing the lm.ckpt and tokenizer.ckpt may also be specified
46
+ # instead. E.g if you want to use your own LM / tokenizer.
47
+ pretrained_lm_tokenizer_path: speechbrain/asr-crdnn-rnnlm-librispeech
48
+
49
+
50
+ ####################### Training Parameters ####################################
51
+
52
+ # To make Transformers converge, the global bath size should be large enough.
53
+ # The global batch size is computed as batch_size * n_gpus * grad_accumulation_factor.
54
+ # Empirically, we found that this value should be >= 128.
55
+ # Please, set your parameters accordingly.
56
+ number_of_epochs: 100
57
+ num_workers: 4
58
+ batch_size_valid: 4
59
+ lr: 0.0004
60
+ weight_decay: 0.01
61
+ number_of_ctc_epochs: 60
62
+ ctc_weight: 0.3 # Multitask with CTC for the encoder (0.0 = disabled)
63
+ ce_weight: 0.0 # Multitask with CE for the decoder (0.0 = disabled)
64
+ max_grad_norm: 5.0
65
+ loss_reduction: 'batchmean'
66
+ precision: fp16 # bf16, fp16 or fp32
67
+
68
+ # The batch size is used if and only if dynamic batching is set to False
69
+ # Validation and testing are done with fixed batches and not dynamic batching.
70
+ batch_size: 6
71
+ grad_accumulation_factor: 4
72
+ sorting: random
73
+ avg_checkpoints: 10 # Number of checkpoints to average for evaluation
74
+
75
+ # Feature parameters
76
+ sample_rate: 16000
77
+ n_fft: 512
78
+ n_mels: 80
79
+ win_length: 32
80
+
81
+ # Streaming & dynamic chunk training options
82
+ # At least for the current architecture on LibriSpeech, we found out that
83
+ # non-streaming accuracy is very similar between `streaming: True` and
84
+ # `streaming: False`.
85
+ streaming: True # controls all Dynamic Chunk Training & chunk size & left context mechanisms
86
+
87
+ # Configuration for Dynamic Chunk Training.
88
+ # In this model, a chunk is roughly equivalent to 40ms of audio.
89
+ dynchunktrain_config_sampler: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfigRandomSampler # yamllint disable-line rule:line-length
90
+ chunkwise_prob: 1.0 # Probability during a batch to limit attention and sample a random chunk size in the following range
91
+ chunk_size_min: 4 # Minimum chunk size (if in a DynChunkTrain batch)
92
+ chunk_size_max: 4 # Maximum chunk size (if in a DynChunkTrain batch)
93
+ limited_left_context_prob: 1.0 # If in a DynChunkTrain batch, the probability during a batch to restrict left context to a random number of chunks
94
+ left_context_chunks_min: 32 # Minimum left context size (in # of chunks)
95
+ left_context_chunks_max: 32 # Maximum left context size (in # of chunks)
96
+ # If you specify a valid/test config, you can optionally have evaluation be
97
+ # done with a specific DynChunkTrain configuration.
98
+ valid_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
99
+ chunk_size: 4
100
+ left_context_size: 32
101
+
102
+ # Dataloader options
103
+ train_dataloader_opts:
104
+ batch_size: !ref <batch_size>
105
+ num_workers: !ref <num_workers>
106
+
107
+ valid_dataloader_opts:
108
+ batch_size: !ref <batch_size_valid>
109
+
110
+ test_dataloader_opts:
111
+ batch_size: !ref <batch_size_valid>
112
+
113
+ # This setup works well for 3090 24GB GPU, adapt it to your needs.
114
+ # Adjust grad_accumulation_factor depending on the DDP node count (here 3)
115
+ # Or turn it off (but training speed will decrease)
116
+ dynamic_batching: True
117
+ max_batch_len: 80
118
+ max_batch_len_val: 50 # we reduce it as the beam is much wider (VRAM)
119
+ num_bucket: 200
120
+
121
+ dynamic_batch_sampler:
122
+ max_batch_len: !ref <max_batch_len>
123
+ max_batch_len_val: !ref <max_batch_len_val>
124
+ num_buckets: !ref <num_bucket>
125
+ shuffle_ex: True # if true re-creates batches at each epoch shuffling examples.
126
+ batch_ordering: random
127
+ max_batch_ex: 256
128
+
129
+ ####################### Model Parameters #######################################
130
+
131
+ # Transformer
132
+ d_model: 512
133
+ joint_dim: 640
134
+ nhead: 8
135
+ num_encoder_layers: 12
136
+ num_decoder_layers: 0
137
+ d_ffn: 2048
138
+ transformer_dropout: 0.1
139
+ activation: !name:torch.nn.GELU
140
+ output_neurons: 1000
141
+ dec_dim: 512
142
+ dec_emb_dropout: 0.2
143
+ dec_dropout: 0.1
144
+ attention_type: RelPosMHAXL
145
+
146
+ # Decoding parameters
147
+ blank_index: 0
148
+ bos_index: 0
149
+ eos_index: 0
150
+ pad_index: 0
151
+ beam_size: 10
152
+ nbest: 1
153
+ # by default {state,expand}_beam = 2.3 as mention in paper
154
+ # https://arxiv.org/abs/1904.02619
155
+ state_beam: 2.3
156
+ expand_beam: 2.3
157
+ lm_weight: 0.50
158
+
159
+ # If True uses torchaudio loss. Otherwise, the numba one
160
+ use_torchaudio: False
161
+
162
+ epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter
163
+ limit: !ref <number_of_epochs>
164
+
165
+ normalize: !new:speechbrain.processing.features.InputNormalization
166
+ norm_type: global
167
+ update_until_epoch: 4
168
+
169
+ compute_features: !new:speechbrain.lobes.features.Fbank
170
+ sample_rate: !ref <sample_rate>
171
+ n_fft: !ref <n_fft>
172
+ n_mels: !ref <n_mels>
173
+ win_length: !ref <win_length>
174
+
175
+ ############################## Augmentations ###################################
176
+
177
+ # Speed perturbation
178
+ speed_perturb: !new:speechbrain.augment.time_domain.SpeedPerturb
179
+ orig_freq: !ref <sample_rate>
180
+ speeds: [95, 100, 105]
181
+
182
+ # Augmenter: Combines previously defined augmentations to perform data augmentation
183
+ wav_augment: !new:speechbrain.augment.augmenter.Augmenter
184
+ min_augmentations: 1
185
+ max_augmentations: 1
186
+ augment_prob: 1.0
187
+ augmentations: [!ref <speed_perturb>]
188
+
189
+
190
+ # Time Drop
191
+ time_drop: !new:speechbrain.augment.freq_domain.SpectrogramDrop
192
+ drop_length_low: 12
193
+ drop_length_high: 20
194
+ drop_count_low: 5
195
+ drop_count_high: 5
196
+ replace: "zeros"
197
+
198
+ # Frequency Drop
199
+ freq_drop: !new:speechbrain.augment.freq_domain.SpectrogramDrop
200
+ drop_length_low: 20
201
+ drop_length_high: 25
202
+ drop_count_low: 2
203
+ drop_count_high: 2
204
+ replace: "zeros"
205
+ dim: 2
206
+
207
+ # Time warp
208
+ time_warp: !new:speechbrain.augment.freq_domain.Warping
209
+
210
+ fea_augment: !new:speechbrain.augment.augmenter.Augmenter
211
+ parallel_augment: False
212
+ concat_original: False
213
+ repeat_augment: 1
214
+ shuffle_augmentations: False
215
+ min_augmentations: 3
216
+ max_augmentations: 3
217
+ augment_prob: 1.0
218
+ augmentations: [
219
+ !ref <time_drop>,
220
+ !ref <freq_drop>,
221
+ !ref <time_warp>]
222
+
223
+ ############################## Models ##########################################
224
+
225
+ CNN: !new:speechbrain.lobes.models.convolution.ConvolutionFrontEnd
226
+ input_shape: (8, 10, 80)
227
+ num_blocks: 2
228
+ num_layers_per_block: 1
229
+ out_channels: (64, 32)
230
+ kernel_sizes: (3, 3)
231
+ strides: (2, 2)
232
+ residuals: (False, False)
233
+
234
+ Transformer: !new:speechbrain.lobes.models.transformer.TransformerASR.TransformerASR # yamllint disable-line rule:line-length
235
+ input_size: 640
236
+ tgt_vocab: !ref <output_neurons>
237
+ d_model: !ref <d_model>
238
+ nhead: !ref <nhead>
239
+ num_encoder_layers: !ref <num_encoder_layers>
240
+ num_decoder_layers: !ref <num_decoder_layers>
241
+ d_ffn: !ref <d_ffn>
242
+ dropout: !ref <transformer_dropout>
243
+ activation: !ref <activation>
244
+ encoder_module: conformer
245
+ attention_type: !ref <attention_type>
246
+ normalize_before: True
247
+ causal: False
248
+
249
+ # We must call an encoder wrapper so the decoder isn't run (we don't have any)
250
+ enc: !new:speechbrain.lobes.models.transformer.TransformerASR.EncoderWrapper
251
+ transformer: !ref <Transformer>
252
+
253
+ # For MTL CTC over the encoder
254
+ proj_ctc: !new:speechbrain.nnet.linear.Linear
255
+ input_size: !ref <joint_dim>
256
+ n_neurons: !ref <output_neurons>
257
+
258
+ # Define some projection layers to make sure that enc and dec
259
+ # output dim are the same before joining
260
+ proj_enc: !new:speechbrain.nnet.linear.Linear
261
+ input_size: !ref <d_model>
262
+ n_neurons: !ref <joint_dim>
263
+ bias: False
264
+
265
+ proj_dec: !new:speechbrain.nnet.linear.Linear
266
+ input_size: !ref <dec_dim>
267
+ n_neurons: !ref <joint_dim>
268
+ bias: False
269
+
270
+ # Uncomment for MTL with CTC
271
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
272
+ blank_index: !ref <blank_index>
273
+ reduction: !ref <loss_reduction>
274
+
275
+ emb: !new:speechbrain.nnet.embedding.Embedding
276
+ num_embeddings: !ref <output_neurons>
277
+ consider_as_one_hot: True
278
+ blank_id: !ref <blank_index>
279
+
280
+ dec: !new:speechbrain.nnet.RNN.LSTM
281
+ input_shape: [null, null, !ref <output_neurons> - 1]
282
+ hidden_size: !ref <dec_dim>
283
+ num_layers: 1
284
+ re_init: True
285
+
286
+ # For MTL with LM over the decoder (need to uncomment to activate)
287
+ # dec_lin: !new:speechbrain.nnet.linear.Linear
288
+ # input_size: !ref <joint_dim>
289
+ # n_neurons: !ref <output_neurons>
290
+ # bias: False
291
+
292
+ # For MTL
293
+ ce_cost: !name:speechbrain.nnet.losses.nll_loss
294
+ label_smoothing: 0.1
295
+
296
+ Tjoint: !new:speechbrain.nnet.transducer.transducer_joint.Transducer_joint
297
+ joint: sum # joint [sum | concat]
298
+ nonlinearity: !ref <activation>
299
+
300
+ transducer_lin: !new:speechbrain.nnet.linear.Linear
301
+ input_size: !ref <joint_dim>
302
+ n_neurons: !ref <output_neurons>
303
+ bias: False
304
+
305
+ log_softmax: !new:speechbrain.nnet.activations.Softmax
306
+ apply_log: True
307
+
308
+ transducer_cost: !name:speechbrain.nnet.losses.transducer_loss
309
+ blank_index: !ref <blank_index>
310
+ use_torchaudio: !ref <use_torchaudio>
311
+
312
+ # This is the RNNLM that is used according to the Huggingface repository
313
+ # NB: It has to match the pre-trained RNNLM!!
314
+ lm_model: !new:speechbrain.lobes.models.RNNLM.RNNLM
315
+ output_neurons: !ref <output_neurons>
316
+ embedding_dim: 128
317
+ activation: !name:torch.nn.LeakyReLU
318
+ dropout: 0.0
319
+ rnn_layers: 2
320
+ rnn_neurons: 2048
321
+ dnn_blocks: 1
322
+ dnn_neurons: 512
323
+ return_hidden: True # For inference
324
+
325
+ # for MTL
326
+ # update model if any HEAD module is added
327
+ modules:
328
+ CNN: !ref <CNN>
329
+ enc: !ref <enc>
330
+ emb: !ref <emb>
331
+ dec: !ref <dec>
332
+ Tjoint: !ref <Tjoint>
333
+ transducer_lin: !ref <transducer_lin>
334
+ normalize: !ref <normalize>
335
+ lm_model: !ref <lm_model>
336
+ proj_ctc: !ref <proj_ctc>
337
+ proj_dec: !ref <proj_dec>
338
+ proj_enc: !ref <proj_enc>
339
+ # dec_lin: !ref <dec_lin>
340
+
341
+ # for MTL
342
+ # update model if any HEAD module is added
343
+ model: !new:torch.nn.ModuleList
344
+ - [!ref <CNN>, !ref <enc>, !ref <emb>, !ref <dec>, !ref <proj_enc>, !ref <proj_dec>, !ref <proj_ctc>, !ref <transducer_lin>]
345
+
346
+ ############################## Decoding & optimiser ############################
347
+
348
+ # Tokenizer initialization
349
+ tokenizer: !new:sentencepiece.SentencePieceProcessor
350
+
351
+ Greedysearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
352
+ decode_network_lst: [!ref <emb>, !ref <dec>, !ref <proj_dec>]
353
+ tjoint: !ref <Tjoint>
354
+ classifier_network: [!ref <transducer_lin>]
355
+ blank_id: !ref <blank_index>
356
+ beam_size: 1
357
+ nbest: 1
358
+
359
+ Beamsearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
360
+ decode_network_lst: [!ref <emb>, !ref <dec>, !ref <proj_dec>]
361
+ tjoint: !ref <Tjoint>
362
+ classifier_network: [!ref <transducer_lin>]
363
+ blank_id: !ref <blank_index>
364
+ beam_size: !ref <beam_size>
365
+ nbest: !ref <nbest>
366
+ lm_module: !ref <lm_model>
367
+ lm_weight: !ref <lm_weight>
368
+ state_beam: !ref <state_beam>
369
+ expand_beam: !ref <expand_beam>
370
+
371
+ opt_class: !name:torch.optim.AdamW
372
+ lr: !ref <lr>
373
+ betas: (0.9, 0.98)
374
+ eps: 1.e-8
375
+ weight_decay: !ref <weight_decay>
376
+
377
+ ############################## Logging and Pretrainer ##########################
378
+
379
+ checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer
380
+ checkpoints_dir: !ref <checkpoint_folder>
381
+ recoverables:
382
+ model: !ref <model>
383
+ normalizer: !ref <normalize>
384
+ counter: !ref <epoch_counter>
385
+
386
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
387
+ collect_in: !ref <pretrain_folder>
388
+ loadables:
389
+ model: !ref <model>
390
+ tokenizer: !ref <tokenizer>
391
+ normalizer: !ref <normalize>
392
+ paths:
393
+ model: !ref <pretrain_source>/model.ckpt
394
+ tokenizer: !ref <pretrain_source>/tokenizer.ckpt
395
+ normalizer: !ref <pretrain_source>/normalizer.ckpt
396
+
397
+ train_logger: !new:speechbrain.utils.train_logger.WandBLogger
398
+ initializer: !name:wandb.init
399
+ project: streaming-asr
400
+ name: conformer_transducer_char
401
+ dir: results/conformer_transducer_char/3415_casual/wandb
402
+ reinit: true
403
+ resume: false
404
+
405
+
406
+ error_rate_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
407
+
408
+ cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
409
+ split_tokens: True
410
+
411
+
412
+ make_tokenizer_streaming_context: !name:speechbrain.tokenizers.SentencePiece.SentencePieceDecoderStreamingContext
413
+ tokenizer_decode_streaming: !name:speechbrain.tokenizers.SentencePiece.spm_decode_preserve_leading_space
414
+
415
+ make_decoder_streaming_context: !name:speechbrain.decoders.transducer.TransducerGreedySearcherStreamingContext # default constructor
416
+ decoding_function: !name:speechbrain.decoders.transducer.TransducerBeamSearcher.transducer_greedy_decode_streaming
417
+ - !ref <Greedysearcher> # self
418
+
419
+ fea_streaming_extractor: !new:speechbrain.lobes.features.StreamingFeatureWrapper
420
+ module: !new:speechbrain.nnet.containers.LengthsCapableSequential
421
+ - !ref <compute_features>
422
+ - !ref <normalize>
423
+ - !ref <CNN>
424
+ # don't consider normalization as part of the input filter chain.
425
+ # normalization will operate at chunk level, which mismatches training
426
+ # somewhat, but does not appear to result in noticeable degradation.
427
+ properties: !apply:speechbrain.utils.filter_analysis.stack_filter_properties
428
+ - [!ref <compute_features>, !ref <CNN>]
streaming_asr/model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4aa2afbc47ffb8af9c9273256bac77b6dd13c9767bd5c81d32208c596c88b0c9
3
+ size 334293791
streaming_asr/normalizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:752b6fe11562ef768efd418897bba1e2dbe12e72a5451aff2b5b8b214ca1d62e
3
+ size 2621
streaming_asr/tokenizer.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:37a6cba34cd520b33fd83612d5efc8ba7e351166541eb2726642bb3032234d31
3
+ size 253217