Jelajahi Sumber

fix exit conditions

雾聪 2 tahun lalu
induk
melakukan
0c6e9ac92f

+ 2 - 2
funasr/runtime/onnxruntime/src/audio.cpp

@@ -1163,8 +1163,8 @@ void Audio::Split(VadModel* vad_obj, int chunk_len, bool input_finished, ASR_TYP
 
             }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;

+ 1 - 2
funasr/runtime/onnxruntime/src/ct-transformer-online.cpp

@@ -22,7 +22,7 @@ void CTTransformerOnline::InitPunc(const std::string &punc_model, const std::str
     }
     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 @@ vector<int> CTTransformerOnline::Infer(vector<int32_t> input_data, int nCacheSiz
     catch (std::exception const &e)
     {
         LOG(ERROR) << "Error when run punc onnx forword: " << (e.what());
-        exit(0);
     }
     return punction;
 }

+ 1 - 2
funasr/runtime/onnxruntime/src/ct-transformer.cpp

@@ -22,7 +22,7 @@ void CTTransformer::InitPunc(const std::string &punc_model, const std::string &p
     }
     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 @@ vector<int> CTTransformer::Infer(vector<int32_t> input_data)
     catch (std::exception const &e)
     {
         LOG(ERROR) << "Error when run punc onnx forword: " << (e.what());
-        exit(0);
     }
     return punction;
 }

+ 3 - 3
funasr/runtime/onnxruntime/src/fsmn-vad.cpp

@@ -58,7 +58,7 @@ void FsmnVad::ReadModel(const char* vad_model) {
         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 @@ void FsmnVad::LoadCmvn(const char *filename)
         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 @@ void FsmnVad::LoadCmvn(const char *filename)
         }
     }catch(std::exception const &e) {
         LOG(ERROR) << "Error when load vad cmvn : " << e.what();
-        exit(0);
+        exit(-1);
     }
 }
 

+ 6 - 6
funasr/runtime/onnxruntime/src/paraformer.cpp

@@ -41,7 +41,7 @@ void Paraformer::InitAsr(const std::string &am_model, const std::string &am_cmvn
         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 @@ void Paraformer::InitAsr(const std::string &en_model, const std::string &de_mode
         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 @@ void Paraformer::InitAsr(const std::string &en_model, const std::string &de_mode
         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 @@ void Paraformer::InitAsr(const std::string &am_model, const std::string &en_mode
         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 @@ void Paraformer::InitHwCompiler(const std::string &hw_model, int thread_num) {
         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 @@ void Paraformer::LoadCmvn(const char *filename)
     ifstream cmvn_stream(filename);
     if (!cmvn_stream.is_open()) {
         LOG(ERROR) << "Failed to open file: " << filename;
-        exit(0);
+        exit(-1);
     }
     string line;
 

+ 1 - 1
funasr/runtime/onnxruntime/src/tpass-online-stream.cpp

@@ -7,7 +7,7 @@ TpassOnlineStream::TpassOnlineStream(TpassStream* tpass_stream, std::vector<int>
     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);
     }