code: def data_prep(data_folder, hparams):
      "Creates the datasets and their data processing pipelines."
  
      train_data = sb.dataio.dataset.DynamicItemDataset.from_json(
          json_path=os.path.join(
              data_folder, "../annotation/VAD_train.json"
          ),
          replacements={"data_folder": data_folder},
      )
  
      valid_data = sb.dataio.dataset.DynamicItemDataset.from_json(
          json_path=os.path.join(
              data_folder, "../annotation/VAD_dev.json"
          ),
          replacements={"data_folder": data_folder},
      )
  
      datasets = [train_data, valid_data]
  
      # 1. 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
  
      # 2. vad targets creation from annotated speech boundaries
      @sb.utils.data_pipeline.takes("speech")
      @sb.utils.data_pipeline.provides("target")
      def vad_targets(string, hparams=hparams):
          if len(string) > 0:
              boundaries = string.split(" ")
              # we group by two
              # 0.01 is 10 ms hop size ...
              boundaries = [int(float(x) / 0.01) for x in boundaries]
              boundaries = list(zip(boundaries[::2], boundaries[1::2]))
          else:
              boundaries = []
  
          gt = torch.zeros(
              int(np.ceil(hparams["example_length"] * (1 / 0.01)))
          )
  
          for indxs in boundaries:
              start, stop = indxs
              gt[start:stop] = 1
  
          return gt
  
      sb.dataio.dataset.add_dynamic_item(datasets, audio_pipeline)
      sb.dataio.dataset.add_dynamic_item(datasets, vad_targets)
  
      # 3. Set output:
      sb.dataio.dataset.set_output_keys(
          datasets, ["id", "sig", "target"]
      )
  
      return train_data, valid_data
  
file_path: speechbrain/tests/integration/VAD/example_vad.py
imports: import os
  import torch
  import numpy
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 1 for calling a global function with example usage: data_prep(data_folder, hparams) and returns: train_data,  valid_data, sig, gt