From 3590ebffd3f6d11fc59bf2407feaa56bc521c761 Mon Sep 17 00:00:00 2001
From: yhliang <68215459+yhliang-aslp@users.noreply.github.com>
Date: 星期三, 16 八月 2023 10:54:41 +0800
Subject: [PATCH] Dev lyh (#860)
---
funasr/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp b/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
index 2d182e0..85d6f03 100644
--- a/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
+++ b/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-rtf.cpp
@@ -28,7 +28,7 @@
std::atomic<int> wav_index(0);
std::mutex mtx;
-void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list,
+void runReg(FUNASR_HANDLE asr_handle, vector<string> wav_list, vector<string> wav_ids,
float* total_length, long* total_time, int core_id) {
struct timeval start, end;
@@ -40,6 +40,9 @@
for (size_t i = 0; i < 1; i++)
{
FUNASR_RESULT result=FunOfflineInfer(asr_handle, wav_list[0].c_str(), RASR_NONE, NULL, 16000);
+ if(result){
+ FunASRFreeResult(result);
+ }
}
while (true) {
@@ -59,13 +62,13 @@
if(result){
string msg = FunASRGetResult(result, 0);
- LOG(INFO) << "Thread: " << this_thread::get_id() <<" Result: " << msg.c_str();
+ LOG(INFO) << "Thread: " << this_thread::get_id() << "," << wav_ids[i] << " : " << msg;
float snippet_time = FunASRGetRetSnippetTime(result);
n_total_length += snippet_time;
FunASRFreeResult(result);
}else{
- LOG(ERROR) << ("No return data!\n");
+ LOG(ERROR) << wav_ids[i] << (": No return data!\n");
}
}
{
@@ -146,9 +149,12 @@
// read wav_path
vector<string> wav_list;
+ vector<string> wav_ids;
+ string default_id = "wav_default_id";
string wav_path_ = model_path.at(WAV_PATH);
if(is_target_file(wav_path_, "wav") || is_target_file(wav_path_, "pcm")){
wav_list.emplace_back(wav_path_);
+ wav_ids.emplace_back(default_id);
}
else if(is_target_file(wav_path_, "scp")){
ifstream in(wav_path_);
@@ -162,7 +168,8 @@
istringstream iss(line);
string column1, column2;
iss >> column1 >> column2;
- wav_list.emplace_back(column2);
+ wav_list.emplace_back(column2);
+ wav_ids.emplace_back(column1);
}
in.close();
}else{
@@ -178,7 +185,7 @@
int rtf_threds = thread_num.getValue();
for (int i = 0; i < rtf_threds; i++)
{
- threads.emplace_back(thread(runReg, asr_handle, wav_list, &total_length, &total_time, i));
+ threads.emplace_back(thread(runReg, asr_handle, wav_list, wav_ids, &total_length, &total_time, i));
}
for (auto& thread : threads)
--
Gitblit v1.9.1