|
|
|
|
|
|
|
|
|
|
|
import sys, os |
|
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../include"))) |
|
from ten_vad import TenVad |
|
import scipy.io.wavfile as Wavfile |
|
|
|
|
|
if __name__ == "__main__": |
|
input_file, out_path = sys.argv[1], sys.argv[2] |
|
sr, data = Wavfile.read(input_file) |
|
hop_size = 256 |
|
threshold = 0.5 |
|
ten_vad_instance = TenVad(hop_size, threshold) |
|
num_frames = data.shape[0] // hop_size |
|
|
|
with open(out_path, "w") as f: |
|
for i in range(num_frames): |
|
audio_data = data[i * hop_size: (i + 1) * hop_size] |
|
out_probability, out_flag = ten_vad_instance.process(audio_data) |
|
print("[%d] %0.6f, %d" % (i, out_probability, out_flag)) |
|
f.write("[%d] %0.6f, %d\n" % (i, out_probability, out_flag)) |
|
|