def test_silence_not_removed(audio): "Test that nothing is removed from audio that doesnt contain silence" test_aud = AudioTensor(torch.ones_like(audio), 16000) orig_samples = test_aud.nsamples for rm_type in [RemoveType.All, RemoveType.Trim, RemoveType.Split]: silence_audio_trim = RemoveSilence(rm_type, threshold=20, pad_ms=20)(test_aud) assert orig_samples == silence_audio_trim.nsamples
def test_silence_removed(audio): "Add silence to a signal and test that it gets removed" silencer = RemoveSilence(threshold=20, pad_ms=20) orig, silenced = apply_transform(silencer, audio) assert silenced.nsamples <= orig.nsamples