code: def spectral_centroid_spread(fft_magnitude, sampling_rate):
      """Computes spectral centroid of frame (given abs(FFT))"""
      ind = (np.arange(1, len(fft_magnitude) + 1)) * (
          sampling_rate / (2.0 * len(fft_magnitude))
      )
  
      Xt = fft_magnitude.copy()
      Xt_max = Xt.max()
      if Xt_max == 0:
          Xt = Xt / eps
      else:
          Xt = Xt / Xt_max
  
      NUM = np.sum(ind * Xt)
      DEN = np.sum(Xt) + eps
  
      # Centroid:
      centroid = NUM / DEN
  
      # Spread:
      spread = np.sqrt(np.sum(((ind - centroid) ** 2) * Xt) / DEN)
  
      # Normalize:
      centroid = centroid / (sampling_rate / 2.0)
      spread = spread / (sampling_rate / 2.0)
  
      return centroid, spread
  
imports: from __future__ import print_function
  import math
  import numpy
  import sys
  from scipy.fftpack import fft
  import matplotlib.pyplot
  from scipy.signal import lfilter
  from scipy.fftpack.realtransforms import dct
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: spectral_centroid_spread(fft_magnitude, sampling_rate) and returns: centroid,  spread