Skip to content

Commit

Permalink
Fix missing defaults and make utils.py python 2.7 conform
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasDrude committed Nov 8, 2018
1 parent 4023995 commit a5baff8
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions nara_wpe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ def stft(
time_signal,
size,
shift,
*,
axis=-1,
window=signal.blackman,
window_length,
fading,
pad,
symmetric_window,
window_length=None,
fading=True,
pad=True,
symmetric_window=False,
):
"""
ToDo: Open points:
Expand Down Expand Up @@ -189,13 +188,13 @@ def stft(
)
except ValueError as e:
raise ValueError(
f'Could not calculate the stft, something does not match.\n'
f'mapping: {mapping}, '
f'time_signal_seg.shape: {time_signal_seg.shape}, '
f'window.shape: {window.shape}, '
f'size: {size}'
f'axis+1: {axis+1}'
) from e
'Could not calculate the stft, something does not match.\n' +
'mapping: {}, '.format(mapping) +
'time_signal_seg.shape: {}, '.format(time_signal_seg.shape) +
'window.shape: {}, '.format(window.shape) +
'size: {}'.format(size) +
'axis+1: {axis+1}'
)


def _samples_to_stft_frames(samples, size, shift):
Expand Down Expand Up @@ -269,13 +268,12 @@ def _biorthogonal_window_brute_force(analysis_window, shift,

def istft(
stft_signal,
size: int=1024,
shift: int=256,
*,
size=1024,
shift=256,
window=signal.blackman,
fading: bool=True,
window_length: int=None,
symmetric_window: bool=False,
fading=True,
window_length=None,
symmetric_window=False,
):
"""
Calculated the inverse short time Fourier transform to exactly reconstruct
Expand Down Expand Up @@ -327,8 +325,9 @@ def istft(
# window = np.ones_like(window)

time_signal = np.zeros(
(*stft_signal.shape[:-2],
stft_signal.shape[-2] * shift + window_length - shift))
list(stft_signal.shape[:-2]) +
[stft_signal.shape[-2] * shift + window_length - shift]
)

# Get the correct view to time_signal
time_signal_seg = segment_axis_v2(
Expand All @@ -338,7 +337,7 @@ def istft(
# Unbuffered inplace add
np.add.at(
time_signal_seg,
...,
Ellipsis,
window * np.real(irfft(stft_signal))[..., :window_length]
)
# The [..., :window_length] is the inverse of the window padding in rfft.
Expand Down

0 comments on commit a5baff8

Please sign in to comment.