Skip to content

Instantly share code, notes, and snippets.

@egorsmkv
Created June 19, 2022 12:28
Show Gist options
  • Save egorsmkv/6d1f6d7cf8a05dd9b42d2e3f4d628847 to your computer and use it in GitHub Desktop.
Save egorsmkv/6d1f6d7cf8a05dd9b42d2e3f4d628847 to your computer and use it in GitHub Desktop.
import torchaudio
from speechbrain.pretrained import VAD
VAD = VAD.from_hparams(source="speechbrain/vad-crdnn-libriparty", savedir="pretrained_models/vad-crdnn-libriparty")
test_file = 'a.wav'
boundaries = VAD.get_speech_segments(test_file)
segments = VAD.get_segments(boundaries, test_file)
for idx, s in enumerate(segments):
segment_file = f'segments-dir/segment_{idx}.wav'
torchaudio.save(segment_file, s.cpu(), 16000)
print(segment_file, 'saved')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment