I calculated FFT for a speech wav-file using scipy.fftpack. How do I read (understand) the return of FFT? I have read that it supposed to be like so: y[0] is 0Hz loudness, y[1] is 1Hz loundess, ... y[n] is nHz loudness ... But seems like it is not like that exactly.
Q1: What will I get when I do abs(y)? I know that we get list of complex numbers from FFT and need to square() or abs() them. But what we will have after that? Is this Decibels?
Q2: Why do we need normalize wav-data before doing FFT? What does depend on this? Before and after normalization I get different results from FFT. If I do normalization, then results of FFT are measured by hundreds, if I don't the results are measured by 1.x small values... Is this Decibels also?
# Read wav-data
fs, data = wavfile.read('eric.wav')
# this is a two channel soundtrack, I get the first track
wavdata = data.T[0]
# this is 16-bit track, b is now normalized on [-1,1)
wavdata = wavdata / (2.0**15)
Q3: What is length of the returned list from FFT? Seems like the length of the result depends on length of given sound file... But in Q1 I supposed to get list of frequencies and their loudness independently from a given source of data. For now, if I cut in half wavdata I will get twice shorter resulting list from FFT...
Complete simple code:
import matplotlib.pyplot as plt
from scipy.fftpack import fft
from scipy.io import wavfile
# load the data
fs, data = wavfile.read('eric.wav')
# this is a two channel soundtrack, I get the first track
a = data.T[0]
# calculate fourier transform
y = fft(a)
# show
plt.plot(abs(y), 'g')
plt.show()
Q4: What do I process results form FFT to get it in form Db vs Hz?
Wav-file could be found here: https://aacapps.com/lamp/voices Thanks.
y[1]
corresponds to 1 Hz. You must calculate the frequencies of corresponding bins, which are separated byfs/N
- N being the size of FFT. $\endgroup$ – jojek♦ Feb 1 '18 at 20:23