From 8dab6d184a034ca86eafa644ea0d2100aadfe27d Mon Sep 17 00:00:00 2001
From: jmwang66 <wangjiaming.wjm@alibaba-inc.com>
Date: 星期二, 09 五月 2023 10:58:33 +0800
Subject: [PATCH] Merge pull request #473 from alibaba-damo-academy/dev_smohan
---
funasr/runtime/onnxruntime/src/online-feature.cpp | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/funasr/runtime/onnxruntime/src/online-feature.cpp b/funasr/runtime/onnxruntime/src/online-feature.cpp
index 5eddfc4..c5caf0a 100644
--- a/funasr/runtime/onnxruntime/src/online-feature.cpp
+++ b/funasr/runtime/onnxruntime/src/online-feature.cpp
@@ -1,7 +1,12 @@
+/**
+ * Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
+ * MIT License (https://opensource.org/licenses/MIT)
+*/
#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),
@@ -13,10 +18,10 @@
frame_shift_sample_length_ = sample_rate_ / 1000 * 10;
}
-void OnlineFeature::extractFeats(vector<std::vector<float>> &vad_feats,
+void OnlineFeature::ExtractFeats(vector<std::vector<float>> &vad_feats,
vector<float> waves, bool input_finished) {
input_finished_ = input_finished;
- onlineFbank(vad_feats, waves);
+ OnlineFbank(vad_feats, waves);
// cache deal & online lfr,cmvn
if (vad_feats.size() > 0) {
if (!reserve_waveforms_.empty()) {
@@ -53,7 +58,7 @@
}
vad_feats = lfr_splice_cache_;
OnlineLfrCmvn(vad_feats);
- reset_cache();
+ ResetCache();
}
}
@@ -102,13 +107,13 @@
return lfr_splice_frame_idxs;
}
-void OnlineFeature::onlineFbank(vector<std::vector<float>> &vad_feats,
+void OnlineFeature::OnlineFbank(vector<std::vector<float>> &vad_feats,
vector<float> &waves) {
knf::OnlineFbank fbank(fbank_opts_);
// cache merge
waves.insert(waves.begin(), input_cache_.begin(), input_cache_.end());
- int frame_number = compute_frame_num(waves.size(), frame_sample_length_, frame_shift_sample_length_);
+ int frame_number = ComputeFrameNum(waves.size(), frame_sample_length_, frame_shift_sample_length_);
// Send the audio after the last frame shift position to the cache
input_cache_.clear();
input_cache_.insert(input_cache_.begin(), waves.begin() + frame_number * frame_shift_sample_length_, waves.end());
@@ -127,3 +132,5 @@
}
}
+
+} // namespace funasr
\ No newline at end of file
--
Gitblit v1.9.1