Skip to content

Commit

Permalink
fix (audio import): enable multiple encoding load
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jun 12, 2017
1 parent 988ffd4 commit 858e928
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion data/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
windows = {'hamming': scipy.signal.hamming, 'hann': scipy.signal.hann, 'blackman': scipy.signal.blackman,
'bartlett': scipy.signal.bartlett}

def __load_audio_file_safetly(path):
try:
return torchaudio.load(path.encode('utf-8')) # py3 fix
except:
return torchaudio.load(path)

def load_audio(path):
sound, _ = torchaudio.load(path.encode('utf-8')) # py3 fix
sound, _ = __load_audio_file_safetly(path)
sound = sound.numpy()
if len(sound.shape) > 1:
if sound.shape[1] == 1:
Expand Down

0 comments on commit 858e928

Please sign in to comment.