fix list index out of range error (#2122)

Co-authored-by: nixonjin <nixonjin@tencent.com>
This commit is contained in:
Nixon 2024-10-09 10:40:58 +08:00 committed by GitHub
parent 0bf8edca37
commit 5dbe6898ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -126,8 +126,10 @@ def abbr_dispose(words: List[Any], time_stamp: List[List] = None) -> List[Any]:
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])
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])
if time_stamp is not None and words[num] != " ":
begin = time_stamp[ts_nums[num]][0]
end = time_stamp[ts_nums[num]][1]
ts_lists.append([begin, end])

View File

@ -84,6 +84,7 @@ def ts_prediction_lfr6_standard(
timestamp_list.append([_end * TIME_RATE, num_frames * TIME_RATE])
new_char_list.append("<sil>")
else:
if len(timestamp_list)>0:
timestamp_list[-1][1] = num_frames * TIME_RATE
if vad_offset: # add offset time in model with vad
for i in range(len(timestamp_list)):