File size: 1,049 Bytes
91670c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Stream example in C++

Here's a simple example of the vad model in c++ onnxruntime.



## Requirements

Code are tested in the environments bellow, feel free to try others.

- WSL2 + Debian-bullseye (docker)  
- gcc 12.2.0
- onnxruntime-linux-x64-1.12.1



## Usage

1. Install gcc 12.2.0, or just pull the docker image with `docker pull gcc:12.2.0-bullseye`

2. Install onnxruntime-linux-x64-1.12.1

   - Download lib onnxruntime: 

     `wget https://github.com/microsoft/onnxruntime/releases/download/v1.12.1/onnxruntime-linux-x64-1.12.1.tgz`

   - Unzip. Assume the path is `/root/onnxruntime-linux-x64-1.12.1`

3. Modify wav path & Test configs in main function

   `wav::WavReader wav_reader("${path_to_your_wav_file}");`

   test sample rate, frame per ms, threshold...

4. Build with gcc and run

   ```bash
   # Build
   g++ silero-vad-onnx.cpp -I /root/onnxruntime-linux-x64-1.12.1/include/ -L /root/onnxruntime-linux-x64-1.12.1/lib/ -lonnxruntime  -Wl,-rpath,/root/onnxruntime-linux-x64-1.12.1/lib/ -o test
   
   # Run
   ./test
   ```