diff --git a/deepspeech/models/ds2_online/deepspeech2.py b/deepspeech/models/ds2_online/deepspeech2.py index d092b154b3bf5033b4452beaba8ec5f6522a9a6b..5ef4431aa16b661bfa5586d4725b95bcf0c9ac3e 100644 --- a/deepspeech/models/ds2_online/deepspeech2.py +++ b/deepspeech/models/ds2_online/deepspeech2.py @@ -180,8 +180,10 @@ class CRNNEncoder(nn.Layer): eouts_chunk_list = [] eouts_chunk_lens_list = [] - - padding_len = chunk_stride - (max_len - chunk_size) % chunk_stride + if (max_len - chunk_size) % chunk_stride != 0: + padding_len = chunk_stride - (max_len - chunk_size) % chunk_stride + else: + padding_len = 0 padding = paddle.zeros((x.shape[0], padding_len, x.shape[2])) padded_x = paddle.concat([x, padding], axis=1) num_chunk = (max_len + padding_len - chunk_size) / chunk_stride + 1