Commit 08118ad0 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

fix formatting

parent cf5cc8f3
Loading
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -380,14 +380,19 @@ def generate_sba_scene(
            logger.warning(
                f"Warning: Sample rate of the background noise is {background.fs} Hz and needs to be resampled to {cfg.fs}!"
            )
            resampled_audio = audioarray.resample(background.audio, background.fs, cfg.fs)
            resampled_audio = audioarray.resample(
                background.audio, background.fs, cfg.fs
            )
            background.audio = resampled_audio
            background.fs = cfg.fs

        # adjust the length of the background noise signal
        if len(background.audio) != len(y.audio):
            background.audio = audioarray.trim(
                background.audio, background.fs, limits=[0, len(background.audio) - len(y.audio)], samples=True
                background.audio,
                background.fs,
                limits=[0, len(background.audio) - len(y.audio)],
                samples=True,
            )

        # adjust the loudness of the background noise signal
@@ -409,11 +414,15 @@ def generate_sba_scene(
                "-- Warning: No target loudness for background noise specified, using default value of -26 LKFS"
            )
            scene["background_level"] = -26
        background.audio, _ = loudness_norm(background, scene['background_level'], loudness_format="STEREO")
        background.audio, _ = loudness_norm(
            background, scene["background_level"], loudness_format="STEREO"
        )

        # add the background noise to the output signal
        y.audio += background.audio
    elif "add_low_level_random_noise" in cfg.__dict__ and cfg.add_low_level_random_noise:
    elif (
        "add_low_level_random_noise" in cfg.__dict__ and cfg.add_low_level_random_noise
    ):
        # create uniformly distributed noise between -4 and 4
        np.random.seed(SEED_RANDOM_NOISE)
        noise = np.random.randint(low=-4, high=5, size=y.audio.shape).astype("float")
+13 −4
Original line number Diff line number Diff line
@@ -381,14 +381,19 @@ def generate_stereo_scene(
            logger.warning(
                f"Warning: Sample rate of the background noise is {background.fs} Hz and needs to be resampled to {cfg.fs}!"
            )
            resampled_audio = audioarray.resample(background.audio, background.fs, cfg.fs)
            resampled_audio = audioarray.resample(
                background.audio, background.fs, cfg.fs
            )
            background.audio = resampled_audio
            background.fs = cfg.fs

        # adjust the length of the background noise signal
        if len(background.audio) != len(y.audio):
            background.audio = audioarray.trim(
                background.audio, background.fs, limits=[0, len(background.audio) - len(y.audio)], samples=True
                background.audio,
                background.fs,
                limits=[0, len(background.audio) - len(y.audio)],
                samples=True,
            )

        # adjust the loudness of the background noise signal
@@ -410,11 +415,15 @@ def generate_stereo_scene(
                "-- Warning: No target loudness for background noise specified, using default value of -26 LKFS"
            )
            scene["background_level"] = -26
        background.audio, _ = loudness_norm(background, scene['background_level'], loudness_format="STEREO")
        background.audio, _ = loudness_norm(
            background, scene["background_level"], loudness_format="STEREO"
        )

        # add the background noise to the output signal
        y.audio += background.audio
    elif "add_low_level_random_noise" in cfg.__dict__ and cfg.add_low_level_random_noise:
    elif (
        "add_low_level_random_noise" in cfg.__dict__ and cfg.add_low_level_random_noise
    ):
        # create uniformly distributed noise between -4 and 4
        np.random.seed(SEED_RANDOM_NOISE)
        noise = np.random.randint(low=-4, high=5, size=y.audio.shape).astype("float")