class_docstr: A ready-to-use class for utterance-level classification (e.g, speaker-id,
  language-id, emotion recognition, keyword spotting, etc).
  
  The class assumes that an encoder called "embedding_model" and a model
  called "classifier" are defined in the yaml file. If you want to
  convert the predicted index into a corresponding text label, please
  provide the path of the label_encoder in a variable called 'lab_encoder_file'
  within the yaml.
  
  The class can be used either to run only the encoder (encode_batch()) to
  extract embeddings or to run a classification step (classify_batch()).
  ```
  
  Example
  -------
  >>> import torchaudio
  >>> from speechbrain.inference.classifiers import AudioClassifier
  >>> tmpdir = getfixture("tmpdir")
  >>> classifier = AudioClassifier.from_hparams(
  ...     source="speechbrain/cnn14-esc50",
  ...     savedir=tmpdir,
  ... )
  >>> signal = torch.randn(1, 16000)
  >>> prediction, _, _, text_lab = classifier.classify_batch(signal)
  >>> print(prediction.shape)
  torch.Size([1, 1, 50])
class_docstr_tok: ["A","ready-to-use","class","for","utterance-level","classification","(","e.g",",","speaker-id",",","language-id",",","emotion","recognition",",","keyword","spotting",",","etc",")",".","The","class","assumes","that","an","encoder","called","``","embedding_model","''","and","a","model","called","``","classifier","''","are","defined","in","the","yaml","file",".","If","you","want","to","convert","the","predicted","index","into","a","corresponding","text","label",",","please","provide","the","path","of","the","label_encoder","in","a","variable","called","'lab_encoder_file'","within","the","yaml",".","The","class","can","be","used","either","to","run","only","the","encoder","(","encode_batch","(",")",")","to","extract","embeddings","or","to","run","a","classification","step","(","classify_batch","(",")",")",".","``","`","Example","--","--","--","-",">",">",">","import","torchaudio",">",">",">","from","speechbrain.inference.classifiers","import","AudioClassifier",">",">",">","tmpdir","=","getfixture","(","``","tmpdir","''",")",">",">",">","classifier","=","AudioClassifier.from_hparams","(","...","source=","''","speechbrain\/cnn14-esc50","''",",","...","savedir=tmpdir",",","...",")",">",">",">","signal","=","torch.randn","(","1",",","16000",")",">",">",">","prediction",",","_",",","_",",","text_lab","=","classifier.classify_batch","(","signal",")",">",">",">","print","(","prediction.shape",")","torch.Size","(","[","1",",","1",",","50","]",")"]
docstr: Performs classification on the top of the encoded features.
  
  It returns the posterior probabilities, the index and, if the label
  encoder is specified it also the text label.
  
  Arguments
  ---------
  wavs : torch.Tensor
      Batch of waveforms [batch, time, channels] or [batch, time]
      depending on the model. Make sure the sample rate is fs=16000 Hz.
  wav_lens : torch.Tensor
      Lengths of the waveforms relative to the longest one in the
      batch, tensor of shape [batch]. The longest one should have
      relative length 1.0 and others len(waveform) / max_length.
      Used for ignoring padding.
  
  Returns
  -------
  out_prob
      The log posterior probabilities of each class ([batch, N_class])
  score:
      It is the value of the log-posterior for the best class ([batch,])
  index
      The indexes of the best class ([batch,])
  text_lab:
      List with the text labels corresponding to the indexes.
      (label encoder should be provided).
docstr_tok: ["Performs","classification","on","the","top","of","the","encoded","features",".","It","returns","the","posterior","probabilities",",","the","index","and",",","if","the","label","encoder","is","specified","it","also","the","text","label",".","Arguments","--","--","--","--","-","wavs",":","torch.Tensor","Batch","of","waveforms","[","batch",",","time",",","channels","]","or","[","batch",",","time","]","depending","on","the","model",".","Make","sure","the","sample","rate","is","fs=16000","Hz",".","wav_lens",":","torch.Tensor","Lengths","of","the","waveforms","relative","to","the","longest","one","in","the","batch",",","tensor","of","shape","[","batch","]",".","The","longest","one","should","have","relative","length","1.0","and","others","len","(","waveform",")","\/","max_length",".","Used","for","ignoring","padding",".","Returns","--","--","--","-","out_prob","The","log","posterior","probabilities","of","each","class","(","[","batch",",","N_class","]",")","score",":","It","is","the","value","of","the","log-posterior","for","the","best","class","(","[","batch",",","]",")","index","The","indexes","of","the","best","class","(","[","batch",",","]",")","text_lab",":","List","with","the","text","labels","corresponding","to","the","indexes",".","(","label","encoder","should","be","provided",")","."]
code: def classify_batch(self, wavs, wav_lens=None):
      """Performs classification on the top of the encoded features.
  
      It returns the posterior probabilities, the index and, if the label
      encoder is specified it also the text label.
  
      Arguments
      ---------
      wavs : torch.Tensor
          Batch of waveforms [batch, time, channels] or [batch, time]
          depending on the model. Make sure the sample rate is fs=16000 Hz.
      wav_lens : torch.Tensor
          Lengths of the waveforms relative to the longest one in the
          batch, tensor of shape [batch]. The longest one should have
          relative length 1.0 and others len(waveform) / max_length.
          Used for ignoring padding.
  
      Returns
      -------
      out_prob
          The log posterior probabilities of each class ([batch, N_class])
      score:
          It is the value of the log-posterior for the best class ([batch,])
      index
          The indexes of the best class ([batch,])
      text_lab:
          List with the text labels corresponding to the indexes.
          (label encoder should be provided).
      """
      wavs = wavs.to(self.device)
      X_stft = self.mods.compute_stft(wavs)
      X_stft_power = speechbrain.processing.features.spectral_magnitude(
          X_stft, power=self.hparams.spec_mag_power
      )
  
      if self.hparams.use_melspectra:
          net_input = self.mods.compute_fbank(X_stft_power)
      else:
          net_input = torch.log1p(X_stft_power)
  
      # Embeddings + sound classifier
      embeddings = self.mods.embedding_model(net_input)
      if embeddings.ndim == 4:
          embeddings = embeddings.mean((-1, -2))
  
      out_probs = self.mods.classifier(embeddings)
      score, index = torch.max(out_probs, dim=-1)
      text_lab = self.hparams.label_encoder.decode_torch(index)
      return out_probs, score, index, text_lab
  
file_path: speechbrain/speechbrain/inference/classifiers.py
imports: import torch
  import torchaudio
  import speechbrain
  from speechbrain.utils.fetching import fetch
  from speechbrain.utils.data_utils import split_path
  from speechbrain.inference.interfaces import Pretrained
label_desc: Use image node_id 2 for calling the AudioClassifier obj's underlying member method code with example usage: obj.classify_batch(wavs, wav_lens) and returns: out_probs,  score,  index,  text_lab