Skip to content

Commit

Permalink
Fix save wav
Browse files Browse the repository at this point in the history
  • Loading branch information
geneing committed Aug 15, 2020
1 parent ec4942b commit 9db0f8a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import librosa
from utils import hparams as hp
from scipy.io.wavfile import write
from scipy.signal import lfilter


Expand All @@ -20,8 +21,10 @@ def load_wav(path):
return librosa.load(path, sr=hp.sample_rate)[0]


def save_wav(x, path):
librosa.output.write_wav(path, x.astype(np.float32), sr=hp.sample_rate)
def save_wav(wav, path):
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
write(path, hp.sample_rate, wav_norm.astype(np.int16))
#librosa.output.write_wav(path, x.astype(np.float32), sr=hp.sample_rate)


def split_signal(x):
Expand Down

0 comments on commit 9db0f8a

Please sign in to comment.