Loading examples/TEMPLATE.yml +4 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ output_path: ".../tmp_output" # input_select: # - "48kHz" ### Include the condition number in the item name; default = false ### for e.g. abcxyz.wav --> abcxyz.cXX.wav # condition_in_output_filename: true ################################################ ### Input configuration ################################################ Loading ivas_processing_scripts/__init__.py +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ from ivas_processing_scripts.processing.processing import ( preprocess_2, preprocess_background_noise, process_item, rename_generated_conditions, reorder_items_list, reverse_process_2, ) Loading Loading @@ -176,6 +177,9 @@ def main(args): if hasattr(cfg, "preprocessing_2"): reverse_process_2(cfg, logger) if cfg.condition_in_output_filename: rename_generated_conditions(cfg.output_path) # copy configuration to output directory with open(cfg.output_path.joinpath(f"{cfg.name}.yml"), "w") as f: yaml.safe_dump(cfg._yaml_dump, f) ivas_processing_scripts/constants.py +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ DEFAULT_CONFIG = { "mask": None, "limit": False, }, "condition_in_output_filename": False, } DEFAULT_CONFIG_EVS = { "cod": { Loading ivas_processing_scripts/processing/chains.py +22 −5 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ def init_processing_chains(cfg: TestConfig) -> None: # TODO we may need to change this to ensure it is only one value for IVAS and a possible list for EVS # condition naming will also need to be checked since we rename to {cond_name}_{bitrate} # this may not be desired if bitrates is not None and len(bitrates) > 1: multiple_bitrates_flag = True else: multiple_bitrates_flag = False if bitrates: for bitrate in bitrates: # check if a list was specified Loading @@ -65,14 +68,24 @@ def init_processing_chains(cfg: TestConfig) -> None: # flatten the list of lists for IVAS [ cfg.proc_chains.append( get_processing_chain(cond_name, cond_cfg, extend_br) get_processing_chain( cond_name, cond_cfg, extend_br, multiple_bitrates=multiple_bitrates_flag, ) ) for extend_br in bitrate ] else: # otherwise pass the list; EVS will interpret as per-channel bitrate cfg.proc_chains.append( get_processing_chain(cond_name, cfg, bitrate) get_processing_chain( cond_name, cfg, bitrate, multiple_bitrates=multiple_bitrates_flag, ) ) else: # non coding condition Loading Loading @@ -176,7 +189,10 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: def get_processing_chain( condition: str, cfg: TestConfig, bitrate: Optional[int] = None condition: str, cfg: TestConfig, bitrate: Optional[int] = None, multiple_bitrates: Optional[bool] = False, ) -> dict: """Mapping from test configuration to condition and postprocessing keyword arguments""" name = f"{condition}" Loading @@ -185,6 +201,7 @@ def get_processing_chain( if isinstance(bitrate, list): name += f"_{sum(bitrate)}" else: if multiple_bitrates is True: name += f"_{bitrate}" chain = { Loading ivas_processing_scripts/processing/processing.py +20 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import re from abc import ABC, abstractmethod from itertools import repeat from pathlib import Path Loading Loading @@ -563,3 +564,22 @@ def multiple_of_frame_size( warn( f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of frame length (20 ms)." ) def rename_generated_conditions(output_path: Path): """ Rename the output files. Only renames the files in directories that contain "cXX" in thier names. The "XX" in "cXX" stands for the condition number, for example "c01" Parameters ---------- output_path: Path Path to output directory """ directory = output_path pattern = re.compile(r"^c\d{2}") for subdirectory in directory.iterdir(): if subdirectory.is_dir() and pattern.match(subdirectory.name): for file_path in subdirectory.iterdir(): new_filename = f"{file_path.stem}.{subdirectory.name}{file_path.suffix}" file_path.rename(subdirectory / new_filename) Loading
examples/TEMPLATE.yml +4 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ output_path: ".../tmp_output" # input_select: # - "48kHz" ### Include the condition number in the item name; default = false ### for e.g. abcxyz.wav --> abcxyz.cXX.wav # condition_in_output_filename: true ################################################ ### Input configuration ################################################ Loading
ivas_processing_scripts/__init__.py +4 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ from ivas_processing_scripts.processing.processing import ( preprocess_2, preprocess_background_noise, process_item, rename_generated_conditions, reorder_items_list, reverse_process_2, ) Loading Loading @@ -176,6 +177,9 @@ def main(args): if hasattr(cfg, "preprocessing_2"): reverse_process_2(cfg, logger) if cfg.condition_in_output_filename: rename_generated_conditions(cfg.output_path) # copy configuration to output directory with open(cfg.output_path.joinpath(f"{cfg.name}.yml"), "w") as f: yaml.safe_dump(cfg._yaml_dump, f)
ivas_processing_scripts/constants.py +1 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ DEFAULT_CONFIG = { "mask": None, "limit": False, }, "condition_in_output_filename": False, } DEFAULT_CONFIG_EVS = { "cod": { Loading
ivas_processing_scripts/processing/chains.py +22 −5 Original line number Diff line number Diff line Loading @@ -57,7 +57,10 @@ def init_processing_chains(cfg: TestConfig) -> None: # TODO we may need to change this to ensure it is only one value for IVAS and a possible list for EVS # condition naming will also need to be checked since we rename to {cond_name}_{bitrate} # this may not be desired if bitrates is not None and len(bitrates) > 1: multiple_bitrates_flag = True else: multiple_bitrates_flag = False if bitrates: for bitrate in bitrates: # check if a list was specified Loading @@ -65,14 +68,24 @@ def init_processing_chains(cfg: TestConfig) -> None: # flatten the list of lists for IVAS [ cfg.proc_chains.append( get_processing_chain(cond_name, cond_cfg, extend_br) get_processing_chain( cond_name, cond_cfg, extend_br, multiple_bitrates=multiple_bitrates_flag, ) ) for extend_br in bitrate ] else: # otherwise pass the list; EVS will interpret as per-channel bitrate cfg.proc_chains.append( get_processing_chain(cond_name, cfg, bitrate) get_processing_chain( cond_name, cfg, bitrate, multiple_bitrates=multiple_bitrates_flag, ) ) else: # non coding condition Loading Loading @@ -176,7 +189,10 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: def get_processing_chain( condition: str, cfg: TestConfig, bitrate: Optional[int] = None condition: str, cfg: TestConfig, bitrate: Optional[int] = None, multiple_bitrates: Optional[bool] = False, ) -> dict: """Mapping from test configuration to condition and postprocessing keyword arguments""" name = f"{condition}" Loading @@ -185,6 +201,7 @@ def get_processing_chain( if isinstance(bitrate, list): name += f"_{sum(bitrate)}" else: if multiple_bitrates is True: name += f"_{bitrate}" chain = { Loading
ivas_processing_scripts/processing/processing.py +20 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ # import logging import re from abc import ABC, abstractmethod from itertools import repeat from pathlib import Path Loading Loading @@ -563,3 +564,22 @@ def multiple_of_frame_size( warn( f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of frame length (20 ms)." ) def rename_generated_conditions(output_path: Path): """ Rename the output files. Only renames the files in directories that contain "cXX" in thier names. The "XX" in "cXX" stands for the condition number, for example "c01" Parameters ---------- output_path: Path Path to output directory """ directory = output_path pattern = re.compile(r"^c\d{2}") for subdirectory in directory.iterdir(): if subdirectory.is_dir() and pattern.match(subdirectory.name): for file_path in subdirectory.iterdir(): new_filename = f"{file_path.stem}.{subdirectory.name}{file_path.suffix}" file_path.rename(subdirectory / new_filename)