recipes.cad2.task2.baseline package

Submodules

recipes.cad2.task2.baseline.enhance module

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

recipes.cad2.task2.baseline.evaluate module

Evaluate the enhanced signals using the HAAQI metric.

recipes.cad2.task2.baseline.evaluate.adjust_level(signal: ndarray, gains_scene: dict) ndarray[source]

Adjust the level of the signal to compensate the effect of amplifying the sources

recipes.cad2.task2.baseline.evaluate.apply_gains(stems: dict, sample_rate: float, gains: dict) dict[source]

Apply gain to the signal by using LUFS.

Parameters:
  • stems (dict) – Dictionary of stems.

  • sample_rate (float) – Sample rate of the signal.

  • gains (dict) – Dictionary of gains.

Returns:

Dictionary of stems with applied gains.

Return type:

dict

recipes.cad2.task2.baseline.evaluate.load_reference_stems(music_dir: str | Path, stems: dict) dict[Any, ndarray][source]

Load the reference stems for a given scene.

Parameters:
  • music_dir (str | Path) – Path to the music directory.

  • stems (dict) – Dictionary of stems

Returns:

Dictionary of reference stems.

Return type:

dict

recipes.cad2.task2.baseline.evaluate.make_scene_listener_list(scenes_listeners: dict, small_test: bool = False) list[source]

Make the list of scene-listener pairing to process

Parameters:
  • scenes_listeners (dict) – Dictionary of scenes and listeners.

  • small_test (bool) – Whether to use a small test set.

Returns:

List of scene-listener pairings.

Return type:

list

recipes.cad2.task2.baseline.evaluate.remix_stems(stems: dict) ndarray[source]

Remix the stems into a stereo signal.

The remixing is done by summing the stems.

Parameters:

stems (dict) – Dictionary of stems.

Returns:

Stereo signal.

Return type:

ndarray

recipes.cad2.task2.baseline.evaluate.run_calculate_aq(config: DictConfig) None[source]

Evaluate the enhanced signals using the HAAQI metric.

recipes.cad2.task2.baseline.evaluate.set_song_seed(song: str) None[source]

Set a seed that is unique for the given song

recipes.cad2.task2.baseline.merge_batches_results module

Join batches scores into a single file.

recipes.cad2.task2.baseline.merge_batches_results.join_batches(config: DictConfig) None[source]

Join batches scores into a single file.

Parameters:

config (DictConfig) – Dictionary of configuration options. The .evaluate.batch_size is extracted to determine how many batches there are to combine.

Module contents