torchaudio should use proper backend to load audio

This commit is contained in:
gorkemgoknar 2023-11-09 15:48:04 +03:00
parent 46d9c27212
commit 491f5eea0e
1 changed files with 3 additions and 6 deletions

View File

@ -69,12 +69,9 @@ def wav_to_mel_cloning(
def load_audio(audiopath, sampling_rate):
# better load setting following: https://github.com/faroit/python_audio_loading_benchmark
if audiopath[-4:] == ".mp3":
# it uses torchaudio with sox backend to load mp3
audio, lsr = torchaudio.backend.sox_io_backend.load(audiopath)
else:
# it uses torchaudio soundfile backend to load all the others data type
audio, lsr = torchaudio.backend.soundfile_backend.load(audiopath)
# torchaudio should chose proper backend to load audio depending on platform
audio, lsr = torchaudio.load(audiopath)
# stereo to mono if needed
if audio.size(0) != 1: