From 874ed3aaac591e2d1c29087b5f4e86ba66272f8b Mon Sep 17 00:00:00 2001
From: 维石 <shixian.shi@alibaba-inc.com>
Date: 星期五, 26 七月 2024 11:40:23 +0800
Subject: [PATCH] bug fix for onnx infer

---
 runtime/python/libtorch/funasr_torch/sensevoice_bin.py   |    3 +++
 runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/runtime/python/libtorch/funasr_torch/sensevoice_bin.py b/runtime/python/libtorch/funasr_torch/sensevoice_bin.py
index 4f79340..d4444e7 100644
--- a/runtime/python/libtorch/funasr_torch/sensevoice_bin.py
+++ b/runtime/python/libtorch/funasr_torch/sensevoice_bin.py
@@ -158,6 +158,9 @@
             feats, feats_len = self.extract_feat(waveform_list[beg_idx:end_idx])
             _language_list = language_list[beg_idx:end_idx]
             _textnorm_list = textnorm_list[beg_idx:end_idx]
+            if not len(_language_list):
+                _language_list = [language_list[0]]
+                _textnorm_list = [textnorm_list[0]]
             B = feats.shape[0]
             if len(_language_list) == 1 and B != 1:
                 _language_list = _language_list * B
diff --git a/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py b/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
index 41f9042..37c98a8 100644
--- a/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
+++ b/runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py
@@ -165,6 +165,9 @@
             feats, feats_len = self.extract_feat(waveform_list[beg_idx:end_idx])
             _language_list = language_list[beg_idx:end_idx]
             _textnorm_list = textnorm_list[beg_idx:end_idx]
+            if not len(_language_list):
+                _language_list = [language_list[0]]
+                _textnorm_list = [textnorm_list[0]]
             B = feats.shape[0]
             if len(_language_list) == 1 and B != 1:
                 _language_list = _language_list * B

--
Gitblit v1.9.1