From 464cc2975634397317838cb70cd35d8b7f1867a5 Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Wed, 26 Jun 2019 14:11:30 +0200 Subject: [PATCH] Make optional reampling of the read wav --- utils/audio.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/audio.py b/utils/audio.py index e14f2b7e..c943e0bb 100644 --- a/utils/audio.py +++ b/utils/audio.py @@ -230,12 +230,13 @@ class AudioProcessor(object): x = np.sign(wav) / mu * ((1 + mu) ** np.abs(wav) - 1) return x - def load_wav(self, filename, encode=False): - x, sr = sf.read(filename) - # x, sr = librosa.load(filename, sr=self.sample_rate) + def load_wav(self, filename, sr=None): + if sr is None: + x, sr = sf.read(filename) + else: + x, sr = librosa.load(filename, sr=sr) if self.do_trim_silence: x = self.trim_silence(x) - # sr, x = io.wavfile.read(filename) assert self.sample_rate == sr, "%s vs %s"%(self.sample_rate, sr) return x