From 5dbe6898cac191d12c487772d7336ab2b2a9c350 Mon Sep 17 00:00:00 2001
From: Nixon <2465004358@qq.com>
Date: 星期三, 09 十月 2024 10:40:58 +0800
Subject: [PATCH] fix list index out of range error (#2122)
---
funasr/utils/postprocess_utils.py | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/funasr/utils/postprocess_utils.py b/funasr/utils/postprocess_utils.py
index c4a0789..10aa29f 100644
--- a/funasr/utils/postprocess_utils.py
+++ b/funasr/utils/postprocess_utils.py
@@ -125,9 +125,11 @@
if time_stamp is not None:
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])
- else:
- word_lists.append(words[num])
- if time_stamp is not None and words[num] != " ":
+ else:
+ # length of time_stamp may not equal to length of words because of the (somehow improper) threshold set in timestamp_tools.py line 46, e.g., length of time_stamp can be zero but length of words is not.
+ # Moreover, move "word_lists.append(words[num])" into if clause, to keep length of word_lists and length of ts_lists equal.
+ if time_stamp is not None and ts_nums[num]<len(time_stamp) and words[num] != " ":
+ word_lists.append(words[num])
begin = time_stamp[ts_nums[num]][0]
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])
--
Gitblit v1.9.1