class_docstr: A "ready-to-use" speech separation model.
  
  Uses Sepformer architecture.
  
  Example
  -------
  >>> tmpdir = getfixture("tmpdir")
  >>> model = SepformerSeparation.from_hparams(
  ...     source="speechbrain/sepformer-wsj02mix",
  ...     savedir=tmpdir)
  >>> mix = torch.randn(1, 400)
  >>> est_sources = model.separate_batch(mix)
  >>> print(est_sources.shape)
  torch.Size([1, 400, 2])
class_docstr_tok: ["A","``","ready-to-use","''","speech","separation","model",".","Uses","Sepformer","architecture",".","Example","--","--","--","-",">",">",">","tmpdir","=","getfixture","(","``","tmpdir","''",")",">",">",">","model","=","SepformerSeparation.from_hparams","(","...","source=","''","speechbrain\/sepformer-wsj02mix","''",",","...","savedir=tmpdir",")",">",">",">","mix","=","torch.randn","(","1",",","400",")",">",">",">","est_sources","=","model.separate_batch","(","mix",")",">",">",">","print","(","est_sources.shape",")","torch.Size","(","[","1",",","400",",","2","]",")"]
docstr: Separate sources from file.
  
  Arguments
  ---------
  path : str
      Path to file which has a mixture of sources. It can be a local
      path, a web url, or a huggingface repo.
  savedir : path
      Path where to store the wav signals (when downloaded from the web).
  Returns
  -------
  tensor
      Separated sources
docstr_tok: ["Separate","sources","from","file",".","Arguments","--","--","--","--","-","path",":","str","Path","to","file","which","has","a","mixture","of","sources",".","It","can","be","a","local","path",",","a","web","url",",","or","a","huggingface","repo",".","savedir",":","path","Path","where","to","store","the","wav","signals","(","when","downloaded","from","the","web",")",".","Returns","--","--","--","-","tensor","Separated","sources"]
code: def separate_file(self, path, savedir="audio_cache"):
      """Separate sources from file.
  
      Arguments
      ---------
      path : str
          Path to file which has a mixture of sources. It can be a local
          path, a web url, or a huggingface repo.
      savedir : path
          Path where to store the wav signals (when downloaded from the web).
      Returns
      -------
      tensor
          Separated sources
      """
      source, fl = split_path(path)
      path = fetch(fl, source=source, savedir=savedir)
  
      batch, fs_file = torchaudio.load(path)
      batch = batch.to(self.device)
      fs_model = self.hparams.sample_rate
  
      # resample the data if needed
      if fs_file != fs_model:
          print(
              "Resampling the audio from {} Hz to {} Hz".format(
                  fs_file, fs_model
              )
          )
          tf = torchaudio.transforms.Resample(
              orig_freq=fs_file, new_freq=fs_model
          ).to(self.device)
          batch = batch.mean(dim=0, keepdim=True)
          batch = tf(batch)
  
      est_sources = self.separate_batch(batch)
      est_sources = (
          est_sources / est_sources.abs().max(dim=1, keepdim=True)[0]
      )
      return est_sources
  
file_path: speechbrain/speechbrain/inference/separation.py
imports: import torch
  import torchaudio
  import torch.nn.functional
  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 SepformerSeparation obj's underlying member method code with example usage: obj.separate_file(path, savedir) and returns: est_sources