From 10f65e1aecdb015a9b3e944152360a1f8dc8986c Mon Sep 17 00:00:00 2001 From: kobenaxie <572745565@qq.com> Date: Thu, 7 Dec 2023 20:52:47 +0800 Subject: [PATCH] Update frame_reducer.py --- .../pruned_transducer_stateless7_ctc_bs/frame_reducer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/frame_reducer.py b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/frame_reducer.py index 318eb58c32..9950fd4950 100644 --- a/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/frame_reducer.py +++ b/egs/librispeech/ASR/pruned_transducer_stateless7_ctc_bs/frame_reducer.py @@ -79,9 +79,11 @@ def forward( limit_lens = x_lens - y_lens max_limit_len = limit_lens.max().int() ctc_prob = ctc_output.exp() + ctc_prob = ctc_prob.masked_fill( + padding_mask.unsqueeze(-1), 0.0, + ) fake_limit_indexes = torch.topk( - ctc_prob[:, :, blank_id].masked_fill(padding_mask, 0.0), - k=max_limit_len, + ctc_prob[:, :, blank_id], max_limit_len ).indices T_arange = ( torch.arange(max_limit_len)