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: Computes the time boundaries where speech activity is detected.
  It takes in input frame-level binary decisions
  (1 for speech, 0 for non-speech) and outputs the begin/end second
  (or sample) of each detected speech region.
  
  Arguments
  ---------
  prob_th: torch.Tensor
      Frame-level binary decisions (1 for speech frame, 0 for a
      non-speech one).  The tensor can be obtained from apply_threshold.
  output_value: 'seconds' or 'samples'
      When the option 'seconds' is set, the returned boundaries are in
      seconds, otherwise, it reports them in samples.
  
  Returns
  -------
  boundaries: torch.Tensor
      Tensor containing the start second (or sample) of speech segments
      in even positions and their corresponding end in odd positions
      (e.g, [1.0, 1.5, 5,.0 6.0] means that we have two speech segment;
       one from 1.0 to 1.5 seconds and another from 5.0 to 6.0 seconds).
docstr_tok: ["Computes","the","time","boundaries","where","speech","activity","is","detected",".","It","takes","in","input","frame-level","binary","decisions","(","1","for","speech",",","0","for","non-speech",")","and","outputs","the","begin\/end","second","(","or","sample",")","of","each","detected","speech","region",".","Arguments","--","--","--","--","-","prob_th",":","torch.Tensor","Frame-level","binary","decisions","(","1","for","speech","frame",",","0","for","a","non-speech","one",")",".","The","tensor","can","be","obtained","from","apply_threshold",".","output_value",":","'seconds","'","or","'samples'","When","the","option","'seconds","'","is","set",",","the","returned","boundaries","are","in","seconds",",","otherwise",",","it","reports","them","in","samples",".","Returns","--","--","--","-","boundaries",":","torch.Tensor","Tensor","containing","the","start","second","(","or","sample",")","of","speech","segments","in","even","positions","and","their","corresponding","end","in","odd","positions","(","e.g",",","[","1.0",",","1.5",",","5",",",".0","6.0","]","means","that","we","have","two","speech","segment",";","one","from","1.0","to","1.5","seconds","and","another","from","5.0","to","6.0","seconds",")","."]
code: def get_boundaries(self, prob_th, output_value="seconds"):
      """Computes the time boundaries where speech activity is detected.
      It takes in input frame-level binary decisions
      (1 for speech, 0 for non-speech) and outputs the begin/end second
      (or sample) of each detected speech region.
  
      Arguments
      ---------
      prob_th: torch.Tensor
          Frame-level binary decisions (1 for speech frame, 0 for a
          non-speech one).  The tensor can be obtained from apply_threshold.
      output_value: 'seconds' or 'samples'
          When the option 'seconds' is set, the returned boundaries are in
          seconds, otherwise, it reports them in samples.
  
      Returns
      -------
      boundaries: torch.Tensor
          Tensor containing the start second (or sample) of speech segments
          in even positions and their corresponding end in odd positions
          (e.g, [1.0, 1.5, 5,.0 6.0] means that we have two speech segment;
           one from 1.0 to 1.5 seconds and another from 5.0 to 6.0 seconds).
      """
      # Shifting frame-levels binary decision by 1
      # This allows detecting changes in speech/non-speech activities
      prob_th_shifted = torch.roll(prob_th, dims=1, shifts=1)
      prob_th_shifted[:, 0, :] = 0
      prob_th = prob_th + prob_th_shifted
  
      # Needed to first and last time step
      prob_th[:, 0, :] = (prob_th[:, 0, :] >= 1).int()
      prob_th[:, -1, :] = (prob_th[:, -1, :] >= 1).int()
  
      # Fix edge cases (when a speech starts in the last frames)
      if (prob_th == 1).nonzero().shape[0] % 2 == 1:
          prob_th = torch.cat(
              (
                  prob_th,
                  torch.Tensor([1.0])
                  .unsqueeze(0)
                  .unsqueeze(2)
                  .to(self.device),
              ),
              dim=1,
          )
  
      # Where prob_th is 1 there is a change
      indexes = (prob_th == 1).nonzero()[:, 1].reshape(-1, 2)
  
      # Remove 1 from end samples
      indexes[:, -1] = indexes[:, -1] - 1
  
      # From indexes to samples
      seconds = (indexes * self.time_resolution).float()
      samples = (self.sample_rate * seconds).round().int()
  
      if output_value == "seconds":
          boundaries = seconds
      else:
          boundaries = samples
      return boundaries
  
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 6 for calling the VAD obj's underlying member method code with example usage: obj.get_boundaries(prob_th, output_value) and returns: boundaries