From 0c6e9ac92f1ccfc045018c8fa93e57087ee23a97 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期四, 31 八月 2023 17:07:02 +0800
Subject: [PATCH] fix exit conditions

---
 funasr/runtime/onnxruntime/src/audio.cpp                 |    4 ++--
 funasr/runtime/onnxruntime/src/ct-transformer.cpp        |    3 +--
 funasr/runtime/onnxruntime/src/ct-transformer-online.cpp |    3 +--
 funasr/runtime/onnxruntime/src/paraformer.cpp            |   12 ++++++------
 funasr/runtime/onnxruntime/src/fsmn-vad.cpp              |    6 +++---
 funasr/runtime/onnxruntime/src/tpass-online-stream.cpp   |    2 +-
 6 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/funasr/runtime/onnxruntime/src/audio.cpp b/funasr/runtime/onnxruntime/src/audio.cpp
index a882078..6335f4e 100644
--- a/funasr/runtime/onnxruntime/src/audio.cpp
+++ b/funasr/runtime/onnxruntime/src/audio.cpp
@@ -1163,8 +1163,8 @@
 
             }else if(speech_end_i != -1){ // [-1,100]
                 if(speech_start == -1 or speech_offline_start == -1){
-                    LOG(ERROR) <<"Vad start is null while vad end is available." ;
-                    exit(-1);
+                    LOG(ERROR) <<"Vad start is null while vad end is available. Set vad start 0" ;
+                    speech_start = 0;
                 }
 
                 int start = speech_start*seg_sample;
diff --git a/funasr/runtime/onnxruntime/src/ct-transformer-online.cpp b/funasr/runtime/onnxruntime/src/ct-transformer-online.cpp
index 14601a5..5fe692b 100644
--- a/funasr/runtime/onnxruntime/src/ct-transformer-online.cpp
+++ b/funasr/runtime/onnxruntime/src/ct-transformer-online.cpp
@@ -22,7 +22,7 @@
     }
     catch (std::exception const &e) {
         LOG(ERROR) << "Error when load punc onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
     // read inputnames outputnames
     string strName;
@@ -226,7 +226,6 @@
     catch (std::exception const &e)
     {
         LOG(ERROR) << "Error when run punc onnx forword: " << (e.what());
-        exit(0);
     }
     return punction;
 }
diff --git a/funasr/runtime/onnxruntime/src/ct-transformer.cpp b/funasr/runtime/onnxruntime/src/ct-transformer.cpp
index 2ee4114..a6c75fb 100644
--- a/funasr/runtime/onnxruntime/src/ct-transformer.cpp
+++ b/funasr/runtime/onnxruntime/src/ct-transformer.cpp
@@ -22,7 +22,7 @@
     }
     catch (std::exception const &e) {
         LOG(ERROR) << "Error when load punc onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
     // read inputnames outputnames
     string strName;
@@ -184,7 +184,6 @@
     catch (std::exception const &e)
     {
         LOG(ERROR) << "Error when run punc onnx forword: " << (e.what());
-        exit(0);
     }
     return punction;
 }
diff --git a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
index 50a9a03..c009be2 100644
--- a/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
+++ b/funasr/runtime/onnxruntime/src/fsmn-vad.cpp
@@ -58,7 +58,7 @@
         LOG(INFO) << "Successfully load model from " << vad_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load vad onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
     GetInputOutputInfo(vad_session_, &vad_in_names_, &vad_out_names_);
 }
@@ -197,7 +197,7 @@
         ifstream cmvn_stream(filename);
         if (!cmvn_stream.is_open()) {
             LOG(ERROR) << "Failed to open file: " << filename;
-            exit(0);
+            exit(-1);
         }
         string line;
 
@@ -230,7 +230,7 @@
         }
     }catch(std::exception const &e) {
         LOG(ERROR) << "Error when load vad cmvn : " << e.what();
-        exit(0);
+        exit(-1);
     }
 }
 
diff --git a/funasr/runtime/onnxruntime/src/paraformer.cpp b/funasr/runtime/onnxruntime/src/paraformer.cpp
index c36a86d..887a463 100644
--- a/funasr/runtime/onnxruntime/src/paraformer.cpp
+++ b/funasr/runtime/onnxruntime/src/paraformer.cpp
@@ -41,7 +41,7 @@
         LOG(INFO) << "Successfully load model from " << am_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load am onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
 
     string strName;
@@ -93,7 +93,7 @@
         LOG(INFO) << "Successfully load model from " << en_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load am encoder model: " << e.what();
-        exit(0);
+        exit(-1);
     }
 
     try {
@@ -101,7 +101,7 @@
         LOG(INFO) << "Successfully load model from " << de_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load am decoder model: " << e.what();
-        exit(0);
+        exit(-1);
     }
 
     // encoder
@@ -156,7 +156,7 @@
         LOG(INFO) << "Successfully load model from " << am_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load am onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
 
     string strName;
@@ -225,7 +225,7 @@
         LOG(INFO) << "Successfully load model from " << hw_model;
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load hw compiler onnx model: " << e.what();
-        exit(0);
+        exit(-1);
     }
 
     string strName;
@@ -292,7 +292,7 @@
     ifstream cmvn_stream(filename);
     if (!cmvn_stream.is_open()) {
         LOG(ERROR) << "Failed to open file: " << filename;
-        exit(0);
+        exit(-1);
     }
     string line;
 
diff --git a/funasr/runtime/onnxruntime/src/tpass-online-stream.cpp b/funasr/runtime/onnxruntime/src/tpass-online-stream.cpp
index d99c871..832cfd1 100644
--- a/funasr/runtime/onnxruntime/src/tpass-online-stream.cpp
+++ b/funasr/runtime/onnxruntime/src/tpass-online-stream.cpp
@@ -7,7 +7,7 @@
     if(tpass_obj->vad_handle){
         vad_online_handle = make_unique<FsmnVadOnline>((FsmnVad*)(tpass_obj->vad_handle).get());
     }else{
-        LOG(ERROR)<<"asr_handle is null";
+        LOG(ERROR)<<"vad_handle is null";
         exit(-1);
     }
 

--
Gitblit v1.9.1