code: def directory_feature_extraction(
      folder_path,
      mid_window,
      mid_step,
      short_window,
      short_step,
      compute_beat=True,
  ):
      """
      This function extracts the mid-term features of the WAVE files of a
      particular folder.
  
      The resulting feature vector is extracted by long-term averaging the
      mid-term features.
      Therefore ONE FEATURE VECTOR is extracted for each WAV file.
  
      ARGUMENTS:
          - folder_path:        the path of the WAVE directory
          - mid_window, mid_step:    mid-term window and step (in seconds)
          - short_window, short_step:    short-term window and step (in seconds)
      """
  
      mid_term_features = np.array([])
      process_times = []
  
      types = ("*.wav", "*.aif", "*.aiff", "*.mp3", "*.au", "*.ogg")
      wav_file_list = []
      for files in types:
          wav_file_list.extend(
              glob.glob(os.path.join(folder_path, files))
          )
  
      wav_file_list = sorted(wav_file_list)
      wav_file_list2, mid_feature_names = [], []
      for i, file_path in enumerate(wav_file_list):
          print(
              "Analyzing file {0:d} of {1:d}: {2:s}".format(
                  i + 1, len(wav_file_list), file_path
              )
          )
          if os.stat(file_path).st_size == 0:
              print("   (EMPTY FILE -- SKIPPING)")
              continue
          sampling_rate, signal = audioBasicIO.read_audio_file(
              file_path
          )
          if sampling_rate == 0:
              continue
  
          t1 = time.time()
          signal = audioBasicIO.stereo_to_mono(signal)
          if signal.shape[0] < float(sampling_rate) / 5:
              print("  (AUDIO FILE TOO SMALL - SKIPPING)")
              continue
          wav_file_list2.append(file_path)
          if compute_beat:
              (
                  mid_features,
                  short_features,
                  mid_feature_names,
              ) = mid_feature_extraction(
                  signal,
                  sampling_rate,
                  round(mid_window * sampling_rate),
                  round(mid_step * sampling_rate),
                  round(sampling_rate * short_window),
                  round(sampling_rate * short_step),
              )
              beat, beat_conf = beat_extraction(
                  short_features, short_step
              )
          else:
              (
                  mid_features,
                  _,
                  mid_feature_names,
              ) = mid_feature_extraction(
                  signal,
                  sampling_rate,
                  round(mid_window * sampling_rate),
                  round(mid_step * sampling_rate),
                  round(sampling_rate * short_window),
                  round(sampling_rate * short_step),
              )
  
          mid_features = np.transpose(mid_features)
          mid_features = mid_features.mean(axis=0)
          # long term averaging of mid-term statistics
          if (not np.isnan(mid_features).any()) and (
              not np.isinf(mid_features).any()
          ):
              if compute_beat:
                  mid_features = np.append(mid_features, beat)
                  mid_features = np.append(mid_features, beat_conf)
                  mid_feature_names += ["bpm", "ratio"]
              if len(mid_term_features) == 0:
                  # append feature vector
                  mid_term_features = mid_features
              else:
                  mid_term_features = np.vstack(
                      (mid_term_features, mid_features)
                  )
              t2 = time.time()
              duration = float(len(signal)) / sampling_rate
              process_times.append((t2 - t1) / duration)
      if len(process_times) > 0:
          print(
              "Feature extraction complexity ratio: "
              "{0:.1f} x realtime".format(
                  (1.0 / np.mean(np.array(process_times)))
              )
          )
      return mid_term_features, wav_file_list2, mid_feature_names
  
file_path: pyAudioAnalysis/pyAudioAnalysis/MidTermFeatures.py
imports: from __future__ import print_function
  import os
  import time
  import glob
  import numpy
  import matplotlib.pyplot
  import sys
  from pyAudioAnalysis import utilities
  from pyAudioAnalysis import audioBasicIO
  from pyAudioAnalysis import ShortTermFeatures
label_desc: Use image node_id 3 for calling a global function with example usage: directory_feature_extraction(folder_path, mid_window, mid_step, short_window, short_step, compute_beat) and returns: mid_term_features,  wav_file_list2,  mid_feature_names