mirror of
https://github.com/snakers4/silero-vad.git
synced 2026-02-04 17:39:22 +08:00
Changed some source.
This commit is contained in:
@@ -4,25 +4,28 @@
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
if(argc != 3){
|
||||
std::cerr<<"Usage : "<<argv[0]<<" <wav.path> threshold"<<std::endl;
|
||||
std::cerr<<"Usage : "<<argv[0]<<" sample.wav 0.38"<<std::endl;
|
||||
if(argc != 4){
|
||||
std::cerr<<"Usage : "<<argv[0]<<" <wav.path> <SampleRate> <Threshold>"<<std::endl;
|
||||
std::cerr<<"Usage : "<<argv[0]<<" sample.wav 16000 0.5"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string wav_path = argv[1];
|
||||
float threshold = std::stof(argv[2]);
|
||||
float sample_rate = std::stof(argv[2]);
|
||||
float threshold = std::stof(argv[3]);
|
||||
|
||||
|
||||
//Load Model
|
||||
std::string model_path = "../../src/silero_vad/data/silero_vad.jit";
|
||||
silero::VadIterator vad(model_path);
|
||||
vad.threshold=threshold;
|
||||
vad.min_speech_duration_ms=255;
|
||||
vad.max_duration_merge_ms=300;
|
||||
vad.print_as_samples=true; //if true, it prints time-stamp with sample numbers.
|
||||
|
||||
vad.threshold=threshold; //(Default:0.5)
|
||||
vad.sample_rate=sample_rate; //16000Hz,8000Hz. (Default:16000)
|
||||
vad.print_as_samples=true; //if true, it prints time-stamp with samples. otherwise, in seconds
|
||||
//(Default:false)
|
||||
|
||||
vad.SetVariables();
|
||||
|
||||
// Read wav
|
||||
wav::WavReader wav_reader(wav_path);
|
||||
std::vector<float> input_wav(wav_reader.num_samples());
|
||||
@@ -34,7 +37,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
vad.SpeechProbs(input_wav);
|
||||
|
||||
std::vector<silero::Interval> speeches = vad.GetSpeechTimestamps();
|
||||
std::vector<silero::SpeechSegment> speeches = vad.GetSpeechTimestamps();
|
||||
for(const auto& speech : speeches){
|
||||
if(vad.print_as_samples){
|
||||
std::cout<<"{'start': "<<static_cast<int>(speech.start)<<", 'end': "<<static_cast<int>(speech.end)<<"}"<<std::endl;
|
||||
|
||||
Reference in New Issue
Block a user