align the padding in librosa to what is now done in tf backend

This commit is contained in:
mmoussallam
2020-07-24 16:32:32 +02:00
parent e7cd9f8aaa
commit 0016e35192
3 changed files with 27 additions and 73 deletions

View File

@@ -123,7 +123,7 @@ class Separator(object):
data = np.asfortranarray(data)
N = self._params["frame_length"]
H = self._params["frame_step"]
F = int(N/2) + 1
win = hann(N, sym=False)
fstft = istft if inverse else stft
win_len_arg = {"win_length": None,
@@ -131,12 +131,10 @@ class Separator(object):
n_channels = data.shape[-1]
out = []
for c in range(n_channels):
d = np.concatenate((np.zeros((F, 1)), data[:, :, c].T, np.zeros(
(F, 1))), axis=1) if inverse else data[:, c]
d = np.concatenate((np.zeros((N, )), data[:, c], np.zeros((N, )))) if not inverse else data[:, :, c].T
s = fstft(d, hop_length=H, window=win, center=False, **win_len_arg)
if inverse:
s = s[H:]
s = s[:length]
s = s[N:N+length]
s = np.expand_dims(s.T, 2-inverse)
out.append(s)
if len(out) == 1: