mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
modify fsmn-vad
This commit is contained in:
parent
659e18be11
commit
0f0dccd758
@ -16,7 +16,7 @@ class VadModel {
|
||||
virtual void LoadConfigFromYaml(const char* filename)=0;
|
||||
virtual void FbankKaldi(float sample_rate, std::vector<std::vector<float>> &vad_feats,
|
||||
const std::vector<float> &waves)=0;
|
||||
virtual std::vector<std::vector<float>> &LfrCmvn(std::vector<std::vector<float>> &vad_feats)=0;
|
||||
virtual void LfrCmvn(std::vector<std::vector<float>> &vad_feats)=0;
|
||||
virtual void Forward(
|
||||
const std::vector<std::vector<float>> &chunk_feats,
|
||||
std::vector<std::vector<float>> *out_prob)=0;
|
||||
@ -24,6 +24,6 @@ class VadModel {
|
||||
virtual void InitCache()=0;
|
||||
};
|
||||
|
||||
VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thread_num);
|
||||
VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thread_num, int mode);
|
||||
} // namespace funasr
|
||||
#endif
|
||||
|
||||
@ -225,7 +225,7 @@ void FsmnVad::LoadCmvn(const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::vector<float>> &FsmnVad::LfrCmvn(std::vector<std::vector<float>> &vad_feats) {
|
||||
void FsmnVad::LfrCmvn(std::vector<std::vector<float>> &vad_feats) {
|
||||
|
||||
std::vector<std::vector<float>> out_feats;
|
||||
int T = vad_feats.size();
|
||||
@ -264,7 +264,6 @@ std::vector<std::vector<float>> &FsmnVad::LfrCmvn(std::vector<std::vector<float>
|
||||
}
|
||||
}
|
||||
vad_feats = out_feats;
|
||||
return vad_feats;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int>>
|
||||
@ -272,7 +271,7 @@ FsmnVad::Infer(const std::vector<float> &waves) {
|
||||
std::vector<std::vector<float>> vad_feats;
|
||||
std::vector<std::vector<float>> vad_probs;
|
||||
FbankKaldi(vad_sample_rate_, vad_feats, waves);
|
||||
vad_feats = LfrCmvn(vad_feats);
|
||||
LfrCmvn(vad_feats);
|
||||
Forward(vad_feats, &vad_probs);
|
||||
|
||||
E2EVadModel vad_scorer = E2EVadModel();
|
||||
|
||||
@ -36,7 +36,7 @@ private:
|
||||
void FbankKaldi(float sample_rate, std::vector<std::vector<float>> &vad_feats,
|
||||
const std::vector<float> &waves);
|
||||
|
||||
std::vector<std::vector<float>> &LfrCmvn(std::vector<std::vector<float>> &vad_feats);
|
||||
void LfrCmvn(std::vector<std::vector<float>> &vad_feats);
|
||||
|
||||
void Forward(
|
||||
const std::vector<std::vector<float>> &chunk_feats,
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
#include "precomp.h"
|
||||
|
||||
namespace funasr {
|
||||
VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thread_num)
|
||||
VadModel *CreateVadModel(std::map<std::string, std::string>& model_path, int thread_num, int mode)
|
||||
{
|
||||
VadModel *mm;
|
||||
mm = new FsmnVad();
|
||||
if(mode == FSMN_VAD_OFFLINE){
|
||||
mm = new FsmnVad();
|
||||
}else{
|
||||
LOG(ERROR)<<"Online fsmn vad not imp!";
|
||||
}
|
||||
|
||||
string vad_model_path;
|
||||
string vad_cmvn_path;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user