mirror of https://github.com/coqui-ai/TTS.git
torchaudio should use proper backend to load audio (#3179)
This commit is contained in:
parent
46d9c27212
commit
66a1e248d0
|
@ -69,12 +69,9 @@ def wav_to_mel_cloning(
|
||||||
|
|
||||||
def load_audio(audiopath, sampling_rate):
|
def load_audio(audiopath, sampling_rate):
|
||||||
# better load setting following: https://github.com/faroit/python_audio_loading_benchmark
|
# 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
|
# torchaudio should chose proper backend to load audio depending on platform
|
||||||
audio, lsr = torchaudio.backend.sox_io_backend.load(audiopath)
|
audio, lsr = torchaudio.load(audiopath)
|
||||||
else:
|
|
||||||
# it uses torchaudio soundfile backend to load all the others data type
|
|
||||||
audio, lsr = torchaudio.backend.soundfile_backend.load(audiopath)
|
|
||||||
|
|
||||||
# stereo to mono if needed
|
# stereo to mono if needed
|
||||||
if audio.size(0) != 1:
|
if audio.size(0) != 1:
|
||||||
|
|
Loading…
Reference in New Issue