Loading ivas_processing_scripts/__init__.py +9 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ from ivas_processing_scripts.processing.processing import ( concat_setup, concat_teardown, preprocess, preprocess_2, process_item, reorder_items_list, ) Loading Loading @@ -95,8 +96,10 @@ def main(args): logger = logging_init(args, cfg) # Re-ordering items based on concatenation order if cfg.concatenate_input and cfg.concatenation_order is not None: cfg.items_list = reorder_items_list(cfg.items_list, cfg.concatenation_order) if hasattr(cfg, "preprocessing_2"): if cfg.preprocessing_2["concatenate_input"] and cfg.preprocessing_2.get("concatenation_order", None) is not None: cfg.items_list = reorder_items_list(cfg.items_list, cfg.preprocessing_2["concatenation_order"]) # check for ISM metadata if cfg.input["fmt"].startswith("ISM"): metadata = check_ISM_metadata( Loading @@ -121,16 +124,13 @@ def main(args): # run preprocessing only once if hasattr(cfg, "preprocessing"): preprocess(cfg, cfg.metadata_path, logger) preprocess(cfg, logger) # preprocessing on whole signal(s) if hasattr(cfg, "preprocessing_2"): # TODO: call function for concatenation, preamble and background noise pass if cfg.concatenate_input: # concatenate items if required concat_setup(cfg, logger) preprocess_2(cfg, logger) # run conditions for condition, out_dir, tmp_dir in zip( cfg.proc_chains, cfg.out_dirs, cfg.tmp_dirs ): Loading ivas_processing_scripts/processing/chains.py +59 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ from ivas_processing_scripts.processing.evs import EVS 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 Loading @@ -46,6 +47,9 @@ def init_processing_chains(cfg: TestConfig) -> None: if hasattr(cfg, "preprocessing"): cfg.proc_chains.append(get_preprocessing(cfg)) if hasattr(cfg, "preprocessing_2"): cfg.proc_chains.append(get_preprocessing_2(cfg)) # other processing chains for cond_name, cond_cfg in cfg.conditions_to_generate.items(): bitrates = cond_cfg.get("bitrates") Loading Loading @@ -119,6 +123,49 @@ def get_preprocessing(cfg: TestConfig) -> dict: return chain def get_preprocessing_2(cfg: TestConfig) -> dict: """Mapping from test configuration to preprocessing 2 keyword arguments""" chain = { "name": "preprocessing_2", "processes": [], } pre2_cfg = cfg.preprocessing_2 background_cfg = pre2_cfg.get("background_noise", None) if background_cfg: background = { "snr": background_cfg.get("snr", None), "background_noise_path": background_cfg.get("background_noise_path", None), "seed_delay": background_cfg.get("seed_delay", 0), "output_fmt": cfg.postprocessing["fmt"], } else: background = None # default to input values if preprocessing was not requested pre_cfg = getattr(cfg, "preprocessing", {}) tmp_in_fs = pre_cfg.get("fs", cfg.input.get("fs")) tmp_in_fmt = pre_cfg.get("fmt", cfg.input["fmt"]) chain["processes"].append( Preprocessing2( { "in_fs": tmp_in_fs, "in_fmt": tmp_in_fmt, "concatenate_input": pre2_cfg.get("concatenate_input", False), "concatenation_order": pre2_cfg.get("concatenation_order", None), "preamble": pre2_cfg.get("preamble", 0), "pad_noise_preamble": pre2_cfg.get("pad_noise_preamble", False), "background_noise": background, "in_hp50": pre2_cfg.get("hp50", False), "multiprocessing": cfg.multiprocessing, } ) ) return chain def get_processing_chain( condition: str, cfg: TestConfig, bitrate: Optional[int] = None ) -> dict: Loading Loading @@ -215,6 +262,11 @@ def get_processing_chain( else: tx_cfg = None if hasattr(cfg, "preprocessing_2"): # TODO: not nice preamble = cfg.preprocessing_2.get("preamble", 0) else: preamble = 0 chain["processes"].append( EVS( { Loading @@ -228,7 +280,7 @@ def get_processing_chain( "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": cfg.preamble, "preamble": preamble, } ) ) Loading Loading @@ -265,6 +317,11 @@ def get_processing_chain( else: tx_cfg = None if hasattr(cfg, "preprocessing_2"): # TODO: not nice preamble = cfg.preprocessing_2.get("preamble", 0) else: preamble = 0 chain["processes"].append( IVAS( { Loading @@ -279,7 +336,7 @@ def get_processing_chain( "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": cfg.preamble, "preamble": preamble, } ) ) Loading ivas_processing_scripts/processing/preprocessing_2.py 0 → 100644 +52 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository. All Rights Reserved. # # This software is protected by copyright law and by international treaties. # The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository retain full ownership rights in their respective contributions in # the software. This notice grants no license of any kind, including but not limited to patent # license, nor is any license granted by implication, estoppel or otherwise. # # Contributors are required to enter into the IVAS codec Public Collaboration agreement before making # contributions. # # This software is provided "AS IS", without any express or implied warranties. The software is in the # development stage. It is intended exclusively for experts who have experience with such software and # solely for the purpose of inspection. All implied warranties of non-infringement, merchantability # and fitness for a particular purpose are hereby disclaimed and excluded. # # Any dispute, controversy or claim arising under or in relation to providing this software shall be # submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. # import logging from pathlib import Path from ivas_processing_scripts.processing.processing import Processing class Preprocessing2(Processing): # TODO def __init__(self, attrs: dict): super().__init__(attrs) self.name = "pre_2" def process(self, in_file: Path, out_file: Path, in_meta, logger: logging.Logger): logger.debug(f"Preprocessing2 configuration : {self.__dict__}") logger.debug(f"Preprocessing2 {in_file.absolute()} -> {out_file.absolute()}") # add preamble # TODO # add background noise # TODO ivas_processing_scripts/processing/processing.py +46 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ from itertools import repeat from pathlib import Path from shutil import copyfile from typing import Iterable, Union from warnings import warn from ivas_processing_scripts.audiotools.audiofile import concat, split from ivas_processing_scripts.audiotools.metadata import ( Loading Loading @@ -176,7 +177,7 @@ def concat_teardown(cfg: TestConfig, logger: logging.Logger): return out_files, out_meta def preprocess(cfg, in_meta, logger): def preprocess(cfg, logger): preprocessing = cfg.proc_chains[0] chain = preprocessing["processes"] Loading @@ -191,7 +192,7 @@ def preprocess(cfg, in_meta, logger): repeat(cfg.out_dirs[0]), repeat(chain), repeat(logger), in_meta, cfg.metadata_path, ), None, "mp" if cfg.multiprocessing else None, Loading @@ -214,6 +215,49 @@ def preprocess(cfg, in_meta, logger): cfg.out_dirs = cfg.out_dirs[1:] def preprocess_2(cfg, logger): preprocessing_2 = cfg.proc_chains[0] chain = preprocessing_2["processes"] logger.info(f" Generating condition: {preprocessing_2['name']}") # concatenate items if required concat_setup(cfg, logger) # run preprocessing 2 apply_func_parallel( process_item, zip( cfg.items_list, repeat(cfg.tmp_dirs[0]), repeat(cfg.out_dirs[0]), repeat(chain), repeat(logger), cfg.metadata_path, ), None, "mp" if cfg.multiprocessing else None, ) # update the configuration to use preprocessing 2 outputs as new inputs cfg.items_list = list_audio( # TODO: add preprocessing_2 to list of audio cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None) ) if cfg.metadata_path[0] is not None: for item_idx in range(len(cfg.metadata_path)): for obj_idx in range(len(cfg.metadata_path[item_idx])): if cfg.metadata_path[item_idx][obj_idx]: cfg.metadata_path[item_idx][obj_idx] = cfg.out_dirs[0] / Path( f"{cfg.items_list[item_idx].stem}.wav.{obj_idx}.csv" ) # remove already applied processing stage cfg.proc_chains = cfg.proc_chains[1:] cfg.tmp_dirs = cfg.tmp_dirs[1:] cfg.out_dirs = cfg.out_dirs[1:] return def process_item( in_file: Union[Path, str], tmp_dir: Union[Path, str], Loading Loading
ivas_processing_scripts/__init__.py +9 −9 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ from ivas_processing_scripts.processing.processing import ( concat_setup, concat_teardown, preprocess, preprocess_2, process_item, reorder_items_list, ) Loading Loading @@ -95,8 +96,10 @@ def main(args): logger = logging_init(args, cfg) # Re-ordering items based on concatenation order if cfg.concatenate_input and cfg.concatenation_order is not None: cfg.items_list = reorder_items_list(cfg.items_list, cfg.concatenation_order) if hasattr(cfg, "preprocessing_2"): if cfg.preprocessing_2["concatenate_input"] and cfg.preprocessing_2.get("concatenation_order", None) is not None: cfg.items_list = reorder_items_list(cfg.items_list, cfg.preprocessing_2["concatenation_order"]) # check for ISM metadata if cfg.input["fmt"].startswith("ISM"): metadata = check_ISM_metadata( Loading @@ -121,16 +124,13 @@ def main(args): # run preprocessing only once if hasattr(cfg, "preprocessing"): preprocess(cfg, cfg.metadata_path, logger) preprocess(cfg, logger) # preprocessing on whole signal(s) if hasattr(cfg, "preprocessing_2"): # TODO: call function for concatenation, preamble and background noise pass if cfg.concatenate_input: # concatenate items if required concat_setup(cfg, logger) preprocess_2(cfg, logger) # run conditions for condition, out_dir, tmp_dir in zip( cfg.proc_chains, cfg.out_dirs, cfg.tmp_dirs ): Loading
ivas_processing_scripts/processing/chains.py +59 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ from ivas_processing_scripts.processing.evs import EVS 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 Loading @@ -46,6 +47,9 @@ def init_processing_chains(cfg: TestConfig) -> None: if hasattr(cfg, "preprocessing"): cfg.proc_chains.append(get_preprocessing(cfg)) if hasattr(cfg, "preprocessing_2"): cfg.proc_chains.append(get_preprocessing_2(cfg)) # other processing chains for cond_name, cond_cfg in cfg.conditions_to_generate.items(): bitrates = cond_cfg.get("bitrates") Loading Loading @@ -119,6 +123,49 @@ def get_preprocessing(cfg: TestConfig) -> dict: return chain def get_preprocessing_2(cfg: TestConfig) -> dict: """Mapping from test configuration to preprocessing 2 keyword arguments""" chain = { "name": "preprocessing_2", "processes": [], } pre2_cfg = cfg.preprocessing_2 background_cfg = pre2_cfg.get("background_noise", None) if background_cfg: background = { "snr": background_cfg.get("snr", None), "background_noise_path": background_cfg.get("background_noise_path", None), "seed_delay": background_cfg.get("seed_delay", 0), "output_fmt": cfg.postprocessing["fmt"], } else: background = None # default to input values if preprocessing was not requested pre_cfg = getattr(cfg, "preprocessing", {}) tmp_in_fs = pre_cfg.get("fs", cfg.input.get("fs")) tmp_in_fmt = pre_cfg.get("fmt", cfg.input["fmt"]) chain["processes"].append( Preprocessing2( { "in_fs": tmp_in_fs, "in_fmt": tmp_in_fmt, "concatenate_input": pre2_cfg.get("concatenate_input", False), "concatenation_order": pre2_cfg.get("concatenation_order", None), "preamble": pre2_cfg.get("preamble", 0), "pad_noise_preamble": pre2_cfg.get("pad_noise_preamble", False), "background_noise": background, "in_hp50": pre2_cfg.get("hp50", False), "multiprocessing": cfg.multiprocessing, } ) ) return chain def get_processing_chain( condition: str, cfg: TestConfig, bitrate: Optional[int] = None ) -> dict: Loading Loading @@ -215,6 +262,11 @@ def get_processing_chain( else: tx_cfg = None if hasattr(cfg, "preprocessing_2"): # TODO: not nice preamble = cfg.preprocessing_2.get("preamble", 0) else: preamble = 0 chain["processes"].append( EVS( { Loading @@ -228,7 +280,7 @@ def get_processing_chain( "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": cfg.preamble, "preamble": preamble, } ) ) Loading Loading @@ -265,6 +317,11 @@ def get_processing_chain( else: tx_cfg = None if hasattr(cfg, "preprocessing_2"): # TODO: not nice preamble = cfg.preprocessing_2.get("preamble", 0) else: preamble = 0 chain["processes"].append( IVAS( { Loading @@ -279,7 +336,7 @@ def get_processing_chain( "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": cfg.preamble, "preamble": preamble, } ) ) Loading
ivas_processing_scripts/processing/preprocessing_2.py 0 → 100644 +52 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository. All Rights Reserved. # # This software is protected by copyright law and by international treaties. # The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, # Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., # Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, # Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other # contributors to this repository retain full ownership rights in their respective contributions in # the software. This notice grants no license of any kind, including but not limited to patent # license, nor is any license granted by implication, estoppel or otherwise. # # Contributors are required to enter into the IVAS codec Public Collaboration agreement before making # contributions. # # This software is provided "AS IS", without any express or implied warranties. The software is in the # development stage. It is intended exclusively for experts who have experience with such software and # solely for the purpose of inspection. All implied warranties of non-infringement, merchantability # and fitness for a particular purpose are hereby disclaimed and excluded. # # Any dispute, controversy or claim arising under or in relation to providing this software shall be # submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. # import logging from pathlib import Path from ivas_processing_scripts.processing.processing import Processing class Preprocessing2(Processing): # TODO def __init__(self, attrs: dict): super().__init__(attrs) self.name = "pre_2" def process(self, in_file: Path, out_file: Path, in_meta, logger: logging.Logger): logger.debug(f"Preprocessing2 configuration : {self.__dict__}") logger.debug(f"Preprocessing2 {in_file.absolute()} -> {out_file.absolute()}") # add preamble # TODO # add background noise # TODO
ivas_processing_scripts/processing/processing.py +46 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ from itertools import repeat from pathlib import Path from shutil import copyfile from typing import Iterable, Union from warnings import warn from ivas_processing_scripts.audiotools.audiofile import concat, split from ivas_processing_scripts.audiotools.metadata import ( Loading Loading @@ -176,7 +177,7 @@ def concat_teardown(cfg: TestConfig, logger: logging.Logger): return out_files, out_meta def preprocess(cfg, in_meta, logger): def preprocess(cfg, logger): preprocessing = cfg.proc_chains[0] chain = preprocessing["processes"] Loading @@ -191,7 +192,7 @@ def preprocess(cfg, in_meta, logger): repeat(cfg.out_dirs[0]), repeat(chain), repeat(logger), in_meta, cfg.metadata_path, ), None, "mp" if cfg.multiprocessing else None, Loading @@ -214,6 +215,49 @@ def preprocess(cfg, in_meta, logger): cfg.out_dirs = cfg.out_dirs[1:] def preprocess_2(cfg, logger): preprocessing_2 = cfg.proc_chains[0] chain = preprocessing_2["processes"] logger.info(f" Generating condition: {preprocessing_2['name']}") # concatenate items if required concat_setup(cfg, logger) # run preprocessing 2 apply_func_parallel( process_item, zip( cfg.items_list, repeat(cfg.tmp_dirs[0]), repeat(cfg.out_dirs[0]), repeat(chain), repeat(logger), cfg.metadata_path, ), None, "mp" if cfg.multiprocessing else None, ) # update the configuration to use preprocessing 2 outputs as new inputs cfg.items_list = list_audio( # TODO: add preprocessing_2 to list of audio cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None) ) if cfg.metadata_path[0] is not None: for item_idx in range(len(cfg.metadata_path)): for obj_idx in range(len(cfg.metadata_path[item_idx])): if cfg.metadata_path[item_idx][obj_idx]: cfg.metadata_path[item_idx][obj_idx] = cfg.out_dirs[0] / Path( f"{cfg.items_list[item_idx].stem}.wav.{obj_idx}.csv" ) # remove already applied processing stage cfg.proc_chains = cfg.proc_chains[1:] cfg.tmp_dirs = cfg.tmp_dirs[1:] cfg.out_dirs = cfg.out_dirs[1:] return def process_item( in_file: Union[Path, str], tmp_dir: Union[Path, str], Loading