code: def prepare_aishell(
      data_folder,
      save_folder,
      skip_prep=False,
      remove_compressed_wavs=True,
  ):
      """This function prepares the AISHELL-1 dataset.
  
      Arguments
      ---------
      data_folder: str
          path to AISHELL-1 dataset.
      save_folder: str
          path where to store the manifest csv files.
      skip_prep: bool
          If True, skip data preparation.
      remove_compressed_wavs: bool
          If True, remove compressed wav files after extraction.
      """
  
      if skip_prep:
          return
  
      wav_dir = os.path.join(data_folder, "wav")
      tgz_list = glob.glob(wav_dir + "/*.tar.gz")
  
      splits = [
          "train",
          "dev",
          "test",
      ]
  
      if skip(splits, save_folder):
          return
  
      extract_and_cleanup_wav_files(
          tgz_list,
          wav_dir,
          splits,
          remove_compressed_wavs=remove_compressed_wavs,
      )
  
      # Create filename-to-transcript dictionary
      filename2transcript = {}
      path_to_transcript = os.path.join(
          data_folder, "transcript/aishell_transcript_v0.8.txt"
      )
  
      with open(
          path_to_transcript,
          "r",
      ) as f:
          lines = f.readlines()
          for line in lines:
              key = line.split()[0]
              value = " ".join(line.split()[1:])
              filename2transcript[key] = value
  
      line_processor = functools.partial(
          process_line,
          filename2transcript=filename2transcript,
      )
  
      for split in splits:
          final_csv = os.path.join(save_folder, split) + ".csv"
          tmp_csv = os.path.join(save_folder, split) + ".tmp"
  
          logger.info("Preparing %s..." % final_csv)
  
          all_wavs = glob.glob(
              os.path.join(data_folder, "wav")
              + "/"
              + split
              + "/*/*.wav"
          )
          # only keep the files that are in the transcript
          transcript_wavs = [
              wav
              for wav in all_wavs
              if wav.split("/")[-1].split(".wav")[0]
              in filename2transcript
          ]
  
          total_line = 0
          total_duration = 0
          id = 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", "transcript"]
              )
              for row in parallel_map(
                  line_processor, transcript_wavs, chunk_size=4092
              ):
                  if row is None:
                      continue
  
                  row = [str(id)] + row
                  csv_writer.writerow(row)
  
                  total_line += 1
                  total_duration += float(row[1])
                  id += 1
  
          msg = f"Number of samples: {total_line} "
          logger.info(msg)
          msg = "Total duration: %s Hours" % (
              str(round(total_duration / 3600, 2))
          )
  
          logger.info(msg)
  
          os.replace(tmp_csv, final_csv)
  
          msg = "\t%s successfully created!" % (final_csv)
          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/AISHELL-1/ASR/CTC/aishell_prepare.py
imports: import os
  import shutil
  import logging
  import glob
  import csv
  from speechbrain.dataio.dataio import read_audio_info
  from speechbrain.utils.parallel import parallel_map
  import functools
label_desc: Use image node_id 4 for calling a global function with example usage: prepare_aishell(data_folder, save_folder, skip_prep, remove_compressed_wavs) without return types