From f192c1cc99d0235f0f8ed50de9c49e7c77a7bded Mon Sep 17 00:00:00 2001
From: 雾聪 <wucong.lyb@alibaba-inc.com>
Date: 星期五, 02 六月 2023 22:40:34 +0800
Subject: [PATCH] update funasr-onnx-offline-vad
---
funasr/runtime/onnxruntime/bin/funasr-onnx-offline-vad.cpp | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-vad.cpp b/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-vad.cpp
index 912630b..3aaffbd 100644
--- a/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-vad.cpp
+++ b/funasr/runtime/onnxruntime/bin/funasr-onnx-offline-vad.cpp
@@ -38,8 +38,8 @@
}
}
-void print_segs(vector<vector<int>>* vec) {
- string seg_out="[";
+void print_segs(vector<vector<int>>* vec, string &wav_id) {
+ string seg_out=wav_id + ": [";
for (int i = 0; i < vec->size(); i++) {
vector<int> inner_vec = (*vec)[i];
seg_out += "[";
@@ -97,9 +97,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_);
@@ -113,7 +116,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{
@@ -123,7 +127,9 @@
float snippet_time = 0.0f;
long taking_micros = 0;
- for(auto& wav_file : wav_list){
+ for (int i = 0; i < wav_list.size(); i++) {
+ auto& wav_file = wav_list[i];
+ auto& wav_id = wav_ids[i];
gettimeofday(&start, NULL);
FUNASR_RESULT result=FsmnVadInfer(vad_hanlde, wav_file.c_str(), NULL, 16000);
gettimeofday(&end, NULL);
@@ -133,7 +139,7 @@
if (result)
{
vector<std::vector<int>>* vad_segments = FsmnVadGetResult(result, 0);
- print_segs(vad_segments);
+ print_segs(vad_segments, wav_id);
snippet_time += FsmnVadGetRetSnippetTime(result);
FsmnVadFreeResult(result);
}
@@ -142,7 +148,7 @@
LOG(ERROR) << ("No return data!\n");
}
}
-
+
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);
--
Gitblit v1.9.1