From fe588bc508c0076bb007d6ed36c18ac8ecb341ac Mon Sep 17 00:00:00 2001
From: 王梦迪 <73778524+di-osc@users.noreply.github.com>
Date: 星期二, 20 五月 2025 16:10:59 +0800
Subject: [PATCH] Fsmn_vad支持多线程并发调用 (#2519)

---
 runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py b/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
index 9cfe46f..6a06ed1 100644
--- a/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
+++ b/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()

--
Gitblit v1.9.1