From 74cf8b65b2254eee059f6f599bb6095db5c66001 Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期四, 16 十一月 2023 11:12:20 +0800
Subject: [PATCH] fix the issue of hotwords_embedding potentially being a null pointer
---
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