Skip to content

fix list index out of range error - #2122

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
nixonjin:dev-nixon
Oct 9, 2024
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
nixonjin:dev-nixon

Conversation

@nixonjin

@nixonjin nixonjin commented Oct 8, 2024 •

Copy link
Copy Markdown
Contributor

list index out of range case 1:
2024-10-08T15:04:42.378018915+08:00 INFO:logger:Traceback (most recent call last):
2024-10-08T15:04:42.378026694+08:00 File "app.py", line 387, in pipeline
2024-10-08T15:04:42.378030230+08:00 reg = step1_asr(media_url)
2024-10-08T15:04:42.378033100+08:00 File "app.py", line 120, in step1_asr
2024-10-08T15:04:42.378035860+08:00 res = asr_model.generate(filename)
2024-10-08T15:04:42.378038943+08:00 File "/usr/local/services/asr/src/asr_model.py", line 371, in generate
2024-10-08T15:04:42.378041871+08:00 return self.inference_with_vad(input, input_len=input_len, **cfg)
2024-10-08T15:04:42.378045201+08:00 File "/usr/local/services/asr/src/asr_model.py", line 534, in inference_with_vad
2024-10-08T15:04:42.378048683+08:00 results = self.inference(
2024-10-08T15:04:42.378054236+08:00 File "/usr/local/services/asr/src/asr_model.py", line 411, in inference
2024-10-08T15:04:42.378057447+08:00 res = model.inference(**batch, **kwargs, cache={}) #nixon
2024-10-08T15:04:42.378060921+08:00 File "/usr/local/lib/python3.8/site-packages/funasr/models/seaco_paraformer/model.py", line 489, in inference
2024-10-08T15:04:42.378063817+08:00 postprocess_utils.sentence_postprocess(token, timestamp)
2024-10-08T15:04:42.378066886+08:00 File "/usr/local/lib/python3.8/site-packages/funasr/utils/postprocess_utils.py", line 247, in sentence_postprocess
2024-10-08T15:04:42.378069820+08:00 word_lists, ts_lists = abbr_dispose(word_lists, ts_lists)
2024-10-08T15:04:42.378072971+08:00 File "/usr/local/lib/python3.8/site-packages/funasr/utils/postprocess_utils.py", line 141, in abbr_dispose
2024-10-08T15:04:42.378075885+08:00 begin = time_stamp[ts_nums[num]][0]
2024-10-08T15:04:42.378078787+08:00 IndexError: list index out of range

# 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.

# time_stamp 的长度可能不等于 words 的长度,
# 因为 timestamp_tools.py 文件第 46 行设置了(某些情况下不合适的)阈值,
# 例如,time_stamp 的长度可以为零,但 words 的长度不是。
# 此外,将 "word_lists.append(words[num])" 移动到 if 语句中,以保持 word_lists 的长度和 ts_lists 的长度相等。

list index out of range case 2:
File "/usr/local/lib/python3.8/site-packages/funasr/utils/timestamp_tools.py", line 93, in ts_prediction_lfr6_standar
timestamp_list[-1][1] = num_frames * TIME_RATE
IndexError: list index out of range

timestamp_list 可能为空

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants