class_docstr: Exportable, `torchaudio`-based implementation of Mel Spectrogram extraction.
  
  See `AudioToMelSpectrogramPreprocessor` for args.
class_docstr_tok: ["Exportable",",","`","torchaudio","`","-based","implementation","of","Mel","Spectrogram","extraction",".","See","`","AudioToMelSpectrogramPreprocessor","`","for","args","."]
code: def __init__(
      self,
      sample_rate: int = 16000,
      n_window_size: int = 320,
      n_window_stride: int = 160,
      normalize: Optional[str] = "per_feature",
      nfilt: int = 64,
      n_fft: Optional[int] = None,
      preemph: float = 0.97,
      lowfreq: float = 0,
      highfreq: Optional[float] = None,
      log: bool = True,
      log_zero_guard_type: str = "add",
      log_zero_guard_value: Union[float, str] = 2**-24,
      dither: float = 1e-5,
      window: str = "hann",
      pad_to: int = 0,
      pad_value: float = 0.0,
      mel_norm="slaney",
      # Seems like no one uses these options anymore. Don't convolute the code by supporting thm.
      use_grads: bool = False,  # Deprecated arguments; kept for config compatibility
      max_duration: float = 16.7,  # Deprecated arguments; kept for config compatibility
      frame_splicing: int = 1,  # Deprecated arguments; kept for config compatibility
      exact_pad: bool = False,  # Deprecated arguments; kept for config compatibility
      nb_augmentation_prob: float = 0.0,  # Deprecated arguments; kept for config compatibility
      nb_max_freq: int = 4000,  # Deprecated arguments; kept for config compatibility
      mag_power: float = 2.0,  # Deprecated arguments; kept for config compatibility
      rng: Optional[
          random.Random
      ] = None,  # Deprecated arguments; kept for config compatibility
      stft_exact_pad: bool = False,  # Deprecated arguments; kept for config compatibility
      stft_conv: bool = False,  # Deprecated arguments; kept for config compatibility
  ):
      super().__init__()
      if not HAVE_TORCHAUDIO:
          raise ValueError(
              f"Need to install torchaudio to instantiate a {self.__class__.__name__}"
          )
  
      # Make sure log zero guard is supported, if given as a string
      supported_log_zero_guard_strings = {"eps", "tiny"}
      if (
          isinstance(log_zero_guard_value, str)
          and log_zero_guard_value
          not in supported_log_zero_guard_strings
      ):
          raise ValueError(
              f"Log zero guard value must either be a float or a member of {supported_log_zero_guard_strings}"
          )
  
      # Copied from `AudioPreprocessor` due to the ad-hoc structuring of the Mel Spec extractor class
      self.torch_windows = {
          "hann": torch.hann_window,
          "hamming": torch.hamming_window,
          "blackman": torch.blackman_window,
          "bartlett": torch.bartlett_window,
          "ones": torch.ones,
          None: torch.ones,
      }
  
      # Ensure we can look up the window function
      if window not in self.torch_windows:
          raise ValueError(
              f"Got window value '{window}' but expected a member of {self.torch_windows.keys()}"
          )
  
      self.win_length = n_window_size
      self.hop_length = n_window_stride
      self._sample_rate = sample_rate
      self._normalize_strategy = normalize
      self._use_log = log
      self._preemphasis_value = preemph
      self.log_zero_guard_type = log_zero_guard_type
      self.log_zero_guard_value: Union[
          str, float
      ] = log_zero_guard_value
      self.dither = dither
      self.pad_to = pad_to
      self.pad_value = pad_value
      self.n_fft = n_fft
      self._mel_spec_extractor: torchaudio.transforms.MelSpectrogram = (
          torchaudio.transforms.MelSpectrogram(
              sample_rate=self._sample_rate,
              win_length=self.win_length,
              hop_length=self.hop_length,
              n_mels=nfilt,
              window_fn=self.torch_windows[window],
              mel_scale="slaney",
              norm=mel_norm,
              n_fft=n_fft,
              f_max=highfreq,
              f_min=lowfreq,
              wkwargs={"periodic": False},
          )
      )
  
imports: import math
  import random
  from typing import Optional, Tuple, Union
  import librosa
  import numpy
  import torch
  import torch.nn
  from nemo.collections.asr.parts.preprocessing.perturb import AudioAugmentor
  from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new FilterbankFeaturesTA object from inherited base classes: nn with example: obj = FilterbankFeaturesTA(sample_rate, n_window_size, n_window_stride, normalize, nfilt, n_fft, preemph, lowfreq, highfreq, log, log_zero_guard_type, log_zero_guard_value, dither, window, pad_to, pad_value, mel_norm, use_grads, max_duration, frame_splicing, exact_pad, nb_augmentation_prob, nb_max_freq, mag_power, rng, stft_exact_pad, stft_conv)