diff --git a/ivas_processing_scripts/audiotools/metadata.py b/ivas_processing_scripts/audiotools/metadata.py index d0d44502ceaf3427cd4d24a7203fd2c211a7137d..6c6466ece19e4adb3f8d1f886c5fbe5e3696e808 100755 --- a/ivas_processing_scripts/audiotools/metadata.py +++ b/ivas_processing_scripts/audiotools/metadata.py @@ -498,7 +498,9 @@ def check_ISM_metadata( elif len(current_item) == num_objects: # just read out - list_item = current_item + list_item = [] + for c_item in current_item: + list_item.append(Path(c_item).resolve()) else: raise ValueError("Number of objects and metadata does not match.") list_meta.append(list_item) @@ -528,7 +530,7 @@ def metadata_search( ) # check if file exists and add to list if file_name_meta.is_file(): - list_item.append(file_name_meta) + list_item.append(Path(file_name_meta).resolve()) else: raise ValueError(f"Metadata file {file_name_meta} not found.") if len(item_names) == 1: diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py index e4f4a69ff70ef9689468268d484f185fb980b3af..027ac4472b2e6310a4a8fca6ceaed5893a20f6ec 100755 --- a/ivas_processing_scripts/processing/chains.py +++ b/ivas_processing_scripts/processing/chains.py @@ -30,6 +30,7 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # +from pathlib import Path from typing import Optional from ivas_processing_scripts.processing.config import TestConfig @@ -79,7 +80,7 @@ def init_processing_chains(cfg: TestConfig) -> None: # list items in input directory cfg.items_list = list_audio( - cfg.input_path, absolute=True, select_list=getattr(cfg, "input_select", None) + cfg.input_path, select_list=getattr(cfg, "input_select", None) ) if not cfg.items_list: raise SystemExit( @@ -135,7 +136,9 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: if background_cfg: background = { "snr": background_cfg.get("snr", None), - "background_noise_path": background_cfg.get("background_noise_path", None), + "background_noise_path": get_abs_path( + background_cfg.get("background_noise_path", None) + ), "seed_delay": background_cfg.get("seed_delay", 0), "master_seed": cfg.master_seed, "output_fmt": cfg.postprocessing["fmt"], @@ -250,7 +253,9 @@ def get_processing_chain( if tx_cfg_tmp.get("type", None) == "FER": tx_cfg = { "type": tx_cfg_tmp.get("type", None), - "error_pattern": tx_cfg_tmp.get("error_pattern", None), + "error_pattern": get_abs_path( + tx_cfg_tmp.get("error_pattern", None) + ), "error_rate": tx_cfg_tmp.get("error_rate", None), "master_seed": cfg.master_seed, "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0), @@ -258,7 +263,9 @@ def get_processing_chain( elif tx_cfg_tmp.get("type", None) == "JBM": tx_cfg = { "type": tx_cfg_tmp.get("type", None), - "error_pattern": tx_cfg_tmp.get("error_pattern", None), + "error_pattern": get_abs_path( + tx_cfg_tmp.get("error_pattern", None) + ), "error_profile": tx_cfg_tmp.get("error_profile", None), "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None), } @@ -281,9 +288,9 @@ def get_processing_chain( "in_fs": tmp_in_fs, "out_fs": dec_cfg.get("fs", tmp_in_fs), "bitrate": bitrate, - "cod_bin": cod_cfg.get("bin"), + "cod_bin": get_abs_path(cod_cfg.get("bin", None)), "cod_opts": cod_cfg.get("opts"), - "dec_bin": dec_cfg.get("bin"), + "dec_bin": get_abs_path(dec_cfg.get("bin", None)), "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, @@ -309,7 +316,9 @@ def get_processing_chain( if tx_cfg_tmp.get("type", None) == "FER": tx_cfg = { "type": tx_cfg_tmp.get("type", None), - "error_pattern": tx_cfg_tmp.get("error_pattern", None), + "error_pattern": get_abs_path( + tx_cfg_tmp.get("error_pattern", None) + ), "error_rate": tx_cfg_tmp.get("error_rate", None), "master_seed": cfg.master_seed, "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0), @@ -317,7 +326,7 @@ def get_processing_chain( elif tx_cfg_tmp.get("type", None) == "JBM": tx_cfg = { "type": tx_cfg_tmp.get("type", None), - "error_pattern": tx_cfg_tmp.get("error_pattern", None), + "error_pattern": tx_cfg_tmp.get("error_rate", None), "error_profile": tx_cfg_tmp.get("error_profile", None), "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None), } @@ -341,9 +350,9 @@ def get_processing_chain( "out_fmt": dec_cfg.get("fmt", tmp_out_fmt), "out_fs": dec_cfg.get("fs", tmp_in_fs), "bitrate": bitrate, - "cod_bin": cod_cfg.get("bin"), + "cod_bin": get_abs_path(cod_cfg.get("bin", None)), "cod_opts": cod_cfg.get("opts"), - "dec_bin": dec_cfg.get("bin"), + "dec_bin": get_abs_path(dec_cfg.get("bin", None)), "dec_opts": dec_cfg.get("opts"), "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, @@ -372,7 +381,7 @@ def get_processing_chain( "bin_dataset": post_cfg.get("bin_dataset"), "bin_lfe_gain": post_cfg.get("bin_lfe_gain"), "limit": post_cfg.get("limit", True), - "trajectory": post_cfg.get("trajectory"), + "trajectory": get_abs_path(post_cfg.get("trajectory", None)), "multiprocessing": cfg.multiprocessing, "mnru_q": tmp_mnru_q, "esdru_alpha": tmp_esdru_alpha, @@ -381,3 +390,11 @@ 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 diff --git a/ivas_processing_scripts/processing/config.py b/ivas_processing_scripts/processing/config.py index b281e2a35135223ecbc1ee6ce08abac20d4273b3..386f542e5448fc115e4e30b332e1ca01064f0295 100755 --- a/ivas_processing_scripts/processing/config.py +++ b/ivas_processing_scripts/processing/config.py @@ -90,8 +90,8 @@ class TestConfig: self._yaml_dump = self._dump_yaml(cfg) # convert to Path - self.input_path = Path(self.input_path) - self.output_path = Path(self.output_path) + self.input_path = Path(self.input_path).resolve().absolute() + self.output_path = Path(self.output_path).resolve().absolute() def _parse_yaml(self, filename): """parse configuration file""" diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index a4fcb2fff3f7bf4d12d1878b9b7b662d056fcd47..0d2097fa04d11555c4ad0866f9dcd223a2420674 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -223,7 +223,7 @@ def preprocess(cfg, logger): # update the configuration to use preprocessing outputs as new inputs cfg.items_list = list_audio( - cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None) + cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None) ) # Re-ordering items based on concatenation order @@ -274,7 +274,7 @@ def preprocess_2(cfg, logger): # update the configuration to use preprocessing 2 outputs as new inputs cfg.items_list = list_audio( - cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None) + cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None) ) # Re-ordering items based on concatenation order @@ -313,7 +313,7 @@ def reverse_process_2(cfg, logger): # if no concatenation read files from folder out_paths_splits = [] for out_dir in cfg.out_dirs: - list_audio_dir = list_audio(out_dir, absolute=True) + list_audio_dir = list_audio(out_dir) out_paths_splits.append(list_audio_dir) if cfg.postprocessing["fmt"].startswith("ISM"): out_meta_splits = [] diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index 1e21b0dba973cdf2dd73405e782743bf8700f6e7..355de5e99dae667fbaa6941afb253066be171f00 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -93,7 +93,7 @@ class DirManager: ) -def list_audio(path: str, absolute: bool = False, select_list: list = None) -> list: +def list_audio(path: str, select_list: list = None) -> list: """ Return list with all files with ALLOWED_INPUT_EXT found under the given path. @@ -105,23 +105,15 @@ def list_audio(path: str, absolute: bool = False, select_list: list = None) -> l if path.exists(): if path.is_dir(): - if absolute: - [audio_list.extend(list(path.glob(ext))) for ext in ALLOWED_INPUT_EXT] - audio_list = [ - path.joinpath(f) - for f in path.iterdir() - if f.suffix in ALLOWED_INPUT_EXT - ] - else: - audio_list = [ - f for f in path.iterdir() if f.suffix in ALLOWED_INPUT_EXT - ] + audio_list = [ + f.resolve().absolute() + for f in path.iterdir() + if f.suffix in ALLOWED_INPUT_EXT + ] else: - if not absolute: - path = path.name ext = path.suffix if ext in ALLOWED_INPUT_EXT: - audio_list.append(path) + audio_list.append(path.resolve().absolute()) # filter according to select list if select_list: @@ -168,7 +160,7 @@ def find_binary( else: if logger: logger.debug(f"Found binary {bin}") - return Path(bin) + return Path(bin).resolve().absolute() def get_devnull():