I have a five second audio (speech with background noise), which I want to process first with bandpass filter and then with wiener filter to reduce noise. Audio is normalized between [-1, 1] and I expect the result to stay in this range also. It does when I do high or low pass filtering, but with a bandpass filtering, the values of the wiener filter explodes (they are approximately in range [-1500, 1500]. Can anybody tell me why?

Here's the Python code. I've tried both butterworth and elliptic filters, different cutoff frequencies and different parts of the audio sample, but all leads to the same result. So does the concatenation of high and low pass filters.

from scipy.io import wavfile
from scipy.signal import sosfilt, butter, wiener, stft, istft
import numpy as np

# bandpass filter
sos = butter(5, [400, 4000], btype='band', output='sos', fs=fs)
filtered = sosfilt(sos, sample, axis=0)

# wiener filter
f, t, fourier = stft(filtered, fs=fs)
y = wiener(fourier)
y = np.asarray(istft(y))
y = y[1, :]

Wiener with bandpass

Wiener with highpass

Original signal

  • $\begingroup$ Hi, Xarzaloxa, and welcome to DSP.SE. Shouldn't the value of the btype parameter be "bandpass" (instead of "band" - see here)? $\endgroup$
    – applesoup
    Commented Oct 12, 2021 at 12:18
  • 2
    $\begingroup$ ... and the wiener function assumes a time-domain signal for input (see here). $\endgroup$
    – applesoup
    Commented Oct 12, 2021 at 12:22

1 Answer 1


Just do:

# wiener filter
#f, t, fourier = stft(filtered, fs=fs)
#yw = wiener(fourier)
#y = np.asarray(istft(yw))
#y = y[1, :]
y = wiener(filtered)

and it appears to work for me.

This is the absolute value of the FFT of the resulting signal:

FFT of Wiener filtered signal

and this is the Wiener filtered signal:

Wiener filtered si

Otherwise, you're doing a Wiener filter on the STFT of the signal which will be doing something completely different from what you expect.

  • $\begingroup$ Thank you, this explained my error! $\endgroup$
    – Xarzaloxa
    Commented Oct 18, 2021 at 8:56
  • $\begingroup$ @Xarzaloxa Cool! Please select this as the accepted answer if this fixes the issue. $\endgroup$
    – Peter K.
    Commented Oct 18, 2021 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.