File size: 9,956 Bytes
0f88e30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# Generated 2026-02-02 from:
# /gallery_rijks/jinyoung.park/streamalign/streamASR/hparams/train_chunk_streaming.yaml
# yamllint disable
# ############################################################################
# Model: E2E ASR with Conformer Transducer (Character-level)
# Encoder: Conformer with Dynamic Chunk Training
# Decoder: LSTM + greedy/beam search
# Tokens: Character-level (no BPE)
# Losses: Transducer + CTC (optional)
# Training: Librispeech
# 
# Modified for character-level prediction and CER evaluation
# ############################################################################

seed: 3407
__set_seed: !apply:speechbrain.utils.seed_everything [3407]
output_folder: results/conformer_transducer_char/3407
output_wer_folder: results/conformer_transducer_char/3407/
save_folder: results/conformer_transducer_char/3407/save
train_log: results/conformer_transducer_char/3407/train_log.txt

# Data files
data_folder: /gallery_rijks/jinyoung.park/datasets/LibriTTS

# Files to hold the manifest data
train_json: !ref <save_folder>/train.json
valid_json: !ref <save_folder>/valid.json
test_json: !ref <save_folder>/test.json

# Data splits
train_split: ["train-clean-100", "train-clean-360", "train-other-500"]
valid_split: ["dev-clean", "dev-other"]
test_split: ["test-clean", "test-other"]

skip_prep: false
ckpt_interval_minutes: 5
####################### Training Parameters ####################################

number_of_epochs: 100
warmup_steps: 25000
num_workers: 4
batch_size_valid: 4
lr: 0.0008
weight_decay: 0.01
number_of_ctc_epochs: 60
ctc_weight: 0.3
ce_weight: 0.0
max_grad_norm: 5.0
loss_reduction: batchmean
precision: fp16

batch_size: 8
grad_accumulation_factor: 4
sorting: random
avg_checkpoints: 10

# Feature parameters
sample_rate: 16000
n_fft: 512
n_mels: 80
win_length: 32

# ============================================================================
# Streaming & Dynamic Chunk Training
# ============================================================================
streaming: true

dynchunktrain_config_sampler: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfigRandomSampler
  chunkwise_prob: 0.6
  chunk_size_min: 8
  chunk_size_max: 32
  limited_left_context_prob: 0.75
  left_context_chunks_min: 2
  left_context_chunks_max: 32
   # Validation uses same streaming config as test
  valid_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
    chunk_size: 16
    left_context_size: 8
   # Test config with specific streaming parameters
  test_config: !new:speechbrain.utils.dynamic_chunk_training.DynChunkTrainConfig
    chunk_size: 16
    left_context_size: 8

# Dataloader options
train_dataloader_opts:
  batch_size: 8
  num_workers: 4

valid_dataloader_opts:
  batch_size: 4

test_dataloader_opts:
  batch_size: 4

# Dynamic batching
dynamic_batching: true
max_batch_len: 150
max_batch_len_val: 50
num_bucket: 200

dynamic_batch_sampler:
  max_batch_len: 150
  max_batch_len_val: 50
  num_buckets: 200
  shuffle_ex: true
  batch_ordering: random
  max_batch_ex: 256

####################### Model Parameters #######################################

# Transformer/Conformer
d_model: 512
joint_dim: 640
nhead: 8
num_encoder_layers: 12
num_decoder_layers: 0
d_ffn: 2048
transformer_dropout: 0.1
activation: &id005 !name:torch.nn.GELU


# ============================================================================
# Character-level output
# 72 characters + blank = 73 tokens (CTC_VOCAB_SIZE)
# space/punct/a-z/accented (0-71) + blank (72)
# ============================================================================
output_neurons: 73

# Decoder
dec_dim: 512
dec_emb_dropout: 0.2
dec_dropout: 0.1
attention_type: RelPosMHAXL

# Decoding parameters
blank_index: 72
bos_index: 72
eos_index: 72
pad_index: 72
beam_size: 10
nbest: 1
state_beam: 2.3
expand_beam: 2.3

# If True uses torchaudio loss
use_torchaudio: false

epoch_counter: &id019 !new:speechbrain.utils.epoch_loop.EpochCounter

  limit: 100

normalize: &id013 !new:speechbrain.processing.features.InputNormalization
  norm_type: global
  update_until_epoch: 4

compute_features: &id021 !new:speechbrain.lobes.features.Fbank
  sample_rate: 16000
  n_fft: 512
  n_mels: 80
  win_length: 32

############################## Augmentations ###################################

speed_perturb: &id001 !new:speechbrain.augment.time_domain.SpeedPerturb
  orig_freq: 16000
  speeds: [95, 100, 105]

wav_augment: !new:speechbrain.augment.augmenter.Augmenter
  min_augmentations: 1
  max_augmentations: 1
  augment_prob: 1.0
  augmentations: [*id001]

time_drop: &id002 !new:speechbrain.augment.freq_domain.SpectrogramDrop
  drop_length_low: 12
  drop_length_high: 20
  drop_count_low: 5
  drop_count_high: 5
  replace: zeros

freq_drop: &id003 !new:speechbrain.augment.freq_domain.SpectrogramDrop
  drop_length_low: 20
  drop_length_high: 25
  drop_count_low: 2
  drop_count_high: 2
  replace: zeros
  dim: 2

time_warp: &id004 !new:speechbrain.augment.freq_domain.Warping

fea_augment: !new:speechbrain.augment.augmenter.Augmenter
  parallel_augment: false
  concat_original: false
  repeat_augment: 1
  shuffle_augmentations: false
  min_augmentations: 3
  max_augmentations: 3
  augment_prob: 1.0
  augmentations: [*id002, *id003, *id004]

############################## Pretrained ###################################
pretrained_source: speechbrain/asr-streaming-conformer-librispeech
pretrained_save: results/conformer_transducer_char/3407/pretrained


############################## Models ##########################################

CNN: &id007 !new:speechbrain.lobes.models.convolution.ConvolutionFrontEnd
  input_shape: (8, 10, 80)
  num_blocks: 2
  num_layers_per_block: 1
  out_channels: (64, 32)
  kernel_sizes: (3, 3)
  strides: (2, 2)
  residuals: (False, False)

Transformer: &id006 !new:models.TransformerASR.TransformerASR

  input_size: 640
  tgt_vocab: 73
  d_model: 512
  nhead: 8
  num_encoder_layers: 12
  num_decoder_layers: 0
  d_ffn: 2048
  dropout: 0.1
  activation: *id005
  encoder_module: conformer
  attention_type: RelPosMHAXL
  normalize_before: true
  output_hidden_states: true
  causal: false

enc: &id008 !new:models.TransformerASR.EncoderWrapper
  transformer: *id006
proj_ctc: &id014 !new:speechbrain.nnet.linear.Linear
  input_size: 640
  n_neurons: 73

proj_enc: &id016 !new:speechbrain.nnet.linear.Linear

  input_size: 512
  n_neurons: 640
  bias: false

proj_dec: &id015 !new:speechbrain.nnet.linear.Linear
  input_size: 512
  n_neurons: 640
  bias: false

ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
  blank_index: 72
  reduction: batchmean

# Character embedding (output_neurons - 1 because blank is handled separately)
emb: &id009 !new:speechbrain.nnet.embedding.Embedding
  num_embeddings: 73
  consider_as_one_hot: true
  blank_id: 72

dec: &id010 !new:speechbrain.nnet.RNN.LSTM
  input_shape: [null, null, 72]
  hidden_size: 512
  num_layers: 1
  re_init: true

ce_cost: !name:speechbrain.nnet.losses.nll_loss
  label_smoothing: 0.1

Tjoint: &id011 !new:speechbrain.nnet.transducer.transducer_joint.Transducer_joint
  joint: sum
  nonlinearity: *id005
transducer_lin: &id012 !new:speechbrain.nnet.linear.Linear
  input_size: 640
  n_neurons: 73
  bias: false

log_softmax: !new:speechbrain.nnet.activations.Softmax
  apply_log: true

transducer_cost: !name:speechbrain.nnet.losses.transducer_loss
  blank_index: 72
  use_torchaudio: false

modules:
  CNN: *id007
  enc: *id008
  emb: *id009
  dec: *id010
  Tjoint: *id011
  transducer_lin: *id012
  normalize: *id013
  proj_ctc: *id014
  proj_dec: *id015
  proj_enc: *id016
model: &id017 !new:torch.nn.ModuleList
- [*id007, *id008, *id009, *id010, *id016, *id015, *id014, *id012]
Greedysearcher: &id020 !new:speechbrain.decoders.transducer.TransducerBeamSearcher
  decode_network_lst: [*id009, *id010, *id015]
  tjoint: *id011
  classifier_network: [*id012]
  blank_id: 72
  beam_size: 1
  nbest: 1

Beamsearcher: !new:speechbrain.decoders.transducer.TransducerBeamSearcher
  decode_network_lst: [*id009, *id010, *id015]
  tjoint: *id011
  classifier_network: [*id012]
  blank_id: 72
  beam_size: 10
  nbest: 1
  state_beam: 2.3
  expand_beam: 2.3

opt_class: !name:torch.optim.AdamW
  lr: 0.0008
  betas: (0.9, 0.98)
  eps: 1.e-8
  weight_decay: 0.01

noam_annealing: &id018 !new:speechbrain.nnet.schedulers.NoamScheduler
  lr_initial: 0.0008
  n_warmup_steps: 25000


############################## Logging and Checkpointing #######################

checkpointer: !new:speechbrain.utils.checkpoints.Checkpointer
  checkpoints_dir: results/conformer_transducer_char/3407/save
  recoverables:
    model: *id017
    scheduler: *id018
    normalizer: *id013
    counter: *id019
train_logger: !new:speechbrain.utils.train_logger.WandBLogger
  initializer: !name:wandb.init
    project: streamingAlign
    name: subalign
    dir: results/conformer_transducer_char/3407/wandb
    reinit: true
    resume: false

# CER computer (character-level)
cer_computer: !name:speechbrain.utils.metric_stats.ErrorRateStats
  split_tokens: true

############################## Streaming Inference #############################

# Streaming configuration for inference
# chunk_size: frames per chunk (8 frames ≈ 320ms after 4x subsampling)
# left_context_size: number of left context chunks
streaming_chunk_size: 16
streaming_left_context: 8

# Create streaming context for the decoder
make_decoder_streaming_context: !name:speechbrain.decoders.transducer.TransducerGreedySearcherStreamingContext

# Streaming decoding function
decoding_function: !name:speechbrain.decoders.transducer.TransducerBeamSearcher.transducer_greedy_decode_streaming
- *id020
fea_streaming_extractor: !new:speechbrain.lobes.features.StreamingFeatureWrapper
  module: !new:speechbrain.nnet.containers.LengthsCapableSequential
  - *id021
  - *id013
  - *id007
  properties: !apply:speechbrain.utils.filter_analysis.stack_filter_properties
  - [*id021, *id007]