code: def feature_extract(x, x_lens):
      x_lens = np.ceil((x_lens / 160) / 3).astype(np.int32)
  
      # pre-emphasis
      x = np.concatenate(
          (np.expand_dims(x[:, 0], 1), x[:, 1:] - 0.97 * x[:, :-1]),
          axis=1,
      )
  
      # stft
      x = librosa.stft(
          x,
          n_fft=512,
          window=WINDOW,
          hop_length=160,
          win_length=320,
          center=True,
          pad_mode="reflect",
      )
      x = np.stack((x.real, x.imag), axis=-1)
  
      # power spectrum
      x = (x**2).sum(-1)
  
      # mel filter bank
      x = np.matmul(FILTER_BANK, x)
  
      # log
      x = np.log(x + 1e-20)
  
      # feature splice
      seq = [x]
      for i in range(1, 3):
          tmp = np.zeros_like(x)
          tmp[:, :, :-i] = x[:, :, i:]
          seq.append(tmp)
      features = np.concatenate(seq, axis=1)[:, :, ::3]
  
      # normalize
      features_mean = np.zeros(
          (features.shape[0], features.shape[1]), dtype=np.float32
      )
      features_std = np.zeros(
          (features.shape[0], features.shape[1]), dtype=np.float32
      )
      for i in range(features.shape[0]):
          features_mean[i, :] = features[i, :, : x_lens[i]].mean(axis=1)
          features_std[i, :] = features[i, :, : x_lens[i]].std(
              axis=1, ddof=1
          )
      features_std += 1e-5
      features = (
          features - np.expand_dims(features_mean, 2)
      ) / np.expand_dims(features_std, 2)
  
      return features.transpose(2, 0, 1), x_lens.astype(np.float32)
  
imports: import json
  import pathlib
  import numpy
  import librosa
  import soundfile
label_desc: Use image node_id 1 for calling a global function with example usage: feature_extract(x, x_lens) and returns: features,  x_lens