Loading README.md +5 −2 Original line number Diff line number Diff line Loading @@ -239,10 +239,13 @@ input: # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB ### SNR for background noise in dB; REQUIRED for prerecorded background noise and ignored for low level noise # snr: 10 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) ### REQUIRED: Either background noise path or low level noise flag ### Path to background noise, must have same format and sampling rate as input signal(s); default = null # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true ``` </details> Loading examples/TEMPLATE.yml +5 −2 Original line number Diff line number Diff line Loading @@ -106,10 +106,13 @@ input: # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB ### SNR for background noise in dB; REQUIRED for prerecorded background noise and ignored for low level noise # snr: 10 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) ### REQUIRED: Either background noise path or low level noise flag ### Path to background noise, must have same format and sampling rate as input signal(s); default = null # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true ################################################# ### Bitstream processing Loading ivas_processing_scripts/audiotools/audioarray.py +9 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ def trim( limits: Optional[Tuple[int, int]] = None, pad_noise: Optional[bool] = False, samples: Optional[bool] = False, seed: Optional[int] = None, ) -> np.ndarray: """ Trim an audio array Loading Loading @@ -88,6 +89,9 @@ def trim( if pre_trim < 0: if pad_noise: # pad with uniformly distributed noise between -4 and 4 if seed: np.random.seed(seed) else: np.random.seed(SEED_PADDING) noise = np.random.randint( low=-4, high=5, size=(np.abs(pre_trim), np.shape(x)[1]) Loading @@ -101,6 +105,9 @@ def trim( if post_trim < 0: if pad_noise: # pad with uniformly distributed noise between -4 and 4 if seed: np.random.seed(seed) else: np.random.seed(SEED_PADDING) noise = np.random.randint( low=-4, high=5, size=(np.abs(post_trim), np.shape(x)[1]) Loading ivas_processing_scripts/processing/chains.py +4 −9 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ from ivas_processing_scripts.processing.ivas import IVAS from ivas_processing_scripts.processing.postprocessing import Postprocessing from ivas_processing_scripts.processing.preprocessing import Preprocessing from ivas_processing_scripts.processing.preprocessing_2 import Preprocessing2 from ivas_processing_scripts.utils import list_audio from ivas_processing_scripts.utils import get_abs_path, list_audio def init_processing_chains(cfg: TestConfig) -> None: Loading Loading @@ -133,6 +133,8 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: } pre2_cfg = cfg.preprocessing_2 # set up background noise background_cfg = pre2_cfg.get("background_noise", None) if background_cfg: background = { Loading @@ -140,6 +142,7 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: "background_noise_path": get_abs_path( background_cfg.get("background_noise_path", None) ), "low_level_noise": background_cfg.get("low_level_noise", False), "seed_delay": cfg.prerun_seed, "master_seed": cfg.master_seed, "output_fmt": cfg.postprocessing["fmt"], Loading Loading @@ -414,11 +417,3 @@ def get_processing_chain( ) return chain def get_abs_path(rel_path): if rel_path is not None: abs_path = Path(rel_path).resolve().absolute() else: abs_path = None return abs_path ivas_processing_scripts/processing/config.py +33 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ from ivas_processing_scripts.constants import ( REQUIRED_KEYS_MNRU, SUPPORTED_CONDITIONS, ) from ivas_processing_scripts.utils import get_abs_path def merge_dicts(base: dict, other: dict) -> None: Loading Loading @@ -139,12 +140,38 @@ class TestConfig: raise KeyError(f"The following key(s) must be specified : {MISSING_KEYS}") # validate preprocessing on concatenated file stage if (pre_proc_2 := getattr(cfg, "preprocessing_2", None)) is not None: bg_noise_folder = Path(pre_proc_2["background_noise_path"]).parent if ( bg_noise_folder.resolve().absolute() == cfg.input_path.resolve().absolute() if (pre_proc_2 := cfg.get("preprocessing_2", None)) is not None and ( bg_noise := pre_proc_2.get("background_noise", None) ) is not None: # check if low level flag or path is given if not bg_noise.get("background_noise_path", None) and not bg_noise.get( "low_level_noise", False ): raise ValueError( "Path to prerecorded noise or low level noise flag has to be provided for background noise" ) if bg_noise.get("background_noise_path", None) and bg_noise.get( "low_level_noise", False ): raise ValueError( "Only prerecorded or low level background noise possible, not both" ) # check if path of background noise exists or is in input folder if bg_noise.get("background_noise_path", None): # check snr if not bg_noise.get("snr", None): raise ValueError("SNR has to be specified for background noise") if not Path(bg_noise["background_noise_path"]).exists(): raise ValueError( f"Background noise path {bg_noise['background_noise_path']} does not exist" ) bg_noise_folder = Path(bg_noise["background_noise_path"]).parent if get_abs_path(bg_noise_folder) == get_abs_path(cfg["input_path"]): raise ValueError( "Background noise file has to be placed outside the input folder!" ) Loading Loading
README.md +5 −2 Original line number Diff line number Diff line Loading @@ -239,10 +239,13 @@ input: # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB ### SNR for background noise in dB; REQUIRED for prerecorded background noise and ignored for low level noise # snr: 10 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) ### REQUIRED: Either background noise path or low level noise flag ### Path to background noise, must have same format and sampling rate as input signal(s); default = null # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true ``` </details> Loading
examples/TEMPLATE.yml +5 −2 Original line number Diff line number Diff line Loading @@ -106,10 +106,13 @@ input: # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB ### SNR for background noise in dB; REQUIRED for prerecorded background noise and ignored for low level noise # snr: 10 ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s) ### REQUIRED: Either background noise path or low level noise flag ### Path to background noise, must have same format and sampling rate as input signal(s); default = null # background_noise_path: ".../noise.wav" ### Flag for using low level [-4,+4] background noise; default = false # low_level_noise: true ################################################# ### Bitstream processing Loading
ivas_processing_scripts/audiotools/audioarray.py +9 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ def trim( limits: Optional[Tuple[int, int]] = None, pad_noise: Optional[bool] = False, samples: Optional[bool] = False, seed: Optional[int] = None, ) -> np.ndarray: """ Trim an audio array Loading Loading @@ -88,6 +89,9 @@ def trim( if pre_trim < 0: if pad_noise: # pad with uniformly distributed noise between -4 and 4 if seed: np.random.seed(seed) else: np.random.seed(SEED_PADDING) noise = np.random.randint( low=-4, high=5, size=(np.abs(pre_trim), np.shape(x)[1]) Loading @@ -101,6 +105,9 @@ def trim( if post_trim < 0: if pad_noise: # pad with uniformly distributed noise between -4 and 4 if seed: np.random.seed(seed) else: np.random.seed(SEED_PADDING) noise = np.random.randint( low=-4, high=5, size=(np.abs(post_trim), np.shape(x)[1]) Loading
ivas_processing_scripts/processing/chains.py +4 −9 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ from ivas_processing_scripts.processing.ivas import IVAS from ivas_processing_scripts.processing.postprocessing import Postprocessing from ivas_processing_scripts.processing.preprocessing import Preprocessing from ivas_processing_scripts.processing.preprocessing_2 import Preprocessing2 from ivas_processing_scripts.utils import list_audio from ivas_processing_scripts.utils import get_abs_path, list_audio def init_processing_chains(cfg: TestConfig) -> None: Loading Loading @@ -133,6 +133,8 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: } pre2_cfg = cfg.preprocessing_2 # set up background noise background_cfg = pre2_cfg.get("background_noise", None) if background_cfg: background = { Loading @@ -140,6 +142,7 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: "background_noise_path": get_abs_path( background_cfg.get("background_noise_path", None) ), "low_level_noise": background_cfg.get("low_level_noise", False), "seed_delay": cfg.prerun_seed, "master_seed": cfg.master_seed, "output_fmt": cfg.postprocessing["fmt"], Loading Loading @@ -414,11 +417,3 @@ def get_processing_chain( ) return chain def get_abs_path(rel_path): if rel_path is not None: abs_path = Path(rel_path).resolve().absolute() else: abs_path = None return abs_path
ivas_processing_scripts/processing/config.py +33 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ from ivas_processing_scripts.constants import ( REQUIRED_KEYS_MNRU, SUPPORTED_CONDITIONS, ) from ivas_processing_scripts.utils import get_abs_path def merge_dicts(base: dict, other: dict) -> None: Loading Loading @@ -139,12 +140,38 @@ class TestConfig: raise KeyError(f"The following key(s) must be specified : {MISSING_KEYS}") # validate preprocessing on concatenated file stage if (pre_proc_2 := getattr(cfg, "preprocessing_2", None)) is not None: bg_noise_folder = Path(pre_proc_2["background_noise_path"]).parent if ( bg_noise_folder.resolve().absolute() == cfg.input_path.resolve().absolute() if (pre_proc_2 := cfg.get("preprocessing_2", None)) is not None and ( bg_noise := pre_proc_2.get("background_noise", None) ) is not None: # check if low level flag or path is given if not bg_noise.get("background_noise_path", None) and not bg_noise.get( "low_level_noise", False ): raise ValueError( "Path to prerecorded noise or low level noise flag has to be provided for background noise" ) if bg_noise.get("background_noise_path", None) and bg_noise.get( "low_level_noise", False ): raise ValueError( "Only prerecorded or low level background noise possible, not both" ) # check if path of background noise exists or is in input folder if bg_noise.get("background_noise_path", None): # check snr if not bg_noise.get("snr", None): raise ValueError("SNR has to be specified for background noise") if not Path(bg_noise["background_noise_path"]).exists(): raise ValueError( f"Background noise path {bg_noise['background_noise_path']} does not exist" ) bg_noise_folder = Path(bg_noise["background_noise_path"]).parent if get_abs_path(bg_noise_folder) == get_abs_path(cfg["input_path"]): raise ValueError( "Background noise file has to be placed outside the input folder!" ) Loading