enhance
Run the dummy enhancement.
- recipes.cad2.task2.baseline.enhance.check_repeated_source(gains: dict, source_list: dict) dict [source]
Check if mixture has 2 voices of the same instrument. Apply average gain to both voices.
- Parameters:
gains (dict) – Dictionary of original gains.
source_list (dict) – Dictionary of sources in mixture.
- Returns:
Dictionary of modified gains.
- Return type:
dict
- recipes.cad2.task2.baseline.enhance.decompose_signal(model: dict[str, ConvTasNetStereo], signal: ndarray, signal_sample_rate: int, device: device, sources_list: dict, listener: Listener, add_residual: float = 0.0) dict[str, ndarray] [source]
Decompose the signal into the estimated sources.
- The listener is ignored by the baseline system as it
is not performing personalised decomposition.
- Parameters:
model (dict) – Dictionary of separation models.
model_sample_rate (int) – Sample rate of the separation model.
signal (ndarray) – Signal to decompose.
signal_sample_rate (int) – Sample rate of the signal.
device (torch.device) – Device to use for separation.
sources_list (dict) – List of sources to separate.
listener (Listener) – Listener audiogram.
add_residual (float) – Add residual to the target estimated sources from the accompaniment.
- Returns:
Dictionary of estimated sources.
- Return type:
dict
- recipes.cad2.task2.baseline.enhance.enhance(config: DictConfig) None [source]
Run the music enhancement. The system decomposes the music into the estimated sources. Next, applies the target gain per source. Then, remixes the sources to create the enhanced signal. Finally, the enhanced signal is amplified for the listener.
- Parameters:
config (dict) – Dictionary of configuration options for enhancing music.
- recipes.cad2.task2.baseline.enhance.load_separation_model(causality: str, device: device, force_redownload: bool = True) dict[str, ConvTasNetStereo] [source]
Load the separation model. :param causality: Causality of the model (causal or noncausal). :type causality: str :param device: Device to load the model. :type device: torch.device :param force_redownload: Whether to force redownload the model. :type force_redownload: bool
- Returns:
Separation model.
- Return type:
model
- recipes.cad2.task2.baseline.enhance.process_remix_for_listener(signal: ndarray, enhancer: MultibandCompressor, enhancer_params: dict, listener) ndarray [source]
Process the stems from sources.
Args:
- Returns:
Processed signal.
- Return type:
ndarray
- recipes.cad2.task2.baseline.enhance.separate_sources(model: Module, mix: Tensor | ndarray, sample_rate: int, segment: float = 10.0, overlap: float = 0.1, number_sources: int = 4, device: device | str | None = None)[source]
Apply model to a given mixture. Use fade, and add segments together in order to add model segment by segment.
- Parameters:
model (torch.nn.Module) – model to use for separation
mix (torch.Tensor) – mixture to separate, shape (batch, channels, time)
sample_rate (int) – sampling rate of the mixture
segment (float) – segment length in seconds
overlap (float) – overlap between segments, between 0 and 1
number_sources (int) – number of sources to separate
device (torch.device, str, or None) – if provided, device on which to execute the computation, otherwise mix.device is assumed. When device is different from mix.device, only local computations will be on device, while the entire tracks will be stored on mix.device.
- Returns:
estimated sources
- Return type:
torch.Tensor
Based on https://pytorch.org/audio/main/tutorials/hybrid_demucs_tutorial.html