From 55708e7cebaedefc5f69d61f157993da41848b8f Mon Sep 17 00:00:00 2001
From: lyblsgo <lyblsgo@163.com>
Date: 星期日, 23 四月 2023 19:06:25 +0800
Subject: [PATCH] add offline punc for onnxruntime
---
funasr/runtime/onnxruntime/src/paraformer_onnx.cpp | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/paraformer_onnx.cpp b/funasr/runtime/onnxruntime/src/paraformer_onnx.cpp
index 1a86da6..69d1554 100644
--- a/funasr/runtime/onnxruntime/src/paraformer_onnx.cpp
+++ b/funasr/runtime/onnxruntime/src/paraformer_onnx.cpp
@@ -17,6 +17,11 @@
vadHandle->init_vad(vad_path, mvn_path, MODEL_SAMPLE_RATE, VAD_MAX_LEN, VAD_SILENCE_DYRATION, VAD_SPEECH_NOISE_THRES);
}
+ // PUNC model
+ if(true){
+ puncHandle = make_unique<CTTransformer>(path, nNumThread);
+ }
+
if(quantize)
{
model_path = pathAppend(path, "model_quant.onnx");
@@ -50,6 +55,7 @@
m_session = std::make_unique<Ort::Session>(env_, model_path.c_str(), sessionOptions);
#endif
+ vector<string> m_strInputNames, m_strOutputNames;
string strName;
getInputName(m_session.get(), strName);
m_strInputNames.push_back(strName.c_str());
@@ -81,6 +87,10 @@
vector<std::vector<int>> ModelImp::vad_seg(std::vector<float>& pcm_data){
return vadHandle->infer(pcm_data);
+}
+
+string ModelImp::AddPunc(const char* szInput){
+ return puncHandle->AddPunc(szInput);
}
vector<float> ModelImp::FbankKaldi(float sample_rate, const float* waves, int len) {
@@ -231,9 +241,9 @@
auto encoder_out_lens = outputTensor[1].GetTensorMutableData<int64_t>();
result = greedy_search(floatData, *encoder_out_lens);
}
- catch (...)
+ catch (std::exception const &e)
{
- result = "";
+ printf(e.what());
}
return result;
--
Gitblit v1.9.1