code: def prepare_tedlium2(
      data_folder,
      utt_save_folder,
      csv_save_folder,
      skip_prep=False,
      avoid_if_shorter_than=1,
  ):
      """This function prepares the Tedlium2 dataset.
      Download link: https://lium.univ-lemans.fr/ted-lium2/
  
      Arguments
      ---------
      data_folder : str
          Path to the folder where the original Tedlium2 dataset is stored.
      utt_save_folder : list
          Path where to save the clipped utterence-leve recordings.
      csv_save_folder: str
          Path where to save the generated .csv files.
      skip_prep: bool
          If True, data preparation is skipped.
      avoid_if_shorter_than: int
          Any utterance shorter than this will be discarded.
  
      Example
      -------
      >>> data_folder = 'datasets/TEDLIUM_release2'
      >>> utt_save_folder = 'datasets/TEDLIUM_release2_processed'
      >>> csv_save_folder = 'TEDLIUM2'
      >>> prepare_tedlium2(data_folder, utt_save_folder, csv_save_folder)
      """
      if skip_prep:
          return
  
      splits = [
          "train",
          "dev",
          "test",
      ]
  
      for split in splits:
          utt_save_folder_split = os.path.join(utt_save_folder, split)
          csv_save_folder_split = os.path.join(csv_save_folder, split)
          os.makedirs(utt_save_folder_split, exist_ok=True)
          os.makedirs(csv_save_folder_split, exist_ok=True)
          new_filename = os.path.join(
              csv_save_folder_split, split + ".csv"
          )
          if os.path.exists(new_filename):
              continue
          logger.info("Preparing %s..." % new_filename)
          data_folder_split = os.path.join(data_folder, split)
          talk_sphs = os.listdir(os.path.join(data_folder_split, "sph"))
  
          line_processor = functools.partial(
              process_line,
              avoid_if_shorter_than=avoid_if_shorter_than,
              utt_save_folder_split=utt_save_folder_split,
              data_folder=data_folder,
              split=split,
          )
  
          tmp_csv = os.path.join(csv_save_folder_split, split + ".tmp")
          final_csv = os.path.join(
              csv_save_folder_split, split + ".csv"
          )
          total_line = 0
          total_duration = 0
          with open(tmp_csv, mode="w", encoding="utf-8") as csv_f:
              csv_writer = csv.writer(
                  csv_f,
                  delimiter=",",
                  quotechar='"',
                  quoting=csv.QUOTE_MINIMAL,
              )
  
              csv_writer.writerow(
                  ["ID", "duration", "wav", "spk_id", "wrd"]
              )
              for row in parallel_map(line_processor, talk_sphs):
                  if row is None:
                      continue
  
                  for line in row:
                      csv_writer.writerow(line)
                      total_duration += float(line[1])
                  total_line += len(row)
  
          os.replace(tmp_csv, final_csv)
  
          msg = "\t%s successfully created!" % (new_filename)
          logger.info(msg)
  
          msg = f"Number of samples: {total_line} "
          logger.info(msg)
          msg = "Total duration: %s Hours" % (
              str(round(total_duration / 3600, 2))
          )
          logger.info(msg)
  
file_path: speechbrain/recipes/Tedlium2/tedlium2_prepare.py
imports: import os
  import csv
  import logging
  import torchaudio
  import functools
  from speechbrain.utils.parallel import parallel_map
label_desc: Use image node_id 3 for calling a global function with example usage: prepare_tedlium2(data_folder, utt_save_folder, csv_save_folder, skip_prep, avoid_if_shorter_than) without return types