File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -177,11 +177,10 @@ def compute_fbank(data,
177
177
waveform = sample ['speech' ]
178
178
feat = feat_extractor (waveform ).squeeze (dim = 0 ).transpose (0 , 1 )
179
179
180
- # padding with replicate mode (align to speech_token len * token_mel_ratio)
181
- pad_len = sample ["speech_token" ].shape [0 ] * token_mel_ratio - feat .shape [0 ]
182
- if pad_len > 0 :
183
- feat_to_pad = feat [- 1 :].repeat ((pad_len , 1 ))
184
- feat = torch .cat ([feat , feat_to_pad ], dim = 0 )
180
+ # trim to align speech_token and speech_feat
181
+ token_len = min (feat .shape [0 ] // token_mel_ratio , sample ["speech_token" ].shape [0 ])
182
+ feat = feat [:token_mel_ratio * token_len ]
183
+ sample ["speech_token" ] = sample ["speech_token" ][:token_len ]
185
184
186
185
sample ['speech_feat' ] = feat
187
186
yield sample
You can’t perform that action at this time.
0 commit comments