I'm trying to design a bandstop filter and it's failing to give me a valid (wav file) output due to nan values in the filter output.
The input is a simple speech clip a few seconds long.
def bandstop(x, f1, f2):
fs, samples = wavfile.read(x)
N = 6 # filter order
rs = 60 # stop band minimum attenuation
b, a = signal.cheby2(N, rs, [2 * f1 / fs, 2 * f2 / fs], btype='bandstop')
xfiltered = signal.filtfilt(b, a, samples) # applying filter
wavfile.write("xfiltered.wav", fs, xfiltered) # returns unreadable file?
I'm testing this with a simple
print xfiltered
to find nan values. Any solutions?