Skip to content

Commit

Permalink
torchaudio should use proper backend to load audio (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorkemgoknar authored Nov 9, 2023
1 parent 46d9c27 commit 66a1e24
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions TTS/tts/models/xtts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 66a1e24

Please sign in to comment.