From 268adb8c1eafb95498e91b9657ed7f66d4d71c20 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期三, 09 八月 2023 22:26:19 +0800
Subject: [PATCH] fix catch for vad

---
 funasr/runtime/websocket/funasr-wss-client-2pass.cpp |    4 ++--
 funasr/runtime/onnxruntime/src/fsmn-vad.cpp          |    2 +-
 funasr/runtime/onnxruntime/src/fsmn-vad-online.cpp   |    3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/funasr/runtime/onnxruntime/src/fsmn-vad-online.cpp b/funasr/runtime/onnxruntime/src/fsmn-vad-online.cpp
index 58bda62..b9cda4b 100644
--- a/funasr/runtime/onnxruntime/src/fsmn-vad-online.cpp
+++ b/funasr/runtime/onnxruntime/src/fsmn-vad-online.cpp
@@ -140,6 +140,9 @@
       return vad_segments;
     }
     fsmnvad_handle_->Forward(vad_feats, &vad_probs, &in_cache_, input_finished);
+    if(vad_probs.size() == 0){
+      return vad_segments;
+    }
 
     vad_segments = vad_scorer(vad_probs, waves, input_finished, true, vad_silence_duration_, vad_max_len_,
                               vad_speech_noise_thres_, vad_sample_rate_);
diff --git a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
index 8ba09c7..50a9a03 100644
--- a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
+++ b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
@@ -148,7 +148,7 @@
                 vad_inputs.size(), vad_out_names_.data(), vad_out_names_.size());
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when run vad onnx forword: " << (e.what());
-        exit(-1);
+        return;
     }
 
     // 5. Change infer result to output shapes
diff --git a/funasr/runtime/websocket/funasr-wss-client-2pass.cpp b/funasr/runtime/websocket/funasr-wss-client-2pass.cpp
index 48e9079..c3c3dc8 100644
--- a/funasr/runtime/websocket/funasr-wss-client-2pass.cpp
+++ b/funasr/runtime/websocket/funasr-wss-client-2pass.cpp
@@ -34,9 +34,9 @@
  */
 void WaitABit() {
     #ifdef WIN32
-        Sleep(300);
+        Sleep(500);
     #else
-        usleep(300);
+        usleep(500);
     #endif
 }
 std::atomic<int> wav_index(0);

--
Gitblit v1.9.1