From bc723ea200144bd6fa8a5dff4b9a780feda144fc Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期四, 29 六月 2023 18:55:01 +0800
Subject: [PATCH] dcos

---
 funasr/runtime/onnxruntime/src/offline-stream.cpp |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/funasr/runtime/onnxruntime/src/offline-stream.cpp b/funasr/runtime/onnxruntime/src/offline-stream.cpp
index 00c1318..d96cf27 100644
--- a/funasr/runtime/onnxruntime/src/offline-stream.cpp
+++ b/funasr/runtime/onnxruntime/src/offline-stream.cpp
@@ -1,10 +1,11 @@
 #include "precomp.h"
+#include <unistd.h>
 
+namespace funasr {
 OfflineStream::OfflineStream(std::map<std::string, std::string>& model_path, int thread_num)
 {
     // VAD model
     if(model_path.find(VAD_DIR) != model_path.end()){
-        use_vad = true;
         string vad_model_path;
         string vad_cmvn_path;
         string vad_config_path;
@@ -15,8 +16,16 @@
         }
         vad_cmvn_path = PathAppend(model_path.at(VAD_DIR), VAD_CMVN_NAME);
         vad_config_path = PathAppend(model_path.at(VAD_DIR), VAD_CONFIG_NAME);
-        vad_handle = make_unique<FsmnVad>();
-        vad_handle->InitVad(vad_model_path, vad_cmvn_path, vad_config_path, thread_num);
+        if (access(vad_model_path.c_str(), F_OK) != 0 ||
+            access(vad_cmvn_path.c_str(), F_OK) != 0 ||
+            access(vad_config_path.c_str(), F_OK) != 0 )
+        {
+            LOG(INFO) << "VAD model file is not exist, skip load vad model.";
+        }else{
+            vad_handle = make_unique<FsmnVad>();
+            vad_handle->InitVad(vad_model_path, vad_cmvn_path, vad_config_path, thread_num);
+            use_vad = true;
+        }
     }
 
     // AM model
@@ -38,7 +47,6 @@
 
     // PUNC model
     if(model_path.find(PUNC_DIR) != model_path.end()){
-        use_punc = true;
         string punc_model_path;
         string punc_config_path;
     
@@ -48,8 +56,15 @@
         }
         punc_config_path = PathAppend(model_path.at(PUNC_DIR), PUNC_CONFIG_NAME);
 
-        punc_handle = make_unique<CTTransformer>();
-        punc_handle->InitPunc(punc_model_path, punc_config_path, thread_num);
+        if (access(punc_model_path.c_str(), F_OK) != 0 ||
+            access(punc_config_path.c_str(), F_OK) != 0 )
+        {
+            LOG(INFO) << "PUNC model file is not exist, skip load punc model.";
+        }else{
+            punc_handle = make_unique<CTTransformer>();
+            punc_handle->InitPunc(punc_model_path, punc_config_path, thread_num);
+            use_punc = true;
+        }
     }
 }
 
@@ -59,3 +74,5 @@
     mm = new OfflineStream(model_path, thread_num);
     return mm;
 }
+
+} // namespace funasr
\ No newline at end of file

--
Gitblit v1.9.1