asteroid.separate module¶
-
class
asteroid.separate.
Separatable
[source]¶ Bases:
asteroid.separate.Protocol
Things that are separatable.
-
forward_wav
(wav: <sphinx.ext.autodoc.importer._MockObject object at 0x7f85c9b53690>, **kwargs) → <sphinx.ext.autodoc.importer._MockObject object at 0x7f85c9b536d0>[source]¶ Parameters: - wav (torch.Tensor) – waveform tensor. Shape: 1D, 2D or 3D tensor, time last.
- **kwargs – Keyword arguments from separate.
Returns: torch.Tensor –
- the estimated sources.
Shape: [batch, n_src, time] or [n_src, time] if the input wav did not have a batch dim.
-
-
asteroid.separate.
separate
(model: asteroid.separate.Separatable, wav, output_dir=None, force_overwrite=False, resample=False, **kwargs)[source]¶ Infer separated sources from input waveforms. Also supports filenames.
Parameters: - model (Separatable, for example asteroid.models.BaseModel) – Model to use.
- wav (Union[torch.Tensor, numpy.ndarray, str]) – waveform array/tensor. Shape: 1D, 2D or 3D tensor, time last.
- output_dir (str) – path to save all the wav files. If None, estimated sources will be saved next to the original ones.
- force_overwrite (bool) – whether to overwrite existing files (when separating from file).
- resample (bool) – Whether to resample input files with wrong sample rate (when separating from file).
- **kwargs – keyword arguments to be passed to forward_wav.
Returns: - Union[torch.Tensor, numpy.ndarray, None], the estimated sources.
(batch, n_src, time) or (n_src, time) w/o batch dim.
Note
separate calls model.forward_wav which calls forward by default. For models whose forward doesn’t have waveform tensors as input/ouput, overwrite their forward_wav method to separate from waveform to waveform.
-
asteroid.separate.
torch_separate
(model: asteroid.separate.Separatable, wav: <sphinx.ext.autodoc.importer._MockObject object at 0x7f85c9b53810>, **kwargs) → <sphinx.ext.autodoc.importer._MockObject object at 0x7f85c9b56590>[source]¶ Core logic of separate.