From 08b031bc0a480748ec91e7d3d593f3fa2ed1256c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E9=9C=87=E4=B8=9C?= <275331498@qq.com> Date: Mon, 22 Jul 2024 16:24:02 +0800 Subject: [PATCH] [fix] fix paraformer search.py (#2580) * [fix] fix paraformer search.py * fix lint --- wenet/paraformer/search.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wenet/paraformer/search.py b/wenet/paraformer/search.py index 5bb3cc67e2..702ace0f98 100644 --- a/wenet/paraformer/search.py +++ b/wenet/paraformer/search.py @@ -126,12 +126,13 @@ def gen_timestamps_from_peak(cif_peaks: List[int], else: split = fire_place[i] + MAX_TOKEN_DURATION times.append([fire_place[i] * frame_rate, split * frame_rate]) - if num_frames - fire_place[-1] > START_END_THRESHOLD: - end = (num_frames + fire_place[-1]) * 0.5 - times[-1][1] = end * frame_rate - times.append([end * frame_rate, num_frames * frame_rate]) - else: - times[-1][1] = num_frames * frame_rate + if len(times) > 0: + if num_frames - fire_place[-1] > START_END_THRESHOLD: + end = (num_frames + fire_place[-1]) * 0.5 + times[-1][1] = end * frame_rate + times.append([end * frame_rate, num_frames * frame_rate]) + else: + times[-1][1] = num_frames * frame_rate return times