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: Detects speech segments within the input file. The input signal can
  be both a short or a long recording. The function computes the
  posterior probabilities on large chunks (e.g, 30 sec), that are read
  sequentially (to avoid storing big signals in memory).
  Each large chunk is, in turn, split into smaller chunks (e.g, 10 seconds)
  that are processed in parallel. The pipeline for detecting the speech
  segments is the following:
      1- Compute posteriors probabilities at the frame level.
      2- Apply a threshold on the posterior probability.
      3- Derive candidate speech segments on top of that.
      4- Apply energy VAD within each candidate segment (optional).
      5- Merge segments that are too close.
      6- Remove segments that are too short.
      7- Double check speech segments (optional).
  
  
  Arguments
  ---------
  audio_file : str
      Path to audio file.
  large_chunk_size: float
      Size (in seconds) of the large chunks that are read sequentially
      from the input audio file.
  small_chunk_size: float
      Size (in seconds) of the small chunks extracted from the large ones.
      The audio signal is processed in parallel within the small chunks.
      Note that large_chunk_size/small_chunk_size must be an integer.
  overlap_small_chunk: bool
      If True, it creates overlapped small chunks (with 50% overlap).
      The probabilities of the overlapped chunks are combined using
      hamming windows.
  apply_energy_VAD: bool
      If True, a energy-based VAD is used on the detected speech segments.
      The neural network VAD often creates longer segments and tends to
      merge close segments together. The energy VAD post-processes can be
      useful for having a fine-grained voice activity detection.
      The energy thresholds is  managed by activation_th and
      deactivation_th (see below).
  double_check: bool
      If True, double checks (using the neural VAD) that the candidate
      speech segments actually contain speech. A threshold on the mean
      posterior probabilities provided by the neural network is applied
      based on the speech_th parameter (see below).
  activation_th:  float
      Threshold of the neural posteriors above which starting a speech segment.
  deactivation_th: float
      Threshold of the neural posteriors below which ending a speech segment.
  en_activation_th: float
      A new speech segment is started it the energy is above activation_th.
      This is active only if apply_energy_VAD is True.
  en_deactivation_th: float
      The segment is considered ended when the energy is <= deactivation_th.
      This is active only if apply_energy_VAD is True.
  speech_th: float
      Threshold on the mean posterior probability within the candidate
      speech segment. Below that threshold, the segment is re-assigned to
      a non-speech region. This is active only if double_check is True.
  close_th: float
      If the distance between boundaries is smaller than close_th, the
      segments will be merged.
  len_th: float
      If the length of the segment is smaller than close_th, the segments
      will be merged.
  
  Returns
  -------
  boundaries: torch.Tensor
      Tensor containing the start second 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: ["Detects","speech","segments","within","the","input","file",".","The","input","signal","can","be","both","a","short","or","a","long","recording",".","The","function","computes","the","posterior","probabilities","on","large","chunks","(","e.g",",","30","sec",")",",","that","are","read","sequentially","(","to","avoid","storing","big","signals","in","memory",")",".","Each","large","chunk","is",",","in","turn",",","split","into","smaller","chunks","(","e.g",",","10","seconds",")","that","are","processed","in","parallel",".","The","pipeline","for","detecting","the","speech","segments","is","the","following",":","1-","Compute","posteriors","probabilities","at","the","frame","level",".","2-","Apply","a","threshold","on","the","posterior","probability",".","3-","Derive","candidate","speech","segments","on","top","of","that",".","4-","Apply","energy","VAD","within","each","candidate","segment","(","optional",")",".","5-","Merge","segments","that","are","too","close",".","6-","Remove","segments","that","are","too","short",".","7-","Double","check","speech","segments","(","optional",")",".","Arguments","--","--","--","--","-","audio_file",":","str","Path","to","audio","file",".","large_chunk_size",":","float","Size","(","in","seconds",")","of","the","large","chunks","that","are","read","sequentially","from","the","input","audio","file",".","small_chunk_size",":","float","Size","(","in","seconds",")","of","the","small","chunks","extracted","from","the","large","ones",".","The","audio","signal","is","processed","in","parallel","within","the","small","chunks",".","Note","that","large_chunk_size\/small_chunk_size","must","be","an","integer",".","overlap_small_chunk",":","bool","If","True",",","it","creates","overlapped","small","chunks","(","with","50","%","overlap",")",".","The","probabilities","of","the","overlapped","chunks","are","combined","using","hamming","windows",".","apply_energy_VAD",":","bool","If","True",",","a","energy-based","VAD","is","used","on","the","detected","speech","segments",".","The","neural","network","VAD","often","creates","longer","segments","and","tends","to","merge","close","segments","together",".","The","energy","VAD","post-processes","can","be","useful","for","having","a","fine-grained","voice","activity","detection",".","The","energy","thresholds","is","managed","by","activation_th","and","deactivation_th","(","see","below",")",".","double_check",":","bool","If","True",",","double","checks","(","using","the","neural","VAD",")","that","the","candidate","speech","segments","actually","contain","speech",".","A","threshold","on","the","mean","posterior","probabilities","provided","by","the","neural","network","is","applied","based","on","the","speech_th","parameter","(","see","below",")",".","activation_th",":","float","Threshold","of","the","neural","posteriors","above","which","starting","a","speech","segment",".","deactivation_th",":","float","Threshold","of","the","neural","posteriors","below","which","ending","a","speech","segment",".","en_activation_th",":","float","A","new","speech","segment","is","started","it","the","energy","is","above","activation_th",".","This","is","active","only","if","apply_energy_VAD","is","True",".","en_deactivation_th",":","float","The","segment","is","considered","ended","when","the","energy","is","<","=","deactivation_th",".","This","is","active","only","if","apply_energy_VAD","is","True",".","speech_th",":","float","Threshold","on","the","mean","posterior","probability","within","the","candidate","speech","segment",".","Below","that","threshold",",","the","segment","is","re-assigned","to","a","non-speech","region",".","This","is","active","only","if","double_check","is","True",".","close_th",":","float","If","the","distance","between","boundaries","is","smaller","than","close_th",",","the","segments","will","be","merged",".","len_th",":","float","If","the","length","of","the","segment","is","smaller","than","close_th",",","the","segments","will","be","merged",".","Returns","--","--","--","-","boundaries",":","torch.Tensor","Tensor","containing","the","start","second","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_speech_segments(
      self,
      audio_file,
      large_chunk_size=30,
      small_chunk_size=10,
      overlap_small_chunk=False,
      apply_energy_VAD=False,
      double_check=True,
      close_th=0.250,
      len_th=0.250,
      activation_th=0.5,
      deactivation_th=0.25,
      en_activation_th=0.5,
      en_deactivation_th=0.0,
      speech_th=0.50,
  ):
      """Detects speech segments within the input file. The input signal can
      be both a short or a long recording. The function computes the
      posterior probabilities on large chunks (e.g, 30 sec), that are read
      sequentially (to avoid storing big signals in memory).
      Each large chunk is, in turn, split into smaller chunks (e.g, 10 seconds)
      that are processed in parallel. The pipeline for detecting the speech
      segments is the following:
          1- Compute posteriors probabilities at the frame level.
          2- Apply a threshold on the posterior probability.
          3- Derive candidate speech segments on top of that.
          4- Apply energy VAD within each candidate segment (optional).
          5- Merge segments that are too close.
          6- Remove segments that are too short.
          7- Double check speech segments (optional).
  
  
      Arguments
      ---------
      audio_file : str
          Path to audio file.
      large_chunk_size: float
          Size (in seconds) of the large chunks that are read sequentially
          from the input audio file.
      small_chunk_size: float
          Size (in seconds) of the small chunks extracted from the large ones.
          The audio signal is processed in parallel within the small chunks.
          Note that large_chunk_size/small_chunk_size must be an integer.
      overlap_small_chunk: bool
          If True, it creates overlapped small chunks (with 50% overlap).
          The probabilities of the overlapped chunks are combined using
          hamming windows.
      apply_energy_VAD: bool
          If True, a energy-based VAD is used on the detected speech segments.
          The neural network VAD often creates longer segments and tends to
          merge close segments together. The energy VAD post-processes can be
          useful for having a fine-grained voice activity detection.
          The energy thresholds is  managed by activation_th and
          deactivation_th (see below).
      double_check: bool
          If True, double checks (using the neural VAD) that the candidate
          speech segments actually contain speech. A threshold on the mean
          posterior probabilities provided by the neural network is applied
          based on the speech_th parameter (see below).
      activation_th:  float
          Threshold of the neural posteriors above which starting a speech segment.
      deactivation_th: float
          Threshold of the neural posteriors below which ending a speech segment.
      en_activation_th: float
          A new speech segment is started it the energy is above activation_th.
          This is active only if apply_energy_VAD is True.
      en_deactivation_th: float
          The segment is considered ended when the energy is <= deactivation_th.
          This is active only if apply_energy_VAD is True.
      speech_th: float
          Threshold on the mean posterior probability within the candidate
          speech segment. Below that threshold, the segment is re-assigned to
          a non-speech region. This is active only if double_check is True.
      close_th: float
          If the distance between boundaries is smaller than close_th, the
          segments will be merged.
      len_th: float
          If the length of the segment is smaller than close_th, the segments
          will be merged.
  
      Returns
      -------
      boundaries: torch.Tensor
          Tensor containing the start second 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).
      """
  
      # Fetch audio file from web if not local
      source, fl = split_path(audio_file)
      audio_file = fetch(fl, source=source)
  
      # Computing speech vs non speech probabilities
      prob_chunks = self.get_speech_prob_file(
          audio_file,
          large_chunk_size=large_chunk_size,
          small_chunk_size=small_chunk_size,
          overlap_small_chunk=overlap_small_chunk,
      )
  
      # Apply a threshold to get candidate speech segments
      prob_th = self.apply_threshold(
          prob_chunks,
          activation_th=activation_th,
          deactivation_th=deactivation_th,
      ).float()
  
      # Compute the boundaries of the speech segments
      boundaries = self.get_boundaries(prob_th, output_value="seconds")
  
      # Apply energy-based VAD on the detected speech segments
      if apply_energy_VAD:
          boundaries = self.energy_VAD(
              audio_file,
              boundaries,
              activation_th=en_activation_th,
              deactivation_th=en_deactivation_th,
          )
  
      # Merge short segments
      boundaries = self.merge_close_segments(
          boundaries, close_th=close_th
      )
  
      # Remove short segments
      boundaries = self.remove_short_segments(boundaries, len_th=len_th)
  
      # Double check speech segments
      if double_check:
          boundaries = self.double_check_speech_segments(
              boundaries, audio_file, speech_th=speech_th
          )
  
      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 17 for calling the VAD obj's underlying member method code with example usage: obj.get_speech_segments(audio_file, large_chunk_size, small_chunk_size, overlap_small_chunk, apply_energy_VAD, double_check, close_th, len_th, activation_th, deactivation_th, en_activation_th, en_deactivation_th, speech_th) and returns: boundaries