mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00

* add vad example * fix typo * fix typo * rename file * remove model and wav * delete Vad.cc * delete Vad.h * rename and format * fix max and min * update readme * rename var * format * add params * update readme * update readme * Update README.md * Update README_CN.md Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
30 lines
805 B
C++
30 lines
805 B
C++
#include <iostream>
|
|
|
|
#include "vad.h"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (argc < 3) {
|
|
std::cout << "Usage: infer_onnx_silero_vad path/to/model path/to/audio "
|
|
"run_option, "
|
|
"e.g ./infer_onnx_silero_vad silero_vad.onnx sample.wav"
|
|
<< std::endl;
|
|
return -1;
|
|
}
|
|
|
|
std::string model_file = argv[1];
|
|
std::string audio_file = argv[2];
|
|
|
|
Vad vad(model_file);
|
|
// custom config, but must be set before init
|
|
// vad.setAudioCofig(16000, 64, 0.5f, 0, 0);
|
|
vad.init();
|
|
vad.loadAudio(audio_file);
|
|
vad.Predict();
|
|
std::vector<std::map<std::string, float>> result = vad.getResult();
|
|
for (auto& res : result) {
|
|
std::cout << "speak start: " << res["start"] << " s, end: " << res["end"]
|
|
<< " s" << std::endl;
|
|
}
|
|
return 0;
|
|
}
|