Merge pull request #421 from yairl/master

Perform in-place resampling during read_audio.
This commit is contained in:
Alexander Veysov
2024-02-16 09:49:28 +03:00
committed by GitHub

View File

@@ -122,6 +122,14 @@ class Validator():
def read_audio(path: str, def read_audio(path: str,
sampling_rate: int = 16000): sampling_rate: int = 16000):
if 'sox' in torchaudio.list_available_backends():
effects = [
['channels', '1'],
['rate', str(sampling_rate)]
]
wav, sr = torchaudio.sox_effects.apply_effects_file(path, effects=effects)
else:
wav, sr = torchaudio.load(path) wav, sr = torchaudio.load(path)
if wav.size(0) > 1: if wav.size(0) > 1: