def stSpectralCentroidAndSpread(X, fs):
    'Computes spectral centroid of frame (given abs(FFT))'
    ind = (np.arange(1, (len(X) + 1)) * (fs / (2.0 * len(X))))
    Xt = X.copy()
    Xt = (Xt / Xt.max())
    NUM = np.sum((ind * Xt))
    DEN = (np.sum(Xt) + eps)
    C = (NUM / DEN)
    S = np.sqrt((np.sum((((ind - C) ** 2) * Xt)) / DEN))
    C = (C / (fs / 2.0))
    S = (S / (fs / 2.0))
    return (C, S)
Computes spectral centroid of frame (given abs(FFT))
def stSpectralCentroidAndSpread(X, fs):
    
    ind = (np.arange(1, (len(X) + 1)) * (fs / (2.0 * len(X))))
    Xt = X.copy()
    Xt = (Xt / Xt.max())
    NUM = np.sum((ind * Xt))
    DEN = (np.sum(Xt) + eps)
    C = (NUM / DEN)
    S = np.sqrt((np.sum((((ind - C) ** 2) * Xt)) / DEN))
    C = (C / (fs / 2.0))
    S = (S / (fs / 2.0))
    return (C, S)