The problem is that when you call abs() in mfcc(), nmax is not yet defined, as that does not happen until you call melFilterBank() later down in the function. Move your definition of nmaxto the beginning of mfcc() instead: def mfcc(signal,nfft,fs,nceps): global nmax nmax = nfft...