code: def prepare_librispeech(
      data_folder,
      save_folder,
      tr_splits=[],
      dev_splits=[],
      te_splits=[],
      select_n_sentences=None,
      merge_lst=[],
      merge_name=None,
      create_lexicon=False,
      skip_prep=False,
  ):
      """
      This class prepares the csv files for the LibriSpeech dataset.
      Download link: http://www.openslr.org/12
  
      Arguments
      ---------
      data_folder : str
          Path to the folder where the original LibriSpeech dataset is stored.
      tr_splits : list
          List of train splits to prepare from ['test-others','train-clean-100',
          'train-clean-360','train-other-500'].
      dev_splits : list
          List of dev splits to prepare from ['dev-clean','dev-others'].
      te_splits : list
          List of test splits to prepare from ['test-clean','test-others'].
      save_folder : str
          The directory where to store the csv files.
      select_n_sentences : int
          Default : None
          If not None, only pick this many sentences.
      merge_lst : list
          List of librispeech splits (e.g, train-clean, train-clean-360,..) to
          merge in a singe csv file.
      merge_name: str
          Name of the merged csv file.
      create_lexicon: bool
          If True, it outputs csv files containing mapping between grapheme
          to phonemes. Use it for training a G2P system.
      skip_prep: bool
          If True, data preparation is skipped.
  
  
      Example
      -------
      >>> data_folder = 'datasets/LibriSpeech'
      >>> tr_splits = ['train-clean-100']
      >>> dev_splits = ['dev-clean']
      >>> te_splits = ['test-clean']
      >>> save_folder = 'librispeech_prepared'
      >>> prepare_librispeech(data_folder, save_folder, tr_splits, dev_splits, te_splits)
      """
  
      if skip_prep:
          return
      data_folder = data_folder
      splits = tr_splits + dev_splits + te_splits
      save_folder = save_folder
      select_n_sentences = select_n_sentences
      conf = {
          "select_n_sentences": select_n_sentences,
      }
  
      # Other variables
      # Saving folder
      if not os.path.exists(save_folder):
          os.makedirs(save_folder)
  
      save_opt = os.path.join(save_folder, OPT_FILE)
  
      # Check if this phase is already done (if so, skip it)
      if skip(splits, save_folder, conf):
          logger.info(
              "Skipping preparation, completed in previous run."
          )
          return
      else:
          logger.info("Data_preparation...")
  
      # Additional checks to make sure the data folder contains Librispeech
      check_librispeech_folders(data_folder, splits)
  
      # create csv files for each split
      all_texts = {}
      for split_index in range(len(splits)):
          split = splits[split_index]
  
          wav_lst = get_all_files(
              os.path.join(data_folder, split), match_and=[".flac"]
          )
  
          text_lst = get_all_files(
              os.path.join(data_folder, split), match_and=["trans.txt"]
          )
  
          text_dict = text_to_dict(text_lst)
          all_texts.update(text_dict)
  
          if select_n_sentences is not None:
              n_sentences = select_n_sentences[split_index]
          else:
              n_sentences = len(wav_lst)
  
          create_csv(
              save_folder,
              wav_lst,
              text_dict,
              split,
              n_sentences,
          )
  
      # Merging csv file if needed
      if merge_lst and merge_name is not None:
          merge_files = [
              split_libri + ".csv" for split_libri in merge_lst
          ]
          merge_csvs(
              data_folder=save_folder,
              csv_lst=merge_files,
              merged_csv=merge_name,
          )
  
      # Create lexicon.csv and oov.csv
      if create_lexicon:
          create_lexicon_and_oov_csv(
              all_texts, data_folder, save_folder
          )
  
      # saving options
      save_pkl(conf, save_opt)
  
file_path: speechbrain/recipes/LibriSpeech/G2P/librispeech_prepare.py
imports: import os
  import csv
  import random
  from collections import Counter
  from dataclasses import dataclass
  import functools
  import logging
  from speechbrain.utils.data_utils import download_file, get_all_files
  from speechbrain.dataio.dataio import load_pkl, save_pkl, merge_csvs, read_audio_info
  from speechbrain.utils.parallel import parallel_map
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_librispeech(data_folder, save_folder, tr_splits, dev_splits, te_splits, select_n_sentences, merge_lst, merge_name, create_lexicon, skip_prep) without return types