Sfoglia il codice sorgente

add funasr namespace

lyblsgo 2 anni fa
parent
commit
1799f356df
29 ha cambiato i file con 114 aggiunte e 57 eliminazioni
  1. 3 0
      funasr/runtime/onnxruntime/src/alignedmem.cpp
  2. 2 0
      funasr/runtime/onnxruntime/src/alignedmem.h
  3. 4 1
      funasr/runtime/onnxruntime/src/audio.cpp
  4. 3 0
      funasr/runtime/onnxruntime/src/commonfunc.h
  5. 2 0
      funasr/runtime/onnxruntime/src/ct-transformer.cpp
  6. 2 0
      funasr/runtime/onnxruntime/src/ct-transformer.h
  7. 4 3
      funasr/runtime/onnxruntime/src/e2e-vad.h
  8. 3 0
      funasr/runtime/onnxruntime/src/fsmn-vad.cpp
  9. 2 1
      funasr/runtime/onnxruntime/src/fsmn-vad.h
  10. 36 36
      funasr/runtime/onnxruntime/src/funasrruntime.cpp
  11. 4 1
      funasr/runtime/onnxruntime/src/model.cpp
  12. 3 0
      funasr/runtime/onnxruntime/src/offline-stream.cpp
  13. 3 0
      funasr/runtime/onnxruntime/src/online-feature.cpp
  14. 4 2
      funasr/runtime/onnxruntime/src/online-feature.h
  15. 3 1
      funasr/runtime/onnxruntime/src/paraformer.cpp
  16. 2 6
      funasr/runtime/onnxruntime/src/paraformer.h
  17. 0 2
      funasr/runtime/onnxruntime/src/precomp.h
  18. 3 0
      funasr/runtime/onnxruntime/src/predefine-coe.h
  19. 3 0
      funasr/runtime/onnxruntime/src/punc-model.cpp
  20. 2 0
      funasr/runtime/onnxruntime/src/resample.cpp
  21. 3 2
      funasr/runtime/onnxruntime/src/resample.h
  22. 4 0
      funasr/runtime/onnxruntime/src/tensor.h
  23. 3 0
      funasr/runtime/onnxruntime/src/tokenizer.cpp
  24. 3 0
      funasr/runtime/onnxruntime/src/tokenizer.h
  25. 3 0
      funasr/runtime/onnxruntime/src/util.cpp
  26. 2 2
      funasr/runtime/onnxruntime/src/util.h
  27. 3 0
      funasr/runtime/onnxruntime/src/vad-model.cpp
  28. 3 0
      funasr/runtime/onnxruntime/src/vocab.cpp
  29. 2 0
      funasr/runtime/onnxruntime/src/vocab.h

+ 3 - 0
funasr/runtime/onnxruntime/src/alignedmem.cpp

@@ -1,4 +1,6 @@
 #include "precomp.h"
+
+namespace funasr {
 void *AlignedMalloc(size_t alignment, size_t required_bytes)
 {
     void *p1;  // original block
@@ -16,3 +18,4 @@ void AlignedFree(void *p)
 {
     free(((void **)p)[-1]);
 }
+} // namespace funasr

+ 2 - 0
funasr/runtime/onnxruntime/src/alignedmem.h

@@ -2,7 +2,9 @@
 #ifndef ALIGNEDMEM_H
 #define ALIGNEDMEM_H
 
+namespace funasr {
 extern void *AlignedMalloc(size_t alignment, size_t required_bytes);
 extern void AlignedFree(void *p);
 
+} // namespace funasr
 #endif

+ 4 - 1
funasr/runtime/onnxruntime/src/audio.cpp

@@ -11,6 +11,7 @@
 
 using namespace std;
 
+namespace funasr {
 // see http://soundfile.sapp.org/doc/WaveFormat/
 // Note: We assume little endian here
 struct WaveHeader {
@@ -552,4 +553,6 @@ void Audio::Split(VadModel* vad_obj, vector<std::vector<int>>& vad_segments)
 
     std::vector<float> pcm_data(speech_data, speech_data+sp_len);
     vad_segments = vad_obj->Infer(pcm_data);
-}
+}
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/commonfunc.h

@@ -1,5 +1,7 @@
 #pragma once 
 #include <algorithm>
+
+namespace funasr {
 typedef struct
 {
     std::string msg;
@@ -58,3 +60,4 @@ template <class ForwardIterator>
 inline static size_t Argmax(ForwardIterator first, ForwardIterator last) {
     return std::distance(first, std::max_element(first, last));
 }
+} // namespace funasr

+ 2 - 0
funasr/runtime/onnxruntime/src/ct-transformer.cpp

@@ -5,6 +5,7 @@
 
 #include "precomp.h"
 
+namespace funasr {
 CTTransformer::CTTransformer()
 :env_(ORT_LOGGING_LEVEL_ERROR, ""),session_options{}
 {
@@ -186,3 +187,4 @@ vector<int> CTTransformer::Infer(vector<int32_t> input_data)
     return punction;
 }
 
+} // namespace funasr

+ 2 - 0
funasr/runtime/onnxruntime/src/ct-transformer.h

@@ -5,6 +5,7 @@
 
 #pragma once 
 
+namespace funasr {
 class CTTransformer : public PuncModel {
 /**
  * Author: Speech Lab of DAMO Academy, Alibaba Group
@@ -30,3 +31,4 @@ public:
 	vector<int>  Infer(vector<int32_t> input_data);
 	string AddPunc(const char* sz_input);
 };
+} // namespace funasr

+ 4 - 3
funasr/runtime/onnxruntime/src/e2e-vad.h

@@ -3,6 +3,8 @@
  * MIT License  (https://opensource.org/licenses/MIT)
 */
 
+#pragma once 
+
 #include <utility>
 #include <vector>
 #include <string>
@@ -13,7 +15,7 @@
 #include <numeric>
 #include <cassert>
 
-
+namespace funasr {
 enum class VadStateMachine {
     kVadInStateStartPointNotDetected = 1,
     kVadInStateInSpeechSegment = 2,
@@ -779,5 +781,4 @@ private:
 
 };
 
-
-
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/fsmn-vad.cpp

@@ -6,6 +6,7 @@
 #include <fstream>
 #include "precomp.h"
 
+namespace funasr {
 void FsmnVad::InitVad(const std::string &vad_model, const std::string &vad_cmvn, const std::string &vad_config, int thread_num) {
     session_options_.SetIntraOpNumThreads(thread_num);
     session_options_.SetGraphOptimizationLevel(ORT_ENABLE_ALL);
@@ -301,3 +302,5 @@ FsmnVad::~FsmnVad() {
 
 FsmnVad::FsmnVad():env_(ORT_LOGGING_LEVEL_ERROR, ""),session_options_{} {
 }
+
+} // namespace funasr

+ 2 - 1
funasr/runtime/onnxruntime/src/fsmn-vad.h

@@ -8,6 +8,7 @@
 
 #include "precomp.h"
 
+namespace funasr {
 class FsmnVad : public VadModel {
 /**
  * Author: Speech Lab of DAMO Academy, Alibaba Group
@@ -63,5 +64,5 @@ private:
     int lfr_n = VAD_LFR_N;
 };
 
-
+} // namespace funasr
 #endif //VAD_SERVER_FSMNVAD_H

+ 36 - 36
funasr/runtime/onnxruntime/src/funasrruntime.cpp

@@ -7,44 +7,44 @@ extern "C" {
 	// APIs for Init
 	_FUNASRAPI FUNASR_HANDLE  FunASRInit(std::map<std::string, std::string>& model_path, int thread_num)
 	{
-		Model* mm = CreateModel(model_path, thread_num);
+		funasr::Model* mm = funasr::CreateModel(model_path, thread_num);
 		return mm;
 	}
 
 	_FUNASRAPI FUNASR_HANDLE  FsmnVadInit(std::map<std::string, std::string>& model_path, int thread_num)
 	{
-		VadModel* mm = CreateVadModel(model_path, thread_num);
+		funasr::VadModel* mm = funasr::CreateVadModel(model_path, thread_num);
 		return mm;
 	}
 
 	_FUNASRAPI FUNASR_HANDLE  FunPuncInit(std::map<std::string, std::string>& model_path, int thread_num)
 	{
-		PuncModel* mm = CreatePuncModel(model_path, thread_num);
+		funasr::PuncModel* mm = funasr::CreatePuncModel(model_path, thread_num);
 		return mm;
 	}
 
 	_FUNASRAPI FUNASR_HANDLE  FunOfflineInit(std::map<std::string, std::string>& model_path, int thread_num)
 	{
-		OfflineStream* mm = CreateOfflineStream(model_path, thread_num);
+		funasr::OfflineStream* mm = funasr::CreateOfflineStream(model_path, thread_num);
 		return mm;
 	}
 
 	// APIs for ASR Infer
 	_FUNASRAPI FUNASR_RESULT FunASRRecogBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		Model* recog_obj = (Model*)handle;
+		funasr::Model* recog_obj = (funasr::Model*)handle;
 		if (!recog_obj)
 			return nullptr;
 
 		int32_t sampling_rate = -1;
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if (!audio.LoadWav(sz_buf, n_len, &sampling_rate))
 			return nullptr;
 
 		float* buff;
 		int len;
 		int flag=0;
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
@@ -61,18 +61,18 @@ extern "C" {
 
 	_FUNASRAPI FUNASR_RESULT FunASRRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		Model* recog_obj = (Model*)handle;
+		funasr::Model* recog_obj = (funasr::Model*)handle;
 		if (!recog_obj)
 			return nullptr;
 
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if (!audio.LoadPcmwav(sz_buf, n_len, &sampling_rate))
 			return nullptr;
 
 		float* buff;
 		int len;
 		int flag = 0;
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
@@ -89,18 +89,18 @@ extern "C" {
 
 	_FUNASRAPI FUNASR_RESULT FunASRRecogPCMFile(FUNASR_HANDLE handle, const char* sz_filename, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		Model* recog_obj = (Model*)handle;
+		funasr::Model* recog_obj = (funasr::Model*)handle;
 		if (!recog_obj)
 			return nullptr;
 
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if (!audio.LoadPcmwav(sz_filename, &sampling_rate))
 			return nullptr;
 
 		float* buff;
 		int len;
 		int flag = 0;
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
@@ -117,12 +117,12 @@ extern "C" {
 
 	_FUNASRAPI FUNASR_RESULT FunASRRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		Model* recog_obj = (Model*)handle;
+		funasr::Model* recog_obj = (funasr::Model*)handle;
 		if (!recog_obj)
 			return nullptr;
 		
 		int32_t sampling_rate = -1;
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if(!audio.LoadWav(sz_wavfile, &sampling_rate))
 			return nullptr;
 
@@ -131,7 +131,7 @@ extern "C" {
 		int flag = 0;
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		while (audio.Fetch(buff, len, flag) > 0) {
 			string msg = recog_obj->Forward(buff, len, flag);
@@ -147,16 +147,16 @@ extern "C" {
 	// APIs for VAD Infer
 	_FUNASRAPI FUNASR_RESULT FsmnVadWavFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		VadModel* vad_obj = (VadModel*)handle;
+		funasr::VadModel* vad_obj = (funasr::VadModel*)handle;
 		if (!vad_obj)
 			return nullptr;
 		
 		int32_t sampling_rate = -1;
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if(!audio.LoadWav(sz_wavfile, &sampling_rate))
 			return nullptr;
 
-		FUNASR_VAD_RESULT* p_result = new FUNASR_VAD_RESULT;
+		funasr::FUNASR_VAD_RESULT* p_result = new funasr::FUNASR_VAD_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		
 		vector<std::vector<int>> vad_segments;
@@ -169,7 +169,7 @@ extern "C" {
 	// APIs for PUNC Infer
 	_FUNASRAPI const std::string FunPuncInfer(FUNASR_HANDLE handle, const char* sz_sentence, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		PuncModel* punc_obj = (PuncModel*)handle;
+		funasr::PuncModel* punc_obj = (funasr::PuncModel*)handle;
 		if (!punc_obj)
 			return nullptr;
 
@@ -180,12 +180,12 @@ extern "C" {
 	// APIs for Offline-stream Infer
 	_FUNASRAPI FUNASR_RESULT FunOfflineRecogFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		OfflineStream* offline_stream = (OfflineStream*)handle;
+		funasr::OfflineStream* offline_stream = (funasr::OfflineStream*)handle;
 		if (!offline_stream)
 			return nullptr;
 		
 		int32_t sampling_rate = -1;
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if(!audio.LoadWav(sz_wavfile, &sampling_rate))
 			return nullptr;
 		if(offline_stream->UseVad()){
@@ -197,7 +197,7 @@ extern "C" {
 		int flag = 0;
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		while (audio.Fetch(buff, len, flag) > 0) {
 			string msg = (offline_stream->asr_handle)->Forward(buff, len, flag);
@@ -216,11 +216,11 @@ extern "C" {
 
 	_FUNASRAPI FUNASR_RESULT FunOfflineRecogPCMBuffer(FUNASR_HANDLE handle, const char* sz_buf, int n_len, int sampling_rate, FUNASR_MODE mode, QM_CALLBACK fn_callback)
 	{
-		OfflineStream* offline_stream = (OfflineStream*)handle;
+		funasr::OfflineStream* offline_stream = (funasr::OfflineStream*)handle;
 		if (!offline_stream)
 			return nullptr;
 
-		Audio audio(1);
+		funasr::Audio audio(1);
 		if (!audio.LoadPcmwav(sz_buf, n_len, &sampling_rate))
 			return nullptr;
 		if(offline_stream->UseVad()){
@@ -230,7 +230,7 @@ extern "C" {
 		float* buff;
 		int len;
 		int flag = 0;
-		FUNASR_RECOG_RESULT* p_result = new FUNASR_RECOG_RESULT;
+		funasr::FUNASR_RECOG_RESULT* p_result = new funasr::FUNASR_RECOG_RESULT;
 		p_result->snippet_time = audio.GetTimeLen();
 		int n_step = 0;
 		int n_total = audio.GetQueueSize();
@@ -263,7 +263,7 @@ extern "C" {
 		if (!result)
 			return 0.0f;
 
-		return ((FUNASR_RECOG_RESULT*)result)->snippet_time;
+		return ((funasr::FUNASR_RECOG_RESULT*)result)->snippet_time;
 	}
 
 	_FUNASRAPI const float FsmnVadGetRetSnippetTime(FUNASR_RESULT result)
@@ -271,13 +271,13 @@ extern "C" {
 		if (!result)
 			return 0.0f;
 
-		return ((FUNASR_VAD_RESULT*)result)->snippet_time;
+		return ((funasr::FUNASR_VAD_RESULT*)result)->snippet_time;
 	}
 
 	// APIs for GetResult
 	_FUNASRAPI const char* FunASRGetResult(FUNASR_RESULT result,int n_index)
 	{
-		FUNASR_RECOG_RESULT * p_result = (FUNASR_RECOG_RESULT*)result;
+		funasr::FUNASR_RECOG_RESULT * p_result = (funasr::FUNASR_RECOG_RESULT*)result;
 		if(!p_result)
 			return nullptr;
 
@@ -286,7 +286,7 @@ extern "C" {
 
 	_FUNASRAPI vector<std::vector<int>>* FsmnVadGetResult(FUNASR_RESULT result,int n_index)
 	{
-		FUNASR_VAD_RESULT * p_result = (FUNASR_VAD_RESULT*)result;
+		funasr::FUNASR_VAD_RESULT * p_result = (funasr::FUNASR_VAD_RESULT*)result;
 		if(!p_result)
 			return nullptr;
 
@@ -298,13 +298,13 @@ extern "C" {
 	{
 		if (result)
 		{
-			delete (FUNASR_RECOG_RESULT*)result;
+			delete (funasr::FUNASR_RECOG_RESULT*)result;
 		}
 	}
 
 	_FUNASRAPI void FsmnVadFreeResult(FUNASR_RESULT result)
 	{
-		FUNASR_VAD_RESULT * p_result = (FUNASR_VAD_RESULT*)result;
+		funasr::FUNASR_VAD_RESULT * p_result = (funasr::FUNASR_VAD_RESULT*)result;
 		if (p_result)
 		{
 			if(p_result->segments){
@@ -317,7 +317,7 @@ extern "C" {
 	// APIs for Uninit
 	_FUNASRAPI void FunASRUninit(FUNASR_HANDLE handle)
 	{
-		Model* recog_obj = (Model*)handle;
+		funasr::Model* recog_obj = (funasr::Model*)handle;
 
 		if (!recog_obj)
 			return;
@@ -327,7 +327,7 @@ extern "C" {
 
 	_FUNASRAPI void FsmnVadUninit(FUNASR_HANDLE handle)
 	{
-		VadModel* recog_obj = (VadModel*)handle;
+		funasr::VadModel* recog_obj = (funasr::VadModel*)handle;
 
 		if (!recog_obj)
 			return;
@@ -337,7 +337,7 @@ extern "C" {
 
 	_FUNASRAPI void FunPuncUninit(FUNASR_HANDLE handle)
 	{
-		PuncModel* punc_obj = (PuncModel*)handle;
+		funasr::PuncModel* punc_obj = (funasr::PuncModel*)handle;
 
 		if (!punc_obj)
 			return;
@@ -347,7 +347,7 @@ extern "C" {
 
 	_FUNASRAPI void FunOfflineUninit(FUNASR_HANDLE handle)
 	{
-		OfflineStream* offline_stream = (OfflineStream*)handle;
+		funasr::OfflineStream* offline_stream = (funasr::OfflineStream*)handle;
 
 		if (!offline_stream)
 			return;

+ 4 - 1
funasr/runtime/onnxruntime/src/model.cpp

@@ -1,5 +1,6 @@
 #include "precomp.h"
 
+namespace funasr {
 Model *CreateModel(std::map<std::string, std::string>& model_path, int thread_num)
 {
     string am_model_path;
@@ -14,7 +15,9 @@ Model *CreateModel(std::map<std::string, std::string>& model_path, int thread_nu
     am_config_path = PathAppend(model_path.at(MODEL_DIR), AM_CONFIG_NAME);
 
     Model *mm;
-    mm = new paraformer::Paraformer();
+    mm = new Paraformer();
     mm->InitAsr(am_model_path, am_cmvn_path, am_config_path, thread_num);
     return mm;
 }
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/offline-stream.cpp

@@ -1,5 +1,6 @@
 #include "precomp.h"
 
+namespace funasr {
 OfflineStream::OfflineStream(std::map<std::string, std::string>& model_path, int thread_num)
 {
     // VAD model
@@ -59,3 +60,5 @@ OfflineStream *CreateOfflineStream(std::map<std::string, std::string>& model_pat
     mm = new OfflineStream(model_path, thread_num);
     return mm;
 }
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/online-feature.cpp

@@ -6,6 +6,7 @@
 #include "online-feature.h"
 #include <utility>
 
+namespace funasr {
 OnlineFeature::OnlineFeature(int sample_rate, knf::FbankOptions fbank_opts, int lfr_m, int lfr_n,
                              std::vector<std::vector<float>> cmvns)
   : sample_rate_(sample_rate),
@@ -131,3 +132,5 @@ void OnlineFeature::OnlineFbank(vector<std::vector<float>> &vad_feats,
   }
 
 }
+
+} // namespace funasr

+ 4 - 2
funasr/runtime/onnxruntime/src/online-feature.h

@@ -2,12 +2,12 @@
  * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
  * MIT License  (https://opensource.org/licenses/MIT)
 */
-
+#pragma once 
 #include <vector>
 #include "precomp.h"
 
 using namespace std;
-
+namespace funasr {
 class OnlineFeature {
 
 public:
@@ -53,3 +53,5 @@ private:
   bool input_finished_ = false;
 
 };
+
+} // namespace funasr

+ 3 - 1
funasr/runtime/onnxruntime/src/paraformer.cpp

@@ -6,7 +6,8 @@
 #include "precomp.h"
 
 using namespace std;
-using namespace paraformer;
+
+namespace funasr {
 
 Paraformer::Paraformer()
 :env_(ORT_LOGGING_LEVEL_ERROR, "paraformer"),session_options{}{
@@ -238,3 +239,4 @@ string Paraformer::Rescoring()
     LOG(ERROR)<<"Not Imp!!!!!!";
     return "";
 }
+} // namespace funasr

+ 2 - 6
funasr/runtime/onnxruntime/src/paraformer.h

@@ -4,12 +4,9 @@
 */
 #pragma once
 
-#ifndef PARAFORMER_MODELIMP_H
-#define PARAFORMER_MODELIMP_H
-
 #include "precomp.h"
 
-namespace paraformer {
+namespace funasr {
 
     class Paraformer : public Model {
     /**
@@ -52,5 +49,4 @@ namespace paraformer {
         string Rescoring();
     };
 
-} // namespace paraformer
-#endif
+} // namespace funasr

+ 0 - 2
funasr/runtime/onnxruntime/src/precomp.h

@@ -46,5 +46,3 @@ using namespace std;
 #include "paraformer.h"
 #include "offline-stream.h"
 #include "funasrruntime.h"
-
-using namespace paraformer;

+ 3 - 0
funasr/runtime/onnxruntime/src/predefine-coe.h

@@ -3,6 +3,7 @@
 
 #include <stdint.h>
 
+namespace funasr {
 const int32_t melcoe_hex[] = {
 
     0x3f01050c, 0x3e0afb11, 0x3f5d413c, 0x3f547fd0, 0x3e2e00c1, 0x3f132970,
@@ -590,3 +591,5 @@ const int pos_enc_div_term_hex[] = {
     0x39164323, 0x3910f3c6, 0x390bd472, 0x3906e374, 0x39021f2b, 0x38fb0c03,
     0x38f22ce3, 0x38e99e04, 0x38e15c92, 0x38d965ce};
 #endif
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/punc-model.cpp

@@ -1,5 +1,6 @@
 #include "precomp.h"
 
+namespace funasr {
 PuncModel *CreatePuncModel(std::map<std::string, std::string>& model_path, int thread_num)
 {
     PuncModel *mm;
@@ -17,3 +18,5 @@ PuncModel *CreatePuncModel(std::map<std::string, std::string>& model_path, int t
     mm->InitPunc(punc_model_path, punc_config_path, thread_num);
     return mm;
 }
+
+} // namespace funasr

+ 2 - 0
funasr/runtime/onnxruntime/src/resample.cpp

@@ -31,6 +31,7 @@
 #include <cstdlib>
 #include <type_traits>
 
+namespace funasr {
 #ifndef M_2PI
 #define M_2PI 6.283185307179586476925286766559005
 #endif
@@ -303,3 +304,4 @@ void LinearResample::SetRemainder(const float *input, int32_t input_dim) {
     }
   }
 }
+} // namespace funasr

+ 3 - 2
funasr/runtime/onnxruntime/src/resample.h

@@ -21,11 +21,11 @@
  */
 // this file is copied and modified from
 // kaldi/src/feat/resample.h
-
+#pragma once 
 #include <cstdint>
 #include <vector>
 
-
+namespace funasr {
 /*
    We require that the input and output sampling rate be specified as
    integers, as this is an easy way to specify that their ratio be rational.
@@ -135,3 +135,4 @@ class LinearResample {
   std::vector<float> input_remainder_;  ///< A small trailing part of the
                                         ///< previously seen input signal.
 };
+} // namespace funasr

+ 4 - 0
funasr/runtime/onnxruntime/src/tensor.h

@@ -5,6 +5,8 @@
 
 using namespace std;
 
+namespace funasr {
+
 template <typename T> class Tensor {
   private:
     void alloc_buff();
@@ -152,4 +154,6 @@ template <typename T> void Tensor<T>::dump(const char *mode)
     fwrite(buff, 1, buff_size * sizeof(T), fp);
     fclose(fp);
 }
+
+} // namespace funasr
 #endif

+ 3 - 0
funasr/runtime/onnxruntime/src/tokenizer.cpp

@@ -5,6 +5,7 @@
 
 #include "precomp.h"
 
+namespace funasr {
 CTokenizer::CTokenizer(const char* sz_yamlfile):m_ready(false)
 {
 	OpenYaml(sz_yamlfile);
@@ -220,3 +221,5 @@ void CTokenizer::StrSplit(const string& str, const char split, vector<string>& r
 	}
 	id_out= String2Ids(str_out);
 }
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/tokenizer.h

@@ -6,6 +6,7 @@
 #pragma once
 #include <yaml-cpp/yaml.h>
 
+namespace funasr {
 class CTokenizer {
 private:
 
@@ -31,3 +32,5 @@ public:
 	void Tokenize(const char* str_info, vector<string>& str_out, vector<int>& id_out);
 
 };
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/util.cpp

@@ -1,6 +1,7 @@
 
 #include "precomp.h"
 
+namespace funasr {
 float *LoadParams(const char *filename)
 {
 
@@ -178,3 +179,5 @@ void Glu(Tensor<float> *din, Tensor<float> *dout)
         }
     }
 }
+
+} // namespace funasr

+ 2 - 2
funasr/runtime/onnxruntime/src/util.h

@@ -1,10 +1,9 @@
-
-
 #ifndef UTIL_H
 #define UTIL_H
 
 using namespace std;
 
+namespace funasr {
 extern float *LoadParams(const char *filename);
 
 extern void SaveDataFile(const char *filename, void *data, uint32_t len);
@@ -27,4 +26,5 @@ extern void Glu(Tensor<float> *din, Tensor<float> *dout);
 
 string PathAppend(const string &p1, const string &p2);
 
+} // namespace funasr
 #endif

+ 3 - 0
funasr/runtime/onnxruntime/src/vad-model.cpp

@@ -1,5 +1,6 @@
 #include "precomp.h"
 
+namespace funasr {
 VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thread_num)
 {
     VadModel *mm;
@@ -19,3 +20,5 @@ VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thr
     mm->InitVad(vad_model_path, vad_cmvn_path, vad_config_path, thread_num);
     return mm;
 }
+
+} // namespace funasr

+ 3 - 0
funasr/runtime/onnxruntime/src/vocab.cpp

@@ -10,6 +10,7 @@
 
 using namespace std;
 
+namespace funasr {
 Vocab::Vocab(const char *filename)
 {
     ifstream in(filename);
@@ -151,3 +152,5 @@ int Vocab::Size()
 {
     return vocab.size();
 }
+
+} // namespace funasr

+ 2 - 0
funasr/runtime/onnxruntime/src/vocab.h

@@ -7,6 +7,7 @@
 #include <vector>
 using namespace std;
 
+namespace funasr {
 class Vocab {
   private:
     vector<string> vocab;
@@ -22,4 +23,5 @@ class Vocab {
     string Vector2StringV2(vector<int> in);
 };
 
+} // namespace funasr
 #endif