class_docstr: A ready-to-use class for Voice Activity Detection (VAD) using a
  pre-trained model.
  
  Example
  -------
  >>> import torchaudio
  >>> from speechbrain.inference.VAD import VAD
  >>> # Model is downloaded from the speechbrain HuggingFace repo
  >>> tmpdir = getfixture("tmpdir")
  >>> VAD = VAD.from_hparams(
  ...     source="speechbrain/vad-crdnn-libriparty",
  ...     savedir=tmpdir,
  ... )
  
  >>> # Perform VAD
  >>> boundaries = VAD.get_speech_segments("tests/samples/single-mic/example1.wav")
docstr: Returns a list containing all the detected speech segments.
  
  Arguments
  ---------
  boundaries: torch.Tensor
      Tensor containing the boundaries of the speech segments.
  audio_file: path
      The original audio file used to compute vad_out.
  before_margin: float
      Used to cut the segments samples a bit before the detected margin.
  after_margin: float
      Use to cut the segments samples a bit after the detected margin.
  
  Returns
  -------
  segments: list
      List containing the detected speech segments
docstr_tok: ["Returns","a","list","containing","all","the","detected","speech","segments",".","Arguments","--","--","--","--","-","boundaries",":","torch.Tensor","Tensor","containing","the","boundaries","of","the","speech","segments",".","audio_file",":","path","The","original","audio","file","used","to","compute","vad_out",".","before_margin",":","float","Used","to","cut","the","segments","samples","a","bit","before","the","detected","margin",".","after_margin",":","float","Use","to","cut","the","segments","samples","a","bit","after","the","detected","margin",".","Returns","--","--","--","-","segments",":","list","List","containing","the","detected","speech","segments"]
code: def get_segments(
      self, boundaries, audio_file, before_margin=0.1, after_margin=0.1
  ):
      """Returns a list containing all the detected speech segments.
  
      Arguments
      ---------
      boundaries: torch.Tensor
          Tensor containing the boundaries of the speech segments.
      audio_file: path
          The original audio file used to compute vad_out.
      before_margin: float
          Used to cut the segments samples a bit before the detected margin.
      after_margin: float
          Use to cut the segments samples a bit after the detected margin.
  
      Returns
      -------
      segments: list
          List containing the detected speech segments
      """
      sample_rate, sig_len = self._get_audio_info(audio_file)
  
      if sample_rate != self.sample_rate:
          raise ValueError(
              "The detected sample rate is different from that set in the hparam file"
          )
  
      segments = []
      for i in range(boundaries.shape[0]):
          beg_sample = boundaries[i, 0] * sample_rate
          end_sample = boundaries[i, 1] * sample_rate
  
          beg_sample = int(
              max(0, beg_sample - before_margin * sample_rate)
          )
          end_sample = int(
              min(sig_len, end_sample + after_margin * sample_rate)
          )
  
          len_seg = end_sample - beg_sample
          vad_segment, fs = torchaudio.load(
              audio_file, frame_offset=beg_sample, num_frames=len_seg
          )
          segments.append(vad_segment)
      return segments
  
imports: import torch
  import torchaudio
  from speechbrain.utils.data_utils import split_path
  from speechbrain.utils.fetching import fetch
  from speechbrain.inference.interfaces import Pretrained
label_desc: Use image node_id 16 for calling the VAD obj's underlying member method code with example usage: obj.get_segments(boundaries, audio_file, before_margin, after_margin) and returns: segments