From 28ccfbfc51068a663a80764e14074df5edf2b5ba Mon Sep 17 00:00:00 2001
From: kongdeqiang <kongdeqiang960204@163.com>
Date: 星期五, 13 三月 2026 17:41:41 +0800
Subject: [PATCH] 提交

---
 runtime/onnxruntime/src/fsmn-vad.cpp |   51 ++++-----------------------------------------------
 1 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/runtime/onnxruntime/src/fsmn-vad.cpp b/runtime/onnxruntime/src/fsmn-vad.cpp
index db633b0..bcef5d4 100644
--- a/runtime/onnxruntime/src/fsmn-vad.cpp
+++ b/runtime/onnxruntime/src/fsmn-vad.cpp
@@ -30,7 +30,7 @@
 
     try{
         YAML::Node frontend_conf = config["frontend_conf"];
-        YAML::Node post_conf = config["vad_post_conf"];
+        YAML::Node post_conf = config["model_conf"];
 
         this->vad_sample_rate_ = frontend_conf["fs"].as<int>();
         this->vad_silence_duration_ =  post_conf["max_end_silence_time"].as<int>();
@@ -60,53 +60,9 @@
         LOG(ERROR) << "Error when load vad onnx model: " << e.what();
         exit(-1);
     }
-    GetInputOutputInfo(vad_session_, &vad_in_names_, &vad_out_names_);
+    GetInputNames(vad_session_.get(), m_strInputNames, vad_in_names_);
+    GetOutputNames(vad_session_.get(), m_strOutputNames, vad_out_names_);
 }
-
-void FsmnVad::GetInputOutputInfo(
-        const std::shared_ptr<Ort::Session> &session,
-        std::vector<const char *> *in_names, std::vector<const char *> *out_names) {
-    Ort::AllocatorWithDefaultOptions allocator;
-    // Input info
-    int num_nodes = session->GetInputCount();
-    in_names->resize(num_nodes);
-    for (int i = 0; i < num_nodes; ++i) {
-        std::unique_ptr<char, Ort::detail::AllocatedFree> name = session->GetInputNameAllocated(i, allocator);
-        Ort::TypeInfo type_info = session->GetInputTypeInfo(i);
-        auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
-        ONNXTensorElementDataType type = tensor_info.GetElementType();
-        std::vector<int64_t> node_dims = tensor_info.GetShape();
-        std::stringstream shape;
-        for (auto j: node_dims) {
-            shape << j;
-            shape << " ";
-        }
-        // LOG(INFO) << "\tInput " << i << " : name=" << name.get() << " type=" << type
-        //           << " dims=" << shape.str();
-        (*in_names)[i] = name.get();
-        name.release();
-    }
-    // Output info
-    num_nodes = session->GetOutputCount();
-    out_names->resize(num_nodes);
-    for (int i = 0; i < num_nodes; ++i) {
-        std::unique_ptr<char, Ort::detail::AllocatedFree> name = session->GetOutputNameAllocated(i, allocator);
-        Ort::TypeInfo type_info = session->GetOutputTypeInfo(i);
-        auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
-        ONNXTensorElementDataType type = tensor_info.GetElementType();
-        std::vector<int64_t> node_dims = tensor_info.GetShape();
-        std::stringstream shape;
-        for (auto j: node_dims) {
-            shape << j;
-            shape << " ";
-        }
-        // LOG(INFO) << "\tOutput " << i << " : name=" << name.get() << " type=" << type
-        //           << " dims=" << shape.str();
-        (*out_names)[i] = name.get();
-        name.release();
-    }
-}
-
 
 void FsmnVad::Forward(
         const std::vector<std::vector<float>> &chunk_feats,
@@ -264,6 +220,7 @@
                 p.insert(p.end(), vad_feats[vad_feats.size() - 1].begin(), vad_feats[vad_feats.size() - 1].end());
             }
             out_feats.emplace_back(p);
+            p.clear();
         }
     }
     // Apply cmvn

--
Gitblit v1.9.1