code: def dataio_prep(hparams):
      "Creates the datasets and their data processing pipelines."
  
      data_folder = hparams["data_folder"]
  
      # 1. Declarations:
      train_data = sb.dataio.dataset.DynamicItemDataset.from_json(
          json_path=hparams["train_annotation"],
          replacements={"data_root": data_folder},
      )
  
      if hparams["sorting"] == "ascending":
          # we sort training data to speed up training and get better results.
          train_data = train_data.filtered_sorted(sort_key="duration")
          # when sorting do not shuffle in dataloader ! otherwise is pointless
          hparams["train_dataloader_opts"]["shuffle"] = False
  
      elif hparams["sorting"] == "descending":
          train_data = train_data.filtered_sorted(
              sort_key="duration", reverse=True
          )
          # when sorting do not shuffle in dataloader ! otherwise is pointless
          hparams["train_dataloader_opts"]["shuffle"] = False
  
      elif hparams["sorting"] == "random":
          pass
  
      else:
          raise NotImplementedError(
              "sorting must be random, ascending or descending"
          )
  
      valid_data = sb.dataio.dataset.DynamicItemDataset.from_json(
          json_path=hparams["valid_annotation"],
          replacements={"data_root": data_folder},
      )
      valid_data = valid_data.filtered_sorted(sort_key="duration")
  
      test_data = sb.dataio.dataset.DynamicItemDataset.from_json(
          json_path=hparams["test_annotation"],
          replacements={"data_root": data_folder},
      )
      test_data = test_data.filtered_sorted(sort_key="duration")
  
      datasets = [train_data, valid_data, test_data]
      label_encoder = sb.dataio.encoder.CTCTextEncoder()
  
      # 2. Define audio pipeline:
      @sb.utils.data_pipeline.takes("wav")
      @sb.utils.data_pipeline.provides("sig")
      def audio_pipeline(wav):
          sig = sb.dataio.dataio.read_audio(wav)
          return sig
  
      sb.dataio.dataset.add_dynamic_item(datasets, audio_pipeline)
  
      # 3. Define text pipeline:
      @sb.utils.data_pipeline.takes("phn")
      @sb.utils.data_pipeline.provides("phn_list", "phn_encoded")
      def text_pipeline(phn):
          phn_list = phn.strip().split()
          yield phn_list
          phn_encoded = label_encoder.encode_sequence_torch(phn_list)
          yield phn_encoded
  
      sb.dataio.dataset.add_dynamic_item(datasets, text_pipeline)
  
      # 3. Fit encoder:
      # Load or compute the label encoder (with multi-gpu dpp support)
      lab_enc_file = os.path.join(
          hparams["save_folder"], "label_encoder.txt"
      )
      label_encoder.load_or_create(
          path=lab_enc_file,
          from_didatasets=[train_data],
          output_key="phn_list",
          special_labels={"blank_label": hparams["blank_index"]},
          sequence_input=True,
      )
  
      # 4. Set output:
      sb.dataio.dataset.set_output_keys(
          datasets, ["id", "sig", "phn_encoded"]
      )
  
      return train_data, valid_data, test_data, label_encoder
  
file_path: speechbrain/recipes/TIMIT/ASR/CTC/train.py
imports: import os
  import sys
  import logging
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main, if_main_process
label_desc: Use image node_id 1 for calling a global function with example usage: dataio_prep(hparams) and returns: train_data,  valid_data,  test_data,  label_encoder, sig