Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
Revert "fix onnxruntime memoryleak when load model (#2108)"
雾聪df24be289221
diff --git a/runtime/onnxruntime/src/fsmn-vad.cpp b/runtime/onnxruntime/src/fsmn-vad.cppindex e34767009..42ce83b45 100644--- a/runtime/onnxruntime/src/fsmn-vad.cpp+++ b/runtime/onnxruntime/src/fsmn-vad.cpp@@ -60,19 +60,18 @@ void FsmnVad::ReadModel(const char* vad_model) {LOG(ERROR) << "Error when load vad onnx model: " << e.what();exit(-1);}- GetInputOutputInfo(vad_session_, &vad_in_names_, &vad_out_names_, &vad_allocator);+ GetInputOutputInfo(vad_session_, &vad_in_names_, &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) {+ std::vector<const char *> *in_names, std::vector<const char *> *out_names) {Ort::AllocatorWithDefaultOptions allocator;// Input infoint 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);+ 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();@@ -91,7 +90,7 @@ void FsmnVad::GetInputOutputInfo(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);+ 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();@@ -311,8 +310,6 @@ void FsmnVad::Test() {}FsmnVad::~FsmnVad() {- for (auto vad_in_name_item : vad_in_names_) vad_allocator.Free((void*)vad_in_name_item);- for (auto vad_out_name_item : vad_out_names_) vad_allocator.Free((void*)vad_out_name_item);}FsmnVad::FsmnVad():env_(ORT_LOGGING_LEVEL_ERROR, ""),session_options_{} {diff --git a/runtime/onnxruntime/src/fsmn-vad.h b/runtime/onnxruntime/src/fsmn-vad.hindex 5443a3ba4..f06a9651b 100644--- a/runtime/onnxruntime/src/fsmn-vad.h+++ b/runtime/onnxruntime/src/fsmn-vad.h@@ -34,7 +34,6 @@ public:std::shared_ptr<Ort::Session> vad_session_ = nullptr;Ort::Env env_;Ort::SessionOptions session_options_;- Ort::AllocatorWithDefaultOptions vad_allocator;std::vector<const char *> vad_in_names_;std::vector<const char *> vad_out_names_;std::vector<std::vector<float>> in_cache_;@@ -57,8 +56,7 @@ private:static void GetInputOutputInfo(const std::shared_ptr<Ort::Session> &session,- std::vector<const char *> *in_names, std::vector<const char *> *out_names,- Ort::AllocatorWithDefaultOptions *allocator);+ std::vector<const char *> *in_names, std::vector<const char *> *out_names);void FbankKaldi(float sample_rate, std::vector<std::vector<float>> &vad_feats,std::vector<float> &waves);