code: def prepare_csv(
      seg_dur, wav_lst, csv_file, random_segment=False, amp_th=0
  ):
      """
      Creates the csv file given a list of wav files.
  
      Arguments
      ---------
      wav_lst : list
          The list of wav files of a given data split.
      csv_file : str
          The path of the output csv file
      random_segment: bool
          Read random segments
      amp_th: float
          Threshold on the average amplitude on the chunk.
          If under this threshold, the chunk is discarded.
  
      Returns
      -------
      None
      """
  
      msg = '\t"Creating csv lists in  %s..."' % (csv_file)
      logger.info(msg)
  
      csv_output = [
          ["ID", "duration", "wav", "start", "stop", "spk_id"]
      ]
  
      # For assigning unique ID to each chunk
      my_sep = "--"
      entry = []
      # Processing all the wav files in the list
      for wav_file in tqdm(wav_lst, dynamic_ncols=True):
          # Getting sentence and speaker ids
          try:
              [spk_id, sess_id, utt_id] = wav_file.split("/")[-3:]
          except ValueError:
              logger.info(f"Malformed path: {wav_file}")
              continue
          audio_id = my_sep.join(
              [spk_id, sess_id, utt_id.split(".")[0]]
          )
  
          # Reading the signal (to retrieve duration in seconds)
          signal, fs = torchaudio.load(wav_file)
          signal = signal.squeeze(0)
  
          if random_segment:
              audio_duration = signal.shape[0] / SAMPLERATE
              start_sample = 0
              stop_sample = signal.shape[0]
  
              # Composition of the csv_line
              csv_line = [
                  audio_id,
                  str(audio_duration),
                  wav_file,
                  start_sample,
                  stop_sample,
                  spk_id,
              ]
              entry.append(csv_line)
          else:
              audio_duration = signal.shape[0] / SAMPLERATE
  
              uniq_chunks_list = _get_chunks(
                  seg_dur, audio_id, audio_duration
              )
              for chunk in uniq_chunks_list:
                  s, e = chunk.split("_")[-2:]
                  start_sample = int(float(s) * SAMPLERATE)
                  end_sample = int(float(e) * SAMPLERATE)
  
                  #  Avoid chunks with very small energy
                  mean_sig = torch.mean(
                      np.abs(signal[start_sample:end_sample])
                  )
                  if mean_sig < amp_th:
                      continue
  
                  # Composition of the csv_line
                  csv_line = [
                      chunk,
                      str(audio_duration),
                      wav_file,
                      start_sample,
                      end_sample,
                      spk_id,
                  ]
                  entry.append(csv_line)
  
      csv_output = csv_output + entry
  
      # Writing the csv lines
      with open(csv_file, mode="w") as csv_f:
          csv_writer = csv.writer(
              csv_f,
              delimiter=",",
              quotechar='"',
              quoting=csv.QUOTE_MINIMAL,
          )
          for line in csv_output:
              csv_writer.writerow(line)
  
      # Final prints
      msg = "\t%s successfully created!" % (csv_file)
      logger.info(msg)
  
file_path: speechbrain/recipes/VoxCeleb/SpeakerRec/voxceleb_prepare.py
imports: import os
  import csv
  import logging
  import glob
  import random
  import shutil
  import sys
  import numpy
  import torch
  import torchaudio
  from tqdm.contrib import tqdm
  from speechbrain.dataio.dataio import load_pkl, save_pkl
label_desc: Use image node_id 6 for calling a global function with example usage: prepare_csv(seg_dur, wav_lst, csv_file, random_segment, amp_th) without return types