| File was renamed from funasr/runtime/onnxruntime/include/libfunasrapi.h |
| | |
| | | _FUNASRAPI const float FunASRGetRetSnippetTime(FUNASR_RESULT result); |
| | | |
| | | // VAD |
| | | _FUNASRAPI FUNASR_HANDLE FunVadInit(std::map<std::string, std::string>& model_path, int thread_num); |
| | | _FUNASRAPI FUNASR_HANDLE FsmnVadInit(std::map<std::string, std::string>& model_path, int thread_num); |
| | | |
| | | _FUNASRAPI FUNASR_RESULT FunVadWavFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback); |
| | | _FUNASRAPI std::vector<std::vector<int>>* FunVadGetResult(FUNASR_RESULT result,int n_index); |
| | | _FUNASRAPI void FunVadFreeResult(FUNASR_RESULT result); |
| | | _FUNASRAPI void FunVadUninit(FUNASR_HANDLE handle); |
| | | _FUNASRAPI const float FunVadGetRetSnippetTime(FUNASR_RESULT result); |
| | | _FUNASRAPI FUNASR_RESULT FsmnVadWavFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback); |
| | | _FUNASRAPI std::vector<std::vector<int>>* FsmnVadGetResult(FUNASR_RESULT result,int n_index); |
| | | _FUNASRAPI void FsmnVadFreeResult(FUNASR_RESULT result); |
| | | _FUNASRAPI void FsmnVadUninit(FUNASR_HANDLE handle); |
| | | _FUNASRAPI const float FsmnVadGetRetSnippetTime(FUNASR_RESULT result); |
| | | |
| | | // PUNC |
| | | _FUNASRAPI FUNASR_HANDLE FunPuncInit(std::map<std::string, std::string>& model_path, int thread_num); |
| | |
| | | #include <sstream> |
| | | #include <map> |
| | | #include <glog/logging.h> |
| | | #include "libfunasrapi.h" |
| | | #include "funasrruntime.h" |
| | | #include "tclap/CmdLine.h" |
| | | #include "com-define.h" |
| | | |
| | |
| | | #endif |
| | | |
| | | #include <glog/logging.h> |
| | | #include "libfunasrapi.h" |
| | | #include "funasrruntime.h" |
| | | #include "tclap/CmdLine.h" |
| | | #include "com-define.h" |
| | | |
| | |
| | | #include <map> |
| | | #include <vector> |
| | | #include <glog/logging.h> |
| | | #include "libfunasrapi.h" |
| | | #include "funasrruntime.h" |
| | | #include "tclap/CmdLine.h" |
| | | #include "com-define.h" |
| | | |
| | |
| | | struct timeval start, end; |
| | | gettimeofday(&start, NULL); |
| | | int thread_num = 1; |
| | | FUNASR_HANDLE vad_hanlde=FunVadInit(model_path, thread_num); |
| | | FUNASR_HANDLE vad_hanlde=FsmnVadInit(model_path, thread_num); |
| | | |
| | | if (!vad_hanlde) |
| | | { |
| | |
| | | long taking_micros = 0; |
| | | for(auto& wav_file : wav_list){ |
| | | gettimeofday(&start, NULL); |
| | | FUNASR_RESULT result=FunVadWavFile(vad_hanlde, wav_file.c_str(), RASR_NONE, NULL); |
| | | FUNASR_RESULT result=FsmnVadWavFile(vad_hanlde, wav_file.c_str(), RASR_NONE, NULL); |
| | | gettimeofday(&end, NULL); |
| | | seconds = (end.tv_sec - start.tv_sec); |
| | | taking_micros += ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); |
| | | |
| | | if (result) |
| | | { |
| | | vector<std::vector<int>>* vad_segments = FunVadGetResult(result, 0); |
| | | vector<std::vector<int>>* vad_segments = FsmnVadGetResult(result, 0); |
| | | print_segs(vad_segments); |
| | | snippet_time += FunVadGetRetSnippetTime(result); |
| | | FunVadFreeResult(result); |
| | | snippet_time += FsmnVadGetRetSnippetTime(result); |
| | | FsmnVadFreeResult(result); |
| | | } |
| | | else |
| | | { |
| | |
| | | LOG(INFO) << "Audio length: " << (double)snippet_time << " s"; |
| | | LOG(INFO) << "Model inference takes: " << (double)taking_micros / 1000000 <<" s"; |
| | | LOG(INFO) << "Model inference RTF: " << (double)taking_micros/ (snippet_time*1000000); |
| | | FunVadUninit(vad_hanlde); |
| | | FsmnVadUninit(vad_hanlde); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | #include <sstream> |
| | | #include <map> |
| | | #include <glog/logging.h> |
| | | #include "libfunasrapi.h" |
| | | #include "funasrruntime.h" |
| | | #include "tclap/CmdLine.h" |
| | | #include "com-define.h" |
| | | |
| File was renamed from funasr/runtime/onnxruntime/src/libfunasrapi.cpp |
| | |
| | | return mm; |
| | | } |
| | | |
| | | _FUNASRAPI FUNASR_HANDLE FunVadInit(std::map<std::string, std::string>& model_path, int thread_num) |
| | | _FUNASRAPI FUNASR_HANDLE FsmnVadInit(std::map<std::string, std::string>& model_path, int thread_num) |
| | | { |
| | | VadModel* mm = CreateVadModel(model_path, thread_num); |
| | | return mm; |
| | |
| | | } |
| | | |
| | | // APIs for VAD Infer |
| | | _FUNASRAPI FUNASR_RESULT FunVadWavFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback) |
| | | _FUNASRAPI FUNASR_RESULT FsmnVadWavFile(FUNASR_HANDLE handle, const char* sz_wavfile, FUNASR_MODE mode, QM_CALLBACK fn_callback) |
| | | { |
| | | VadModel* vad_obj = (VadModel*)handle; |
| | | if (!vad_obj) |
| | |
| | | return ((FUNASR_RECOG_RESULT*)result)->snippet_time; |
| | | } |
| | | |
| | | _FUNASRAPI const float FunVadGetRetSnippetTime(FUNASR_RESULT result) |
| | | _FUNASRAPI const float FsmnVadGetRetSnippetTime(FUNASR_RESULT result) |
| | | { |
| | | if (!result) |
| | | return 0.0f; |
| | |
| | | return p_result->msg.c_str(); |
| | | } |
| | | |
| | | _FUNASRAPI vector<std::vector<int>>* FunVadGetResult(FUNASR_RESULT result,int n_index) |
| | | _FUNASRAPI vector<std::vector<int>>* FsmnVadGetResult(FUNASR_RESULT result,int n_index) |
| | | { |
| | | FUNASR_VAD_RESULT * p_result = (FUNASR_VAD_RESULT*)result; |
| | | if(!p_result) |
| | |
| | | } |
| | | } |
| | | |
| | | _FUNASRAPI void FunVadFreeResult(FUNASR_RESULT result) |
| | | _FUNASRAPI void FsmnVadFreeResult(FUNASR_RESULT result) |
| | | { |
| | | FUNASR_VAD_RESULT * p_result = (FUNASR_VAD_RESULT*)result; |
| | | if (p_result) |
| | |
| | | delete recog_obj; |
| | | } |
| | | |
| | | _FUNASRAPI void FunVadUninit(FUNASR_HANDLE handle) |
| | | _FUNASRAPI void FsmnVadUninit(FUNASR_HANDLE handle) |
| | | { |
| | | VadModel* recog_obj = (VadModel*)handle; |
| | | |
| | |
| | | #include "resample.h" |
| | | #include "paraformer.h" |
| | | #include "offline-stream.h" |
| | | #include "libfunasrapi.h" |
| | | #include "funasrruntime.h" |
| | | |
| | | using namespace paraformer; |