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: Encode the given audiofile into a sequence of embeddings.
  
  Arguments
  ---------
  path : str
      Path to audio file which to encode.
  
  Returns
  -------
  torch.Tensor
      The audiofile embeddings produced by this system.
docstr_tok: ["Encode","the","given","audiofile","into","a","sequence","of","embeddings",".","Arguments","--","--","--","--","-","path",":","str","Path","to","audio","file","which","to","encode",".","Returns","--","--","--","-","torch.Tensor","The","audiofile","embeddings","produced","by","this","system","."]
code: def encode_file(self, path, **kwargs):
      """Encode the given audiofile into a sequence of embeddings.
  
      Arguments
      ---------
      path : str
          Path to audio file which to encode.
  
      Returns
      -------
      torch.Tensor
          The audiofile embeddings produced by this system.
      """
      waveform = self.load_audio(path, **kwargs)
      # Fake a batch:
      batch = waveform.unsqueeze(0)
      rel_length = torch.tensor([1.0])
      results = self.encode_batch(batch, rel_length)
      return results["embeddings"]
  
file_path: speechbrain/speechbrain/inference/encoders.py
imports: import torch
  from speechbrain.inference.interfaces import Pretrained
label_desc: Use image node_id 2 for calling the WaveformEncoder obj's underlying member method code with example usage: obj.encode_file(path) and returns: results