Frequency detection from a sound file Frequency detection from a sound file numpy numpy

Frequency detection from a sound file


I'm not sure if this is what you want, if you just want the FFT:

import scikits.audiolab, scipyx, fs, nbits = scikits.audiolab.wavread(filename)X = scipy.fft(x)

If you want the magnitude response:

import pylabXdb = 20*scipy.log10(scipy.absolute(X))f = scipy.linspace(0, fs, len(Xdb))pylab.plot(f, Xdb)pylab.show()


I think that what you need to do is a Short-time Fourier Transform(STFT). Basically, you do multiple partially overlapping FFTs and add them together for each point in time. Then you would find the peak for each point in time. I haven't done this myself, but I've looked into it some in the past and this is definitely the way to go forward.

There's some Python code to do a STFT here and here.