Loading ivas_processing_scripts/generation/generate_sba_items.py +13 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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") Loading ivas_processing_scripts/generation/generate_stereo_items.py +13 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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") Loading Loading
ivas_processing_scripts/generation/generate_sba_items.py +13 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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") Loading
ivas_processing_scripts/generation/generate_stereo_items.py +13 −4 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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") Loading