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 EncoderClassifier
  >>> # Model is downloaded from the speechbrain HuggingFace repo
  >>> tmpdir = getfixture("tmpdir")
  >>> classifier = EncoderClassifier.from_hparams(
  ...     source="speechbrain/spkrec-ecapa-voxceleb",
  ...     savedir=tmpdir,
  ... )
  >>> classifier.hparams.label_encoder.ignore_len()
  
  >>> # Compute embeddings
  >>> signal, fs = torchaudio.load("tests/samples/single-mic/example1.wav")
  >>> embeddings = classifier.encode_batch(signal)
  
  >>> # Classification
  >>> prediction = classifier.classify_batch(signal)
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","EncoderClassifier",">",">",">","#","Model","is","downloaded","from","the","speechbrain","HuggingFace","repo",">",">",">","tmpdir","=","getfixture","(","``","tmpdir","''",")",">",">",">","classifier","=","EncoderClassifier.from_hparams","(","...","source=","''","speechbrain\/spkrec-ecapa-voxceleb","''",",","...","savedir=tmpdir",",","...",")",">",">",">","classifier.hparams.label_encoder.ignore_len","(",")",">",">",">","#","Compute","embeddings",">",">",">","signal",",","fs","=","torchaudio.load","(","``","tests\/samples\/single-mic\/example1.wav","''",")",">",">",">","embeddings","=","classifier.encode_batch","(","signal",")",">",">",">","#","Classification",">",">",">","prediction","=","classifier.classify_batch","(","signal",")"]
docstr: Encodes the input audio into a single vector embedding.
  
  The waveforms should already be in the model's desired format.
  You can call:
  ``normalized = <this>.normalizer(signal, sample_rate)``
  to get a correctly converted signal in most cases.
  
  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.
  normalize : bool
      If True, it normalizes the embeddings with the statistics
      contained in mean_var_norm_emb.
  
  Returns
  -------
  torch.Tensor
      The encoded batch
docstr_tok: ["Encodes","the","input","audio","into","a","single","vector","embedding",".","The","waveforms","should","already","be","in","the","model","'s","desired","format",".","You","can","call",":","``","normalized","=","<","this",">",".normalizer","(","signal",",","sample_rate",")","``","to","get","a","correctly","converted","signal","in","most","cases",".","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",".","normalize",":","bool","If","True",",","it","normalizes","the","embeddings","with","the","statistics","contained","in","mean_var_norm_emb",".","Returns","--","--","--","-","torch.Tensor","The","encoded","batch"]
code: def encode_batch(self, wavs, wav_lens=None, normalize=False):
      """Encodes the input audio into a single vector embedding.
  
      The waveforms should already be in the model's desired format.
      You can call:
      ``normalized = <this>.normalizer(signal, sample_rate)``
      to get a correctly converted signal in most cases.
  
      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.
      normalize : bool
          If True, it normalizes the embeddings with the statistics
          contained in mean_var_norm_emb.
  
      Returns
      -------
      torch.Tensor
          The encoded batch
      """
      # Manage single waveforms in input
      if len(wavs.shape) == 1:
          wavs = wavs.unsqueeze(0)
  
      # Assign full length if wav_lens is not assigned
      if wav_lens is None:
          wav_lens = torch.ones(wavs.shape[0], device=self.device)
  
      # Storing waveform in the specified device
      wavs, wav_lens = wavs.to(self.device), wav_lens.to(self.device)
      wavs = wavs.float()
  
      # Computing features and embeddings
      feats = self.mods.compute_features(wavs)
      feats = self.mods.mean_var_norm(feats, wav_lens)
      embeddings = self.mods.embedding_model(feats, wav_lens)
      if normalize:
          embeddings = self.hparams.mean_var_norm_emb(
              embeddings,
              torch.ones(embeddings.shape[0], device=self.device),
          )
      return embeddings
  
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 EncoderClassifier obj's underlying member method code with example usage: obj.encode_batch(wavs, wav_lens, normalize) and returns: embeddings