Skip to content

Commit

Permalink
Update unitests of stft op.
Browse files Browse the repository at this point in the history
  • Loading branch information
KPatr1ck committed Mar 18, 2022
1 parent 6f18f8c commit 1276abf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion paddle/fluid/operators/overlap_add_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class OverlapAddOp : public framework::OperatorWithKernel {
hop_length, frame_length));
}

if (n_frames == -1 && frame_length == -1) {
if (n_frames == -1) {
seq_length = -1;
} else {
seq_length = (n_frames - 1) * hop_length + frame_length;
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/fluid/tests/unittests/test_stft_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def setUp(self):
self.outputs = {'Out': stft_np(x=self.inputs['X'], **self.attrs)}

def initTestCase(self):
input_shape = (2, 1600)
input_shape = (2, 100)
input_type = 'float64'
attrs = {
'n_fft': 50,
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def istft(x,

window_envelop = overlap_add(
x=paddle.tile(
x=paddle.multiply(window, window),
x=paddle.multiply(window, window).unsqueeze(0),
repeat_times=[n_frames, 1]).transpose(
perm=[1, 0]), # (n_fft, num_frames)
hop_length=hop_length,
Expand All @@ -566,7 +566,7 @@ def istft(x,
window_envelop = window_envelop[start:start + length]

# Check whether the Nonzero Overlap Add (NOLA) constraint is met.
if window_envelop.abs().min().item() < 1e-11:
if in_dygraph_mode() and window_envelop.abs().min().item() < 1e-11:
raise ValueError(
'Abort istft because Nonzero Overlap Add (NOLA) condition failed. For more information about NOLA constraint please see `scipy.signal.check_NOLA`(https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.check_NOLA.html).'
)
Expand Down

0 comments on commit 1276abf

Please sign in to comment.