asteroid.dsp.consistency module¶
-
asteroid.dsp.consistency.
mixture_consistency
(mixture, est_sources, src_weights=None, dim=1)[source]¶ Applies mixture consistency to a tensor of estimated sources.
- Args
mixture (torch.Tensor): Mixture waveform or TF representation. est_sources (torch.Tensor): Estimated sources waveforms or TF
representations.- src_weights (torch.Tensor): Consistency weight for each source.
- Shape needs to be broadcastable to est_source. We make sure that the weights sum up to 1 along dim dim. If src_weights is None, compute them based on relative power.
dim (int): Axis which contains the sources in est_sources.
- Returns
- torch.Tensor with same shape as est_sources, after applying mixture consistency.
- Notes
- This method can be used only in ‘complete’ separation tasks, otherwise the residual error will contain unwanted sources. For example, this won’t work with the task sep_noisy from WHAM.
- Examples
>>> # Works on waveforms >>> mix = torch.randn(10, 16000) >>> est_sources = torch.randn(10, 2, 16000) >>> new_est_sources = mixture_consistency(mix, est_sources, dim=1) >>> # Also works on spectrograms >>> mix = torch.randn(10, 514, 400) >>> est_sources = torch.randn(10, 2, 514, 400) >>> new_est_sources = mixture_consistency(mix, est_sources, dim=1)
- References
- Scott Wisdom, John R Hershey, Kevin Wilson, Jeremy Thorpe, Michael Chinen, Brian Patton, and Rif A Saurous. “Differentiable consistency constraints for improved deep speech enhancement”, ICASSP 2019.