Isuxiz Slidder
2025-03-31 3df109adfccedeb134dea4ba2ea9a2da89872048
Update model.py to fix "IndexError: index 1 is out of bounds for dimension 1 with size 0" (#2454)

* Update model.py

Avoid exception of "IndexError: index 1 is out of bounds for dimension 1 with size 0"

* Update model.py

Add return word in timestamps

* Revert "Update model.py"

This reverts commit bc736df30282e004b9b4b572e5f943cddf63eac0.
1个文件已修改
5 ■■■■■ 已修改文件
funasr/models/sense_voice/model.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
funasr/models/sense_voice/model.py
@@ -925,6 +925,11 @@
                    if tok_ls: token_ids.extend(tok_ls)
                    else: token_ids.append(124)
                if len(token_ids) == 0:
                    result_i = {"key": key[i], "text": text}
                    results.append(result_i)
                    continue
                logits_speech = self.ctc.softmax(encoder_out)[i, 4 : encoder_out_lens[i].item(), :]
                pred = logits_speech.argmax(-1).cpu()
                logits_speech[pred == self.blank_id, self.blank_id] = 0