code: def resample_file(resampled_dir, filepath, ext, sample_rate):
      """
      Resample an audio file to 16kHZ and transform to monochannel
      Remove incompatible files.
  
      Args:
          resampled_dir: Directory of transformed files.
          filepath: Filepath of Audio
          ext: File type e.g. "wav", "flac"
  
      Returns:
  
      """
      head, filename = os.path.split(filepath)
      _, clsname = os.path.split(head)
  
      filename, _ = os.path.splitext(filename)
  
      new_dir = os.path.join(resampled_dir, clsname)
      if not os.path.exists(new_dir):
          os.makedirs(new_dir)
  
      new_path = os.path.join(new_dir, filename + f".{ext}")
  
      # check if the resampled data exists.
      if os.path.exists(new_path):
          print(f"Resampled file {filepath} exists. Skip it.")
          return None
  
      transform = sox.Transformer()
      transform.set_output_format(file_type="wav")
      transform.convert(samplerate=sample_rate, n_channels=1)
  
      try:
          transform.build(filepath, new_path)
          print(f"Finished converting file {filepath}.")
  
          return None
  
      except sox.core.SoxError as e:
          try:
              # Check if the file is readable
              librosa.load(path=filepath)
  
              # if it is, force input format and try again
              transform.set_input_format(file_type=ext)
              transform.build(filepath, new_path)
              return None
  
          except Exception:
              return filepath
  
file_path: NeMo/scripts/freesound_download_resample/freesound_resample.py
imports: import argparse
  import glob
  import os
  import time
  import librosa
  import sox
  from joblib import Parallel, delayed
label_desc: Use image node_id 1 for calling a global function with example usage: resample_file(resampled_dir, filepath, ext, sample_rate) and returns: None, None, None, filepath