From eff2570faf3dae7908db87edf4ef1a6ea88e5b33 Mon Sep 17 00:00:00 2001
From: cdevelop <cdevelop@qq.com>
Date: 星期三, 15 十一月 2023 19:46:00 +0800
Subject: [PATCH] 解决windwos 加载lm模型失败 (#1093)

---
 runtime/onnxruntime/src/paraformer.cpp |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/runtime/onnxruntime/src/paraformer.cpp b/runtime/onnxruntime/src/paraformer.cpp
index b6babfe..11ed0ff 100644
--- a/runtime/onnxruntime/src/paraformer.cpp
+++ b/runtime/onnxruntime/src/paraformer.cpp
@@ -191,9 +191,13 @@
     try {
         lm_ = std::shared_ptr<fst::Fst<fst::StdArc>>(
             fst::Fst<fst::StdArc>::Read(lm_file));
-        if (vocab) { delete vocab; }
-        vocab = new Vocab(lm_cfg_file.c_str());
-        LOG(INFO) << "Successfully load lm file " << lm_file;
+        if (lm_){
+            if (vocab) { delete vocab; }
+            vocab = new Vocab(lm_cfg_file.c_str());
+            LOG(INFO) << "Successfully load lm file " << lm_file;
+        }else{
+            LOG(ERROR) << "Failed to load lm file " << lm_file;
+        }
     } catch (std::exception const &e) {
         LOG(ERROR) << "Error when load lm file: " << e.what();
         exit(0);

--
Gitblit v1.9.1