scene_renderer_cec1
Scene rendering for CEC1 challenge.
- class clarity.data.scene_renderer_cec1.Renderer(input_path, output_path, num_channels=1, sample_rate=44100, ramp_duration=0.5, tail_duration=0.2, pre_duration=2.0, post_duration=1.0, test_nbits=16)[source]
Bases:
object
SceneGenerator of CEC1 training and development sets. The render() function generates all simulated signals for each scene given the parameters specified in the metadata/scenes.train.json or metadata/scenes.dev.json file.
- apply_brir(signal, brir)[source]
Convolve a signal with a binaural room impulse response (BRIR).
- Parameters:
signal (ndarray) – The mono or stereo signal stored as array of floats
brir (ndarray) – The BRIR stored a 2xN array of floats
n_tail (int) – Truncate output to input signal length + n_tail
- Returns:
The convolved signals
- Return type:
ndarray
- apply_ramp(signal, ramp_duration)[source]
Apply half cosine ramp into and out of signal.
- Parameters:
signal (np.ndarray) – signal to be ramped.
ramp_duration (int) – ramp duration in seconds.
- Returns:
Signal ramped into and out of by cosine function.
- Return type:
np.ndarray
- compute_snr(target: ndarray, noise: ndarray, pre_samples=0, post_samples=-1)[source]
Return the Signal Noise Ratio (SNR).
Take the overlapping segment of the noise and get the speech-weighted better ear Signal Noise Ratio. (Note, SNR is a ratio – not in dB.)
- Parameters:
target (np.ndarray) – Target signal.
noise (np.ndarray) – Noise (should be same length as target)
- Returns:
signal_noise_ratio for better ear.
- Return type:
float
- render(target_id: str, noise_type: str, interferer_id: str, room: str, scene: str, offset, snr_dB: int, dataset, pre_samples=88200, post_samples=44100)[source]
- clarity.data.scene_renderer_cec1.check_scene_exists(scene: dict, output_path: str, num_channels: int) bool [source]
Checks correct dataset directory for full set of pre-existing files.
- Parameters:
scene (dict) – dictionary defining the scene to be generated.
output_path (str) – Path files should be saved to.
num_channels (int) – Number of channels
- Returns:
- boolean value indicating whether scene signals exist
or do not exist.
- Return type:
status