def fft_spectrum ( frames , fft_points = 512 ) : SPECTRUM_VECTOR = np . fft . rfft ( frames , n = fft_points , axis = - 1 , norm = None ) return np . absolute ( SPECTRUM_VECTOR )
python fft high amplitude at 0
This function computes the one - dimensional n - point discrete Fourier Transform ( DFT ) of a real - valued array by means of an efficient algorithm called the Fast Fourier Transform ( FFT ) . Please refer to https : // docs . scipy . org / doc / numpy / reference / generated / numpy . fft . rfft . html for further details .
def fft_spectrum(frames, fft_points=512):
    """This function computes the one-dimensional n-point discrete Fourier
    Transform (DFT) of a real-valued array by means of an efficient algorithm
    called the Fast Fourier Transform (FFT). Please refer to
    https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.rfft.html
    for further details.

    Args:
        frames (array): The frame array in which each row is a frame.
        fft_points (int): The length of FFT. If fft_length is greater than frame_len, the frames will be zero-padded.

    Returns:
            array: The fft spectrum.
            If frames is an num_frames x sample_per_frame matrix, output
            will be num_frames x FFT_LENGTH.
    """
    SPECTRUM_VECTOR = np.fft.rfft(frames, n=fft_points, axis=-1, norm=None)
    return np.absolute(SPECTRUM_VECTOR)