code: def feature_extraction(
      signal, sampling_rate, window, step, deltas=True
  ):
      """
      This function implements the shor-term windowing process.
      For each short-term window a set of features is extracted.
      This results to a sequence of feature vectors, stored in a np matrix.
  
      ARGUMENTS
          signal:         the input signal samples
          sampling_rate:  the sampling freq (in Hz)
          window:         the short-term window size (in samples)
          step:           the short-term window step (in samples)
          deltas:         (opt) True/False if delta features are to be
                          computed
      RETURNS
          features (numpy.ndarray):        contains features
                                           (n_feats x numOfShortTermWindows)
          feature_names (python list):     contains feature names
                                           (n_feats x numOfShortTermWindows)
      """
  
      window = int(window)
      step = int(step)
  
      # signal normalization
      signal = np.double(signal)
      signal = signal / (2.0**15)
  
      signal = dc_normalize(signal)
  
      number_of_samples = len(signal)  # total number of samples
      current_position = 0
      count_fr = 0
      num_fft = int(window / 2)
  
      # compute the triangular filter banks used in the mfcc calculation
      fbank, freqs = mfcc_filter_banks(sampling_rate, num_fft)
  
      n_time_spectral_feats = 8
      n_harmonic_feats = 0
      n_mfcc_feats = 13
      n_chroma_feats = 13
      n_total_feats = (
          n_time_spectral_feats
          + n_mfcc_feats
          + n_harmonic_feats
          + n_chroma_feats
      )
      #    n_total_feats = n_time_spectral_feats + n_mfcc_feats +
      #    n_harmonic_feats
  
      # define list of feature names
      feature_names = ["zcr", "energy", "energy_entropy"]
      feature_names += ["spectral_centroid", "spectral_spread"]
      feature_names.append("spectral_entropy")
      feature_names.append("spectral_flux")
      feature_names.append("spectral_rolloff")
      feature_names += [
          "mfcc_{0:d}".format(mfcc_i)
          for mfcc_i in range(1, n_mfcc_feats + 1)
      ]
      feature_names += [
          "chroma_{0:d}".format(chroma_i)
          for chroma_i in range(1, n_chroma_feats)
      ]
      feature_names.append("chroma_std")
  
      # add names for delta features:
      if deltas:
          feature_names_2 = feature_names + [
              "delta " + f for f in feature_names
          ]
          feature_names = feature_names_2
  
      features = []
      # for each short-term window to end of signal
      while current_position + window - 1 < number_of_samples:
          count_fr += 1
          # get current window
          x = signal[current_position : current_position + window]
  
          # update window position
          current_position = current_position + step
  
          # get fft magnitude
          fft_magnitude = abs(fft(x))
  
          # normalize fft
          fft_magnitude = fft_magnitude[0:num_fft]
          fft_magnitude = fft_magnitude / len(fft_magnitude)
  
          # keep previous fft mag (used in spectral flux)
          if count_fr == 1:
              fft_magnitude_previous = fft_magnitude.copy()
          feature_vector = np.zeros((n_total_feats, 1))
  
          # zero crossing rate
          feature_vector[0] = zero_crossing_rate(x)
  
          # short-term energy
          feature_vector[1] = energy(x)
  
          # short-term entropy of energy
          feature_vector[2] = energy_entropy(x)
  
          # sp centroid/spread
          [
              feature_vector[3],
              feature_vector[4],
          ] = spectral_centroid_spread(fft_magnitude, sampling_rate)
  
          # spectral entropy
          feature_vector[5] = spectral_entropy(fft_magnitude)
  
          # spectral flux
          feature_vector[6] = spectral_flux(
              fft_magnitude, fft_magnitude_previous
          )
  
          # spectral rolloff
          feature_vector[7] = spectral_rolloff(fft_magnitude, 0.90)
  
          # MFCCs
          mffc_feats_end = n_time_spectral_feats + n_mfcc_feats
          feature_vector[
              n_time_spectral_feats:mffc_feats_end, 0
          ] = mfcc(fft_magnitude, fbank, n_mfcc_feats).copy()
  
          # chroma features
          chroma_names, chroma_feature_matrix = chroma_features(
              fft_magnitude, sampling_rate, num_fft
          )
          chroma_features_end = (
              n_time_spectral_feats + n_mfcc_feats + n_chroma_feats - 1
          )
          feature_vector[
              mffc_feats_end:chroma_features_end
          ] = chroma_feature_matrix
          feature_vector[
              chroma_features_end
          ] = chroma_feature_matrix.std()
          if not deltas:
              features.append(feature_vector)
          else:
              # delta features
              if count_fr > 1:
                  delta = feature_vector - feature_vector_prev
                  feature_vector_2 = np.concatenate(
                      (feature_vector, delta)
                  )
              else:
                  feature_vector_2 = np.concatenate(
                      (feature_vector, np.zeros(feature_vector.shape))
                  )
              feature_vector_prev = feature_vector
              features.append(feature_vector_2)
  
          fft_magnitude_previous = fft_magnitude.copy()
  
      features = np.concatenate(features, 1)
      return features, feature_names
  
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 18 for calling a global function with example usage: feature_extraction(signal, sampling_rate, window, step, deltas) and returns: features,  feature_names