# -*- coding: utf-8 -*-
"""
computes the spectral slope from the magnitude spectrum

  Args:
    X: spectrogram (dimension FFTLength X Observations)
    f_s: sample rate of audio data

  Returns:
    vssl spectral slope
"""

import numpy as np
  
    
def FeatureSpectralSlope(X,f_s):   
    
    # compute mean
    mu_x = X.mean(axis=0,keepdims=True)

    # compute index vector
    kmu = np.arange(0, X.shape[0]) - X.shape[0]/2
 
    # compute slope
    X = X - mu_x
    vssl = np.dot(kmu, X)/np.dot(kmu,kmu)

    return (vssl)