From 2b3b98522707f41cefa92ce2ab0b1dbf69172208 Mon Sep 17 00:00:00 2001 From: huangyuxin Date: Thu, 26 Aug 2021 05:04:10 +0000 Subject: [PATCH] fix paddling len --- deepspeech/models/ds2_online/deepspeech2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deepspeech/models/ds2_online/deepspeech2.py b/deepspeech/models/ds2_online/deepspeech2.py index d092b154b..5ef4431aa 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