docstr: Voice activity detection (VAD) based silence trimming.
  
  Args:
      model_name: NeMo VAD model to load. Valid configurations can be found with
        EncDecClassificationModel.list_available_models()
      vad_sample_rate: Sample rate used for pretrained VAD model.
      vad_threshold: Softmax probability [0, 1] of VAD output, above which audio frames will be classified
        as speech.
      device: Device "cpu" or "cuda" to use for running the VAD model.
      trim_win_length: Length of audio frames to use when doing speech detection. This does not need to match
        the win_length used any other part of the code or model.
      trim_hop_length: Stride of audio frames to use when doing speech detection. This does not need to match
        the hop_length used any other part of the code or model.
      pad_seconds: Audio duration in seconds to keep before and after each speech segment.
        Set this to at least 0.1 to avoid cutting off any speech audio, with larger values
        being safer but increasing the average silence duration left afterwards.
      volume_norm: Whether to normalize the volume of audio before doing speech detection.
docstr_tok: ["Voice","activity","detection","(","VAD",")","based","silence","trimming",".","Args",":","model_name",":","NeMo","VAD","model","to","load",".","Valid","configurations","can","be","found","with","EncDecClassificationModel.list_available_models","(",")","vad_sample_rate",":","Sample","rate","used","for","pretrained","VAD","model",".","vad_threshold",":","Softmax","probability","[","0",",","1","]","of","VAD","output",",","above","which","audio","frames","will","be","classified","as","speech",".","device",":","Device","``","cpu","''","or","``","cuda","''","to","use","for","running","the","VAD","model",".","trim_win_length",":","Length","of","audio","frames","to","use","when","doing","speech","detection",".","This","does","not","need","to","match","the","win_length","used","any","other","part","of","the","code","or","model",".","trim_hop_length",":","Stride","of","audio","frames","to","use","when","doing","speech","detection",".","This","does","not","need","to","match","the","hop_length","used","any","other","part","of","the","code","or","model",".","pad_seconds",":","Audio","duration","in","seconds","to","keep","before","and","after","each","speech","segment",".","Set","this","to","at","least","0.1","to","avoid","cutting","off","any","speech","audio",",","with","larger","values","being","safer","but","increasing","the","average","silence","duration","left","afterwards",".","volume_norm",":","Whether","to","normalize","the","volume","of","audio","before","doing","speech","detection","."]
code: def __init__(
      self,
      model_name: str = "vad_multilingual_marblenet",
      vad_sample_rate: int = 16000,
      vad_threshold: float = 0.5,
      device: str = "cpu",
      speech_frame_threshold: int = 1,
      trim_win_length: int = 4096,
      trim_hop_length: int = 1024,
      pad_seconds: float = 0.1,
      volume_norm: bool = True,
  ) -> None:
      """Voice activity detection (VAD) based silence trimming.
  
      Args:
          model_name: NeMo VAD model to load. Valid configurations can be found with
            EncDecClassificationModel.list_available_models()
          vad_sample_rate: Sample rate used for pretrained VAD model.
          vad_threshold: Softmax probability [0, 1] of VAD output, above which audio frames will be classified
            as speech.
          device: Device "cpu" or "cuda" to use for running the VAD model.
          trim_win_length: Length of audio frames to use when doing speech detection. This does not need to match
            the win_length used any other part of the code or model.
          trim_hop_length: Stride of audio frames to use when doing speech detection. This does not need to match
            the hop_length used any other part of the code or model.
          pad_seconds: Audio duration in seconds to keep before and after each speech segment.
            Set this to at least 0.1 to avoid cutting off any speech audio, with larger values
            being safer but increasing the average silence duration left afterwards.
          volume_norm: Whether to normalize the volume of audio before doing speech detection.
      """
      assert vad_sample_rate > 0
      assert vad_threshold >= 0
      assert speech_frame_threshold > 0
      assert trim_win_length > 0
      assert trim_hop_length > 0
  
      self.device = device
      self.vad_model = (
          EncDecClassificationModel.from_pretrained(
              model_name=model_name
          )
          .eval()
          .to(self.device)
      )
      self.vad_sample_rate = vad_sample_rate
      self.vad_threshold = vad_threshold
  
      self.speech_frame_threshold = speech_frame_threshold
      self.trim_win_length = trim_win_length
      self.trim_hop_length = trim_hop_length
      # Window shift neeeded in order to center frames
      self.trim_shift = self.trim_win_length // 2
  
      self.pad_seconds = pad_seconds
      self.volume_norm = volume_norm
  
imports: from abc import ABC, abstractmethod
  from typing import Tuple
  import librosa
  import numpy
  import torch
  from nemo.collections.asr.models import EncDecClassificationModel
  from nemo.collections.tts.parts.utils.tts_dataset_utils import normalize_volume
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new VadAudioTrimmer object from inherited base classes: AudioTrimmer with example: obj = VadAudioTrimmer(model_name, vad_sample_rate, vad_threshold, device, speech_frame_threshold, trim_win_length, trim_hop_length, pad_seconds, volume_norm)