Add Silero VAD (#313)

This commit is contained in:
Fangjun Kuang
2023-09-17 14:54:38 +08:00
committed by GitHub
parent 3a20e332bf
commit c471423125
36 changed files with 1683 additions and 16 deletions

View File

@@ -0,0 +1,44 @@
// sherpa-onnx/csrc/vad-model-config.cc
//
// Copyright (c) 2023 Xiaomi Corporation
#include "sherpa-onnx/csrc/vad-model-config.h"
#include <sstream>
#include <string>
namespace sherpa_onnx {
void VadModelConfig::Register(ParseOptions *po) {
silero_vad.Register(po);
po->Register("vad-sample-rate", &sample_rate,
"Sample rate expected by the VAD model");
po->Register("vad-num-threads", &num_threads,
"Number of threads to run the VAD model");
po->Register("vad-provider", &provider,
"Specify a provider to run the VAD model. Supported values: "
"cpu, cuda, coreml");
po->Register("vad-debug", &debug,
"true to display debug information when loading vad models");
}
bool VadModelConfig::Validate() const { return silero_vad.Validate(); }
std::string VadModelConfig::ToString() const {
std::ostringstream os;
os << "VadModelConfig(";
os << "silero_vad=" << silero_vad.ToString() << ", ";
os << "sample_rate=" << sample_rate << ", ";
os << "num_threads=" << num_threads << ", ";
os << "provider=\"" << provider << "\", ";
os << "debug=" << (debug ? "True" : "False") << ")";
return os.str();
}
} // namespace sherpa_onnx