Support both sox and sox_io backends for in-place audio resampling.

This commit is contained in:
Yair Lifshitz
2024-02-16 05:58:09 -05:00
parent 797a88a386
commit d8cc947c73

View File

@@ -122,7 +122,10 @@ class Validator():
def read_audio(path: str,
sampling_rate: int = 16000):
if 'sox_io' in torchaudio.list_audio_backends():
sox_backends = set(['sox', 'sox_io'])
audio_backends = torchaudio.list_audio_backends()
if len(sox_backends.intersection(audio_backends)) > 0:
effects = [
['channels', '1'],
['rate', str(sampling_rate)]