class_docstr: A ready-to-use waveformEncoder model
  
  It can be used to wrap different embedding models such as SSL ones (wav2vec2)
  or speaker ones (Xvector) etc. Two functions are available: encode_batch and
  encode_file. They can be used to obtain the embeddings directly from an audio
  file or from a batch of audio tensors respectively.
  
  The given YAML must contain the fields specified in the *_NEEDED[] lists.
  
  Example
  -------
  >>> from speechbrain.inference.encoders import WaveformEncoder
  >>> tmpdir = getfixture("tmpdir")
  >>> ssl_model = WaveformEncoder.from_hparams(
  ...     source="speechbrain/ssl-wav2vec2-base-libri",
  ...     savedir=tmpdir,
  ... ) # doctest: +SKIP
  >>> ssl_model.encode_file("samples/audio_samples/example_fr.wav") # doctest: +SKIP
class_docstr_tok: ["A","ready-to-use","waveformEncoder","model","It","can","be","used","to","wrap","different","embedding","models","such","as","SSL","ones","(","wav2vec2",")","or","speaker","ones","(","Xvector",")","etc",".","Two","functions","are","available",":","encode_batch","and","encode_file",".","They","can","be","used","to","obtain","the","embeddings","directly","from","an","audio","file","or","from","a","batch","of","audio","tensors","respectively",".","The","given","YAML","must","contain","the","fields","specified","in","the","*","_NEEDED","[","]","lists",".","Example","--","--","--","-",">",">",">","from","speechbrain.inference.encoders","import","WaveformEncoder",">",">",">","tmpdir","=","getfixture","(","``","tmpdir","''",")",">",">",">","ssl_model","=","WaveformEncoder.from_hparams","(","...","source=","''","speechbrain\/ssl-wav2vec2-base-libri","''",",","...","savedir=tmpdir",",","...",")","#","doctest",":","+SKIP",">",">",">","ssl_model.encode_file","(","``","samples\/audio_samples\/example_fr.wav","''",")","#","doctest",":","+SKIP"]
docstr: Encodes the input audio into a sequence of hidden states
  
  The waveforms should already be in the model's desired format.
  
  Arguments
  ---------
  wavs : torch.Tensor
      Batch of waveforms [batch, time, channels] or [batch, time]
      depending on the model.
  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
  -------
  torch.Tensor
      The encoded batch
docstr_tok: ["Encodes","the","input","audio","into","a","sequence","of","hidden","states","The","waveforms","should","already","be","in","the","model","'s","desired","format",".","Arguments","--","--","--","--","-","wavs",":","torch.Tensor","Batch","of","waveforms","[","batch",",","time",",","channels","]","or","[","batch",",","time","]","depending","on","the","model",".","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","--","--","--","-","torch.Tensor","The","encoded","batch"]
code: def encode_batch(self, wavs, wav_lens):
      """Encodes the input audio into a sequence of hidden states
  
      The waveforms should already be in the model's desired format.
  
      Arguments
      ---------
      wavs : torch.Tensor
          Batch of waveforms [batch, time, channels] or [batch, time]
          depending on the model.
      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
      -------
      torch.Tensor
          The encoded batch
      """
      wavs = wavs.float()
      wavs, wav_lens = wavs.to(self.device), wav_lens.to(self.device)
      encoder_out = self.mods.encoder(wavs, wav_lens)
      return encoder_out
  
file_path: speechbrain/speechbrain/inference/encoders.py
imports: import torch
  from speechbrain.inference.interfaces import Pretrained
label_desc: Use image node_id 3 for calling the WaveformEncoder obj's underlying member method code with example usage: obj.encode_batch(wavs, wav_lens) and returns: encoder_out