From 3549c0106e5a35ef2ddffdfd7381e613ed5310bd Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期四, 14 三月 2024 15:11:22 +0800
Subject: [PATCH] update com define
---
runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp b/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
index 39928b4..d9a3c51 100644
--- a/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
+++ b/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
@@ -54,8 +54,7 @@
// warm up
for (size_t i = 0; i < 1; i++)
{
- FunOfflineReset(asr_handle, decoder_handle);
- FUNASR_RESULT result=FunOfflineInfer(asr_handle, wav_list[0].c_str(), RASR_NONE, NULL, hotwords_embedding, audio_fs, true, decoder_handle);
+ FUNASR_RESULT result=FunOfflineInfer(asr_handle, wav_list[0].c_str(), RASR_NONE, nullptr, hotwords_embedding, audio_fs, true, decoder_handle);
if(result){
FunASRFreeResult(result);
}
@@ -68,10 +67,10 @@
break;
}
- gettimeofday(&start, NULL);
- FUNASR_RESULT result=FunOfflineInfer(asr_handle, wav_list[i].c_str(), RASR_NONE, NULL, hotwords_embedding, audio_fs, true, decoder_handle);
+ gettimeofday(&start, nullptr);
+ FUNASR_RESULT result=FunOfflineInfer(asr_handle, wav_list[i].c_str(), RASR_NONE, nullptr, hotwords_embedding, audio_fs, true, decoder_handle);
- gettimeofday(&end, NULL);
+ gettimeofday(&end, nullptr);
seconds = (end.tv_sec - start.tv_sec);
long taking_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
n_total_time += taking_micros;
@@ -82,6 +81,10 @@
string stamp = FunASRGetStamp(result);
if(stamp !=""){
LOG(INFO) << "Thread: " << this_thread::get_id() << "," << wav_ids[i] << " : " << stamp;
+ }
+ string stamp_sents = FunASRGetStampSents(result);
+ if(stamp_sents !=""){
+ LOG(INFO)<< wav_ids[i] <<" : "<<stamp_sents;
}
float snippet_time = FunASRGetRetSnippetTime(result);
n_total_length += snippet_time;
@@ -112,10 +115,8 @@
void GetValue(TCLAP::ValueArg<std::string>& value_arg, string key, std::map<std::string, std::string>& model_path)
{
- if (value_arg.isSet()){
- model_path.insert({key, value_arg.getValue()});
- LOG(INFO)<< key << " : " << value_arg.getValue();
- }
+ model_path.insert({key, value_arg.getValue()});
+ LOG(INFO)<< key << " : " << value_arg.getValue();
}
int main(int argc, char *argv[])
@@ -141,6 +142,7 @@
TCLAP::ValueArg<std::int32_t> audio_fs("", AUDIO_FS, "the sample rate of audio", false, 16000, "int32_t");
TCLAP::ValueArg<std::int32_t> thread_num("", THREAD_NUM, "multi-thread num for rtf", true, 0, "int32_t");
TCLAP::ValueArg<std::string> hotword("", HOTWORD, "the hotword file, one hotword perline, Format: Hotword Weight (could be: 闃块噷宸村反 20)", false, "", "string");
+ TCLAP::SwitchArg use_gpu("", INFER_GPU, "Whether to use GPU for inference, default is false", false);
cmd.add(model_dir);
cmd.add(quantize);
@@ -158,6 +160,7 @@
cmd.add(wav_path);
cmd.add(audio_fs);
cmd.add(thread_num);
+ cmd.add(use_gpu);
cmd.parse(argc, argv);
std::map<std::string, std::string> model_path;
@@ -173,8 +176,9 @@
GetValue(wav_path, WAV_PATH, model_path);
struct timeval start, end;
- gettimeofday(&start, NULL);
- FUNASR_HANDLE asr_handle=FunOfflineInit(model_path, 1);
+ gettimeofday(&start, nullptr);
+ bool use_gpu_ = use_gpu.getValue();
+ FUNASR_HANDLE asr_handle=FunOfflineInit(model_path, 1, use_gpu_);
if (!asr_handle)
{
@@ -182,7 +186,7 @@
exit(-1);
}
- gettimeofday(&end, NULL);
+ gettimeofday(&end, nullptr);
long seconds = (end.tv_sec - start.tv_sec);
long modle_init_micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec);
LOG(INFO) << "Model initialization takes " << (double)modle_init_micros / 1000000 << " s";
--
Gitblit v1.9.1