class_docstr: Constructs a Whisper feature extractor.
  
  This feature extractor inherits from [`~feature_extraction_sequence_utils.SequenceFeatureExtractor`] which contains
  most of the main methods. Users should refer to this superclass for more information regarding those methods.
  
  This class extracts mel-filter bank features from raw speech using a custom numpy implementation of the `Short Time
  Fourier Transform` which should match pytorch's `torch.stft` equivalent.
  
  Args:
      feature_size (`int`, defaults to 80):
          The feature dimension of the extracted features.
      sampling_rate (`int`, defaults to 16000):
          The sampling rate at which the audio files should be digitalized expressed in hertz (Hz).
      hop_length (`int`, defaults to 160):
          Length of the overlaping windows for the STFT used to obtain the Mel Frequency coefficients.
      chunk_length (`int`, defaults to 30):
          The maximum number of chuncks of `sampling_rate` samples used to trim and pad longer or shorter audio
          sequences.
      n_fft (`int`, defaults to 400):
          Size of the Fourier transform.
      padding_value (`float`, *optional*, defaults to 0.0):
          Padding value used to pad the audio. Should correspond to silences.
class_docstr_tok: ["Constructs","a","Whisper","feature","extractor",".","This","feature","extractor","inherits","from","[","`","~feature_extraction_sequence_utils.SequenceFeatureExtractor","`","]","which","contains","most","of","the","main","methods",".","Users","should","refer","to","this","superclass","for","more","information","regarding","those","methods",".","This","class","extracts","mel-filter","bank","features","from","raw","speech","using","a","custom","numpy","implementation","of","the","`","Short","Time","Fourier","Transform","`","which","should","match","pytorch","'s","`","torch.stft","`","equivalent",".","Args",":","feature_size","(","`","int","`",",","defaults","to","80",")",":","The","feature","dimension","of","the","extracted","features",".","sampling_rate","(","`","int","`",",","defaults","to","16000",")",":","The","sampling","rate","at","which","the","audio","files","should","be","digitalized","expressed","in","hertz","(","Hz",")",".","hop_length","(","`","int","`",",","defaults","to","160",")",":","Length","of","the","overlaping","windows","for","the","STFT","used","to","obtain","the","Mel","Frequency","coefficients",".","chunk_length","(","`","int","`",",","defaults","to","30",")",":","The","maximum","number","of","chuncks","of","`","sampling_rate","`","samples","used","to","trim","and","pad","longer","or","shorter","audio","sequences",".","n_fft","(","`","int","`",",","defaults","to","400",")",":","Size","of","the","Fourier","transform",".","padding_value","(","`","float","`",",","*","optional","*",",","defaults","to","0.0",")",":","Padding","value","used","to","pad","the","audio",".","Should","correspond","to","silences","."]
docstr: Main method to featurize and prepare for the model one or several sequence(s). Implementation uses PyTorch for
  the STFT computation if available, otherwise a slower NumPy based one.
  
  Args:
      raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
          The sequence or batch of sequences to be padded. Each sequence can be a numpy array, a list of float
          values, a list of numpy arrays or a list of list of float values. Must be mono channel audio, not
          stereo, i.e. single float per timestep.
      truncation (`bool`, *optional*, default to `True`):
          Activates truncation to cut input sequences longer than *max_length* to *max_length*.
      pad_to_multiple_of (`int`, *optional*, defaults to None):
          If set will pad the sequence to a multiple of the provided value.
  
          This is especially useful to enable the use of Tensor Cores on NVIDIA hardware with compute capability
          `>= 7.5` (Volta), or on TPUs which benefit from having sequence lengths be a multiple of 128.
      return_attention_mask (`bool`, *optional*):
          Whether to return the attention mask. If left to the default, will return the attention mask according
          to the specific feature_extractor's default.
  
          [What are attention masks?](../glossary#attention-mask)
  
          <Tip>
  
          For Whisper models, `attention_mask` should always be passed for batched inference, to avoid subtle
          bugs.
  
          </Tip>
  
      return_tensors (`str` or [`~utils.TensorType`], *optional*):
          If set, will return tensors instead of list of python integers. Acceptable values are:
  
          - `'tf'`: Return TensorFlow `tf.constant` objects.
          - `'pt'`: Return PyTorch `torch.Tensor` objects.
          - `'np'`: Return Numpy `np.ndarray` objects.
      sampling_rate (`int`, *optional*):
          The sampling rate at which the `raw_speech` input was sampled. It is strongly recommended to pass
          `sampling_rate` at the forward call to prevent silent errors and allow automatic speech recognition
          pipeline.
      padding_value (`float`, defaults to 0.0):
          The value that is used to fill the padding values / vectors.
      do_normalize (`bool`, *optional*, defaults to `False`):
          Whether or not to zero-mean unit-variance normalize the input. Normalizing can help to significantly
          improve the performance of the model.
docstr_tok: ["Main","method","to","featurize","and","prepare","for","the","model","one","or","several","sequence","(","s",")",".","Implementation","uses","PyTorch","for","the","STFT","computation","if","available",",","otherwise","a","slower","NumPy","based","one",".","Args",":","raw_speech","(","`","np.ndarray","`",",","`","List","[","float","]","`",",","`","List","[","np.ndarray","]","`",",","`","List","[","List","[","float","]","]","`",")",":","The","sequence","or","batch","of","sequences","to","be","padded",".","Each","sequence","can","be","a","numpy","array",",","a","list","of","float","values",",","a","list","of","numpy","arrays","or","a","list","of","list","of","float","values",".","Must","be","mono","channel","audio",",","not","stereo",",","i.e",".","single","float","per","timestep",".","truncation","(","`","bool","`",",","*","optional","*",",","default","to","`","True","`",")",":","Activates","truncation","to","cut","input","sequences","longer","than","*","max_length","*","to","*","max_length","*",".","pad_to_multiple_of","(","`","int","`",",","*","optional","*",",","defaults","to","None",")",":","If","set","will","pad","the","sequence","to","a","multiple","of","the","provided","value",".","This","is","especially","useful","to","enable","the","use","of","Tensor","Cores","on","NVIDIA","hardware","with","compute","capability","`",">","=","7.5","`","(","Volta",")",",","or","on","TPUs","which","benefit","from","having","sequence","lengths","be","a","multiple","of","128.","return_attention_mask","(","`","bool","`",",","*","optional","*",")",":","Whether","to","return","the","attention","mask",".","If","left","to","the","default",",","will","return","the","attention","mask","according","to","the","specific","feature_extractor","'s","default",".","[","What","are","attention","masks","?","]","(","..","\/glossary","#","attention-mask",")","<","Tip",">","For","Whisper","models",",","`","attention_mask","`","should","always","be","passed","for","batched","inference",",","to","avoid","subtle","bugs",".","<","\/Tip",">","return_tensors","(","`","str","`","or","[","`","~utils.TensorType","`","]",",","*","optional","*",")",":","If","set",",","will","return","tensors","instead","of","list","of","python","integers",".","Acceptable","values","are",":","-","`","'tf","'","`",":","Return","TensorFlow","`","tf.constant","`","objects",".","-","`","'pt","'","`",":","Return","PyTorch","`","torch.Tensor","`","objects",".","-","`","'np","'","`",":","Return","Numpy","`","np.ndarray","`","objects",".","sampling_rate","(","`","int","`",",","*","optional","*",")",":","The","sampling","rate","at","which","the","`","raw_speech","`","input","was","sampled",".","It","is","strongly","recommended","to","pass","`","sampling_rate","`","at","the","forward","call","to","prevent","silent","errors","and","allow","automatic","speech","recognition","pipeline",".","padding_value","(","`","float","`",",","defaults","to","0.0",")",":","The","value","that","is","used","to","fill","the","padding","values","\/","vectors",".","do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","zero-mean","unit-variance","normalize","the","input",".","Normalizing","can","help","to","significantly","improve","the","performance","of","the","model","."]
code: def __call__(
      self,
      raw_speech: Union[
          np.ndarray, List[float], List[np.ndarray], List[List[float]]
      ],
      truncation: bool = True,
      pad_to_multiple_of: Optional[int] = None,
      return_tensors: Optional[Union[str, TensorType]] = None,
      return_attention_mask: Optional[bool] = None,
      padding: Optional[str] = "max_length",
      max_length: Optional[int] = None,
      sampling_rate: Optional[int] = None,
      do_normalize: Optional[bool] = None,
      **kwargs,
  ) -> BatchFeature:
      """
      Main method to featurize and prepare for the model one or several sequence(s). Implementation uses PyTorch for
      the STFT computation if available, otherwise a slower NumPy based one.
  
      Args:
          raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
              The sequence or batch of sequences to be padded. Each sequence can be a numpy array, a list of float
              values, a list of numpy arrays or a list of list of float values. Must be mono channel audio, not
              stereo, i.e. single float per timestep.
          truncation (`bool`, *optional*, default to `True`):
              Activates truncation to cut input sequences longer than *max_length* to *max_length*.
          pad_to_multiple_of (`int`, *optional*, defaults to None):
              If set will pad the sequence to a multiple of the provided value.
  
              This is especially useful to enable the use of Tensor Cores on NVIDIA hardware with compute capability
              `>= 7.5` (Volta), or on TPUs which benefit from having sequence lengths be a multiple of 128.
          return_attention_mask (`bool`, *optional*):
              Whether to return the attention mask. If left to the default, will return the attention mask according
              to the specific feature_extractor's default.
  
              [What are attention masks?](../glossary#attention-mask)
  
              <Tip>
  
              For Whisper models, `attention_mask` should always be passed for batched inference, to avoid subtle
              bugs.
  
              </Tip>
  
          return_tensors (`str` or [`~utils.TensorType`], *optional*):
              If set, will return tensors instead of list of python integers. Acceptable values are:
  
              - `'tf'`: Return TensorFlow `tf.constant` objects.
              - `'pt'`: Return PyTorch `torch.Tensor` objects.
              - `'np'`: Return Numpy `np.ndarray` objects.
          sampling_rate (`int`, *optional*):
              The sampling rate at which the `raw_speech` input was sampled. It is strongly recommended to pass
              `sampling_rate` at the forward call to prevent silent errors and allow automatic speech recognition
              pipeline.
          padding_value (`float`, defaults to 0.0):
              The value that is used to fill the padding values / vectors.
          do_normalize (`bool`, *optional*, defaults to `False`):
              Whether or not to zero-mean unit-variance normalize the input. Normalizing can help to significantly
              improve the performance of the model.
      """
  
      if sampling_rate is not None:
          if sampling_rate != self.sampling_rate:
              raise ValueError(
                  f"The model corresponding to this feature extractor: {self.__class__.__name__} was trained using a"
                  f" sampling rate of {self.sampling_rate}. Please make sure that the provided `raw_speech` input"
                  f" was sampled with {self.sampling_rate} and not {sampling_rate}."
              )
      else:
          logger.warning(
              "It is strongly recommended to pass the `sampling_rate` argument to this function. "
              "Failing to do so can result in silent errors that might be hard to debug."
          )
  
      is_batched_numpy = (
          isinstance(raw_speech, np.ndarray)
          and len(raw_speech.shape) > 1
      )
      if is_batched_numpy and len(raw_speech.shape) > 2:
          raise ValueError(
              f"Only mono-channel audio is supported for input to {self}"
          )
      is_batched = is_batched_numpy or (
          isinstance(raw_speech, (list, tuple))
          and (isinstance(raw_speech[0], (np.ndarray, tuple, list)))
      )
  
      if is_batched:
          raw_speech = [
              np.asarray([speech], dtype=np.float32).T
              for speech in raw_speech
          ]
      elif not is_batched and not isinstance(raw_speech, np.ndarray):
          raw_speech = np.asarray(raw_speech, dtype=np.float32)
      elif isinstance(
          raw_speech, np.ndarray
      ) and raw_speech.dtype is np.dtype(np.float64):
          raw_speech = raw_speech.astype(np.float32)
  
      # always return batch
      if not is_batched:
          raw_speech = [np.asarray([raw_speech]).T]
  
      batched_speech = BatchFeature({"input_features": raw_speech})
  
      # convert into correct format for padding
  
      padded_inputs = self.pad(
          batched_speech,
          padding=padding,
          max_length=max_length if max_length else self.n_samples,
          truncation=truncation,
          pad_to_multiple_of=pad_to_multiple_of,
          return_attention_mask=return_attention_mask or do_normalize,
      )
  
      # zero-mean and unit-variance normalization
      if do_normalize:
          padded_inputs[
              "input_features"
          ] = self.zero_mean_unit_var_norm(
              padded_inputs["input_features"],
              attention_mask=padded_inputs["attention_mask"],
              padding_value=self.padding_value,
          )
          padded_inputs["input_features"] = np.stack(
              padded_inputs["input_features"], axis=0
          )
  
      # make sure list is in array format
      input_features = padded_inputs.get("input_features").transpose(
          2, 0, 1
      )
  
      extract_fbank_features = (
          self._torch_extract_fbank_features
          if is_torch_available()
          else self._np_extract_fbank_features
      )
      input_features = [
          extract_fbank_features(waveform)
          for waveform in input_features[0]
      ]
  
      if isinstance(input_features[0], List):
          padded_inputs["input_features"] = [
              np.asarray(feature, dtype=np.float32)
              for feature in input_features
          ]
      else:
          padded_inputs["input_features"] = input_features
  
      if return_attention_mask:
          # rescale from sample (48000) to feature (3000)
          padded_inputs["attention_mask"] = padded_inputs[
              "attention_mask"
          ][:, :: self.hop_length]
  
      if return_tensors is not None:
          padded_inputs = padded_inputs.convert_to_tensors(
              return_tensors
          )
  
      return padded_inputs
  
file_path: transformers/src/transformers/models/whisper/feature_extraction_whisper.py
imports: from typing import List, Optional, Union
  import numpy
  from ...None import is_torch_available
  from ...audio_utils import mel_filter_bank, spectrogram, window_function
  from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
  from ...feature_extraction_utils import BatchFeature
  from ...utils import TensorType, logging
label_desc: Use image node_id 5 for calling the WhisperFeatureExtractor obj's underlying member method code with example usage: obj.__call__(raw_speech, truncation, pad_to_multiple_of, return_tensors, return_attention_mask, padding, max_length, sampling_rate, do_normalize) and returns: padded_inputs