class_docstr: Transformer-based Speech Encoder from OpenAI's Whisper Model:
  
  URL: https://github.com/openai/whisper
class_docstr_tok: ["Transformer-based","Speech","Encoder","from","OpenAI","'s","Whisper","Model",":","URL",":","https",":","\/\/github.com\/openai\/whisper"]
code: def __init__(
      self,
      input_size: int = 1,
      dropout_rate: float = 0.0,
      whisper_model: str = "small",
      download_dir: str = None,
      use_specaug: bool = False,
      specaug_conf: Union[dict, None] = None,
      do_pad_trim: bool = False,
  ):
      try:
          import whisper
          from whisper.audio import HOP_LENGTH, N_FFT, N_MELS, N_SAMPLES
      except Exception as e:
          print("Error: whisper is not properly installed.")
          print(
              "Please install whisper with: cd ${MAIN_ROOT}/tools &&",
              "./installers/install_whisper.sh",
          )
          raise e
  
      assert check_argument_types()
      super().__init__()
  
      self.n_fft = N_FFT
      self.win_length = N_FFT
      self.hop_length = HOP_LENGTH
      self.n_mels = N_MELS
  
      self.mel_filters = whisper.audio.mel_filters
  
      # note that originally Whisper doesn't use dropouts
      self.dropout = torch.nn.Dropout(dropout_rate)
  
      assert whisper_model in whisper.available_models()
      _model = whisper.load_model(
          whisper_model, download_root=download_dir, device="cpu"
      )
      self.encoders = copy.deepcopy(_model.encoder)
      self.encoders.train()
  
      del _model
  
      if use_specaug:
          self.specaug = SpecAug(**specaug_conf)
      else:
          self.specaug = None
  
      self.do_pad_trim = do_pad_trim
      self.pad_samples = N_SAMPLES
  
file_path: espnet/espnet2/asr/encoder/whisper_encoder.py
imports: import copy
  from typing import Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.specaug.specaug import SpecAug
label_desc: Use image node_id 1 to create a new OpenAIWhisperEncoder object from inherited base classes: AbsEncoder with example: obj = OpenAIWhisperEncoder(input_size, dropout_rate, whisper_model, download_dir, use_specaug, specaug_conf, do_pad_trim)