majic31
2024-12-24 ae7aff2e9cf6c79cf61e18cdc60ce68cf9f98400
fix: solve problems in sensevoice_bin.py related to argmax and unique, as mentioned in issue #2331 (#2332)

1个文件已修改
6 ■■■■■ 已修改文件
runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
@@ -183,8 +183,10 @@
                #     ctc_logits = torch.from_numpy(ctc_logits).float()
                # support batch_size=1 only currently
                x = ctc_logits[b, : encoder_out_lens[b].item(), :]
                yseq = x.argmax(dim=-1)
                yseq = np.unique(yseq)
                yseq = np.argmax(x, axis=-1)
                # Use np.diff and np.where instead of torch.unique_consecutive.
                mask = np.concatenate(([True], np.diff(yseq) != 0))
                yseq = yseq[mask]
                mask = yseq != self.blank_id
                token_int = yseq[mask].tolist()