Loading examples/TEMPLATE.yml +34 −20 Original line number Diff line number Diff line Loading @@ -16,17 +16,15 @@ # delete_tmp: true ### Master seed for random processes like bitstream error pattern generation; default = 0 # master_seed: 5 ### Additional seed to specify number of preruns; default = 0 # prerun_seed: 2 ### Any relative paths will be interpreted relative to the working directory the script is called from! ### Usage of absolute paths is recommended. ### Do not use file names with dots "." in them! This is not supported, use "_" instead ### For Windows user: please use double back slash '\\' in paths and add '.exe' to executable definitions ### REQUIRED: Input path or file input_path: "~/ivas/items/HOA3" input_path: ".../ivas/items/HOA3" ### REQUIRED: Output path or file output_path: "./tmp_output" output_path: ".../tmp_output" ### Metadata path or file(s) ### If input format is ISM{1-4} a path for the metadata files can be specified; ### default = null (for ISM search for item_name.{wav, raw, pcm}.{0-3}.csv in input folder, otherise ignored) Loading @@ -49,17 +47,6 @@ output_path: "./tmp_output" # input_select: # - "48kHz" ### Horizontally concatenate input items into one long file; default = false # concatenate_input: true ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be ### as per the filesystem on the users' device ### Should only be used if concatenate_input = true # concatenation_order: [] ### Specify preamble duration in ms; default = 0 # preamble: 40 ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) # pad_noise_preamble: true ################################################ ### Input configuration ################################################ Loading @@ -70,7 +57,7 @@ input: # fs: 32000 ################################################ ### Pre-processing ### Pre-processing on individual items ################################################ ### Pre-processing step performed prior to core processing for all conditions ### If not defined, preprocessing step is skipped Loading @@ -97,6 +84,31 @@ input: ### Length of window used at start/end of signal (ms); default = 0 # window: 100 ################################################ ### Pre-processing on whole signal(s) ################################################ # preprocessing_2: ### Options for processing of the concatenated item (concatenate_input: true) or ### the individual items (concatenate_input: false) after previous pre-processing step ### Horizontally concatenate input items into one long file; default = false # concatenate_input: true ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be ### as per the filesystem on the users' device ### Should only be used if concatenate_input = true # concatenation_order: [] ### Specify preamble duration in ms; default = 0 # preamble: 10000 ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB # snr: 10 ### REQUIRED: Path to background noise # background_noise_path: ".../noise.wav" ### Seed for delay offest; default = 0 # seed_delay: 10 ################################################# ### Bitstream processing ################################################# Loading @@ -122,6 +134,8 @@ input: # error_pattern: "path/pattern.192" ### Error rate in percent # error_rate: 5 ### Additional seed to specify number of preruns; default = 0 # prerun_seed: 2 ################################################ ### Configuration for conditions under test Loading Loading @@ -209,7 +223,7 @@ conditions_to_generate: ### Path to decoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary) bin: ~/git/ivas-codec/IVAS_dec ### Decoder output format; default = postprocessing fmt fmt: "CICP19" fmt: "7_1_4" ### Decoder output sampling rate; default = null (same as input) # fs: 48000 ### Additional commandline options; default = null Loading Loading @@ -244,8 +258,8 @@ conditions_to_generate: postprocessing: ### REQUIRED: Target format for output fmt: "BINAURAL" ### Target sampling rate in Hz for resampling; default = null (no resampling) # fs: 16000 ### REQUIRED: Target sampling rate in Hz for resampling fs: 48000 ### Low-pass cut-off frequency in Hz; default = null (no filtering) # lp_cutoff: 24000 ### Target loudness in LKFS; default = null (no loudness change applied) Loading ivas_processing_scripts/__init__.py +20 −27 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ from itertools import repeat import yaml from ivas_processing_scripts.audiotools.metadata import check_ISM_metadata from ivas_processing_scripts.audiotools.wrappers.bs1770 import scale_files from ivas_processing_scripts.constants import ( LOGGER_DATEFMT, LOGGER_FORMAT, Loading @@ -44,11 +43,11 @@ from ivas_processing_scripts.constants import ( ) from ivas_processing_scripts.processing import chains, config from ivas_processing_scripts.processing.processing import ( concat_setup, concat_teardown, preprocess, preprocess_2, process_item, reorder_items_list, reverse_process_2, ) from ivas_processing_scripts.utils import DirManager, apply_func_parallel Loading Loading @@ -95,8 +94,15 @@ 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.get("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,12 +127,15 @@ def main(args): # run preprocessing only once if hasattr(cfg, "preprocessing"): preprocess(cfg, cfg.metadata_path, logger) preprocess(cfg, logger) if cfg.concatenate_input: # concatenate items if required concat_setup(cfg, logger) # preprocessing on whole signal(s) if hasattr(cfg, "preprocessing_2"): # save process info to revert it later cfg.pre2 = cfg.proc_chains[0]["processes"][0] preprocess_2(cfg, logger) # run conditions for condition, out_dir, tmp_dir in zip( cfg.proc_chains, cfg.out_dirs, cfg.tmp_dirs ): Loading @@ -134,11 +143,6 @@ def main(args): logger.info(f" Generating condition: {condition['name']}") # # TODO: what happens when no concatenation or only one file for concatenation? # if condition["processes"][0].name == "ivas": # TODO: check if 0 index sufficient # a = {"number_frames": cfg.num_frames, "number_frames_preamble": cfg.num_frames_preamble} # condition["processes"][0].tx.update(a) apply_func_parallel( process_item, zip( Loading @@ -153,19 +157,8 @@ def main(args): "mp" if cfg.multiprocessing else None, ) if cfg.concatenate_input: # write out the splits, optionally remove file out_paths_splits, out_meta_splits = concat_teardown(cfg, logger) # scale individual files if cfg.postprocessing.get("loudness", False): # TODO: take care of samplingrate scale_files( out_paths_splits, cfg.postprocessing["fmt"], cfg.postprocessing["loudness"], cfg.postprocessing.get("fs", None), out_meta_splits, ) if hasattr(cfg, "preprocessing_2"): reverse_process_2(cfg, logger) # copy configuration to output directory with open(cfg.output_path.joinpath(f"{cfg.name}.yml"), "w") as f: Loading ivas_processing_scripts/audiotools/audiofile.py +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ def write( def concat( in_filenames: list, out_file: str, silence_pre: int, silence_post: int, silence_pre: Optional[int] = 0, silence_post: Optional[int] = 0, in_fs: Optional[int] = 48000, num_channels: Optional[int] = None, pad_noise: Optional[bool] = False, Loading ivas_processing_scripts/audiotools/metadata.py +43 −30 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ def write_ISM_metadata_in_file( List of acutally used file names """ if len(metadata) != len(file_name) and not automatic_naming: if not automatic_naming and len(metadata) != len(file_name): raise ValueError("Number of metadata objects and file names has to match") number_objects = len(metadata) Loading Loading @@ -299,9 +299,9 @@ def concat_meta_from_file( audio_files: list[str], meta_files: list[list[str]], out_file: list[str], silence_pre: int, silence_post: int, input_fmt: str, silence_pre: Optional[int] = 0, silence_post: Optional[int] = 0, preamble: Optional[int] = None, ) -> None: """ Loading @@ -315,12 +315,12 @@ def concat_meta_from_file( List of corresponding metadata file names out_file: list[str] Name of concatenated output file silence_pre: int Silence inserted before each item silence_post: int Silence inserted after each item input_fmt: str Input audio format silence_pre: Optional[int] Silence inserted before each item silence_post: Optional[int] Silence inserted after each item preamble: Optional[int] Length of preamble in milliseconds """ Loading Loading @@ -362,7 +362,7 @@ def concat_meta_from_file( # pad trim_meta( audio_item, (-silence_pre, -silence_post) ) # use negative value since we wante to pad, not trim ) # use negative value since we want to pad, not trim # concatenate for idx, obj_pos in enumerate(audio_item.object_pos): Loading @@ -374,26 +374,7 @@ def concat_meta_from_file( # add preamble if preamble: preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): raise ValueError( f"ISM metadata padding and trimming only possible if pad/trim length is multiple of frame length. " f"Frame length: {IVAS_FRAME_LEN_MS}ms" ) for obj_idx in range(len(concat_meta_all_obj)): if ( concat_meta_all_obj is not None and concat_meta_all_obj[obj_idx] is not None ): concat_meta_all_obj[obj_idx] = trim( concat_meta_all_obj[obj_idx], limits=(-int(preamble_frames), 0), samples=True, ) # add radius 1 concat_meta_all_obj[obj_idx][: int(preamble_frames), 2] = 1 pass concat_meta_all_obj = add_remove_preamble(concat_meta_all_obj, preamble) write_ISM_metadata_in_file(concat_meta_all_obj, out_file) Loading Loading @@ -529,7 +510,7 @@ def check_ISM_metadata( def metadata_search( in_meta: Union[str, Path], in_meta_path: Union[str, Path], item_names: list[Union[str, Path]], num_objects: int, ) -> list[list[Union[Path, str]]]: Loading @@ -542,7 +523,7 @@ def metadata_search( for item in item_names: list_item = [] for obj_idx in range(num_objects): file_name_meta = in_meta / Path(item.stem).with_suffix( file_name_meta = in_meta_path / Path(item.stem).with_suffix( f"{item.suffix}.{obj_idx}.csv" ) # check if file exists and add to list Loading @@ -556,3 +537,35 @@ def metadata_search( list_meta.append(list_item) return list_meta def add_remove_preamble( metadata, preamble, add: Optional[bool] = True, ): preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): raise ValueError( f"Application of preamble for ISM metadata is only possible if preamble length is multiple of frame length. " f"Frame length: {IVAS_FRAME_LEN_MS}ms" ) for obj_idx in range(len(metadata)): if metadata is not None and metadata[obj_idx] is not None: if add: metadata[obj_idx] = trim( metadata[obj_idx], limits=(-int(preamble_frames), 0), samples=True, ) # add radius 1 metadata[obj_idx][: int(preamble_frames), 2] = 1 else: metadata[obj_idx] = trim( metadata[obj_idx], limits=(int(preamble_frames), 0), samples=True, ) return metadata ivas_processing_scripts/audiotools/wrappers/gen_patt.py +1 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ def create_error_pattern( tmp_sta_file = tmp_dir.joinpath("sta") # compute seed seed = random_seed(master_seed, prerun_seed) seed = random_seed((0, 99999999), master_seed, prerun_seed) # open file and modify lines = [] Loading Loading
examples/TEMPLATE.yml +34 −20 Original line number Diff line number Diff line Loading @@ -16,17 +16,15 @@ # delete_tmp: true ### Master seed for random processes like bitstream error pattern generation; default = 0 # master_seed: 5 ### Additional seed to specify number of preruns; default = 0 # prerun_seed: 2 ### Any relative paths will be interpreted relative to the working directory the script is called from! ### Usage of absolute paths is recommended. ### Do not use file names with dots "." in them! This is not supported, use "_" instead ### For Windows user: please use double back slash '\\' in paths and add '.exe' to executable definitions ### REQUIRED: Input path or file input_path: "~/ivas/items/HOA3" input_path: ".../ivas/items/HOA3" ### REQUIRED: Output path or file output_path: "./tmp_output" output_path: ".../tmp_output" ### Metadata path or file(s) ### If input format is ISM{1-4} a path for the metadata files can be specified; ### default = null (for ISM search for item_name.{wav, raw, pcm}.{0-3}.csv in input folder, otherise ignored) Loading @@ -49,17 +47,6 @@ output_path: "./tmp_output" # input_select: # - "48kHz" ### Horizontally concatenate input items into one long file; default = false # concatenate_input: true ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be ### as per the filesystem on the users' device ### Should only be used if concatenate_input = true # concatenation_order: [] ### Specify preamble duration in ms; default = 0 # preamble: 40 ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) # pad_noise_preamble: true ################################################ ### Input configuration ################################################ Loading @@ -70,7 +57,7 @@ input: # fs: 32000 ################################################ ### Pre-processing ### Pre-processing on individual items ################################################ ### Pre-processing step performed prior to core processing for all conditions ### If not defined, preprocessing step is skipped Loading @@ -97,6 +84,31 @@ input: ### Length of window used at start/end of signal (ms); default = 0 # window: 100 ################################################ ### Pre-processing on whole signal(s) ################################################ # preprocessing_2: ### Options for processing of the concatenated item (concatenate_input: true) or ### the individual items (concatenate_input: false) after previous pre-processing step ### Horizontally concatenate input items into one long file; default = false # concatenate_input: true ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be ### as per the filesystem on the users' device ### Should only be used if concatenate_input = true # concatenation_order: [] ### Specify preamble duration in ms; default = 0 # preamble: 10000 ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence) # preamble_noise: true ### Additive background noise # background_noise: ### REQUIRED: SNR for background noise in dB # snr: 10 ### REQUIRED: Path to background noise # background_noise_path: ".../noise.wav" ### Seed for delay offest; default = 0 # seed_delay: 10 ################################################# ### Bitstream processing ################################################# Loading @@ -122,6 +134,8 @@ input: # error_pattern: "path/pattern.192" ### Error rate in percent # error_rate: 5 ### Additional seed to specify number of preruns; default = 0 # prerun_seed: 2 ################################################ ### Configuration for conditions under test Loading Loading @@ -209,7 +223,7 @@ conditions_to_generate: ### Path to decoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary) bin: ~/git/ivas-codec/IVAS_dec ### Decoder output format; default = postprocessing fmt fmt: "CICP19" fmt: "7_1_4" ### Decoder output sampling rate; default = null (same as input) # fs: 48000 ### Additional commandline options; default = null Loading Loading @@ -244,8 +258,8 @@ conditions_to_generate: postprocessing: ### REQUIRED: Target format for output fmt: "BINAURAL" ### Target sampling rate in Hz for resampling; default = null (no resampling) # fs: 16000 ### REQUIRED: Target sampling rate in Hz for resampling fs: 48000 ### Low-pass cut-off frequency in Hz; default = null (no filtering) # lp_cutoff: 24000 ### Target loudness in LKFS; default = null (no loudness change applied) Loading
ivas_processing_scripts/__init__.py +20 −27 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ from itertools import repeat import yaml from ivas_processing_scripts.audiotools.metadata import check_ISM_metadata from ivas_processing_scripts.audiotools.wrappers.bs1770 import scale_files from ivas_processing_scripts.constants import ( LOGGER_DATEFMT, LOGGER_FORMAT, Loading @@ -44,11 +43,11 @@ from ivas_processing_scripts.constants import ( ) from ivas_processing_scripts.processing import chains, config from ivas_processing_scripts.processing.processing import ( concat_setup, concat_teardown, preprocess, preprocess_2, process_item, reorder_items_list, reverse_process_2, ) from ivas_processing_scripts.utils import DirManager, apply_func_parallel Loading Loading @@ -95,8 +94,15 @@ 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.get("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,12 +127,15 @@ def main(args): # run preprocessing only once if hasattr(cfg, "preprocessing"): preprocess(cfg, cfg.metadata_path, logger) preprocess(cfg, logger) if cfg.concatenate_input: # concatenate items if required concat_setup(cfg, logger) # preprocessing on whole signal(s) if hasattr(cfg, "preprocessing_2"): # save process info to revert it later cfg.pre2 = cfg.proc_chains[0]["processes"][0] preprocess_2(cfg, logger) # run conditions for condition, out_dir, tmp_dir in zip( cfg.proc_chains, cfg.out_dirs, cfg.tmp_dirs ): Loading @@ -134,11 +143,6 @@ def main(args): logger.info(f" Generating condition: {condition['name']}") # # TODO: what happens when no concatenation or only one file for concatenation? # if condition["processes"][0].name == "ivas": # TODO: check if 0 index sufficient # a = {"number_frames": cfg.num_frames, "number_frames_preamble": cfg.num_frames_preamble} # condition["processes"][0].tx.update(a) apply_func_parallel( process_item, zip( Loading @@ -153,19 +157,8 @@ def main(args): "mp" if cfg.multiprocessing else None, ) if cfg.concatenate_input: # write out the splits, optionally remove file out_paths_splits, out_meta_splits = concat_teardown(cfg, logger) # scale individual files if cfg.postprocessing.get("loudness", False): # TODO: take care of samplingrate scale_files( out_paths_splits, cfg.postprocessing["fmt"], cfg.postprocessing["loudness"], cfg.postprocessing.get("fs", None), out_meta_splits, ) if hasattr(cfg, "preprocessing_2"): reverse_process_2(cfg, logger) # copy configuration to output directory with open(cfg.output_path.joinpath(f"{cfg.name}.yml"), "w") as f: Loading
ivas_processing_scripts/audiotools/audiofile.py +2 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,8 @@ def write( def concat( in_filenames: list, out_file: str, silence_pre: int, silence_post: int, silence_pre: Optional[int] = 0, silence_post: Optional[int] = 0, in_fs: Optional[int] = 48000, num_channels: Optional[int] = None, pad_noise: Optional[bool] = False, Loading
ivas_processing_scripts/audiotools/metadata.py +43 −30 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ def write_ISM_metadata_in_file( List of acutally used file names """ if len(metadata) != len(file_name) and not automatic_naming: if not automatic_naming and len(metadata) != len(file_name): raise ValueError("Number of metadata objects and file names has to match") number_objects = len(metadata) Loading Loading @@ -299,9 +299,9 @@ def concat_meta_from_file( audio_files: list[str], meta_files: list[list[str]], out_file: list[str], silence_pre: int, silence_post: int, input_fmt: str, silence_pre: Optional[int] = 0, silence_post: Optional[int] = 0, preamble: Optional[int] = None, ) -> None: """ Loading @@ -315,12 +315,12 @@ def concat_meta_from_file( List of corresponding metadata file names out_file: list[str] Name of concatenated output file silence_pre: int Silence inserted before each item silence_post: int Silence inserted after each item input_fmt: str Input audio format silence_pre: Optional[int] Silence inserted before each item silence_post: Optional[int] Silence inserted after each item preamble: Optional[int] Length of preamble in milliseconds """ Loading Loading @@ -362,7 +362,7 @@ def concat_meta_from_file( # pad trim_meta( audio_item, (-silence_pre, -silence_post) ) # use negative value since we wante to pad, not trim ) # use negative value since we want to pad, not trim # concatenate for idx, obj_pos in enumerate(audio_item.object_pos): Loading @@ -374,26 +374,7 @@ def concat_meta_from_file( # add preamble if preamble: preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): raise ValueError( f"ISM metadata padding and trimming only possible if pad/trim length is multiple of frame length. " f"Frame length: {IVAS_FRAME_LEN_MS}ms" ) for obj_idx in range(len(concat_meta_all_obj)): if ( concat_meta_all_obj is not None and concat_meta_all_obj[obj_idx] is not None ): concat_meta_all_obj[obj_idx] = trim( concat_meta_all_obj[obj_idx], limits=(-int(preamble_frames), 0), samples=True, ) # add radius 1 concat_meta_all_obj[obj_idx][: int(preamble_frames), 2] = 1 pass concat_meta_all_obj = add_remove_preamble(concat_meta_all_obj, preamble) write_ISM_metadata_in_file(concat_meta_all_obj, out_file) Loading Loading @@ -529,7 +510,7 @@ def check_ISM_metadata( def metadata_search( in_meta: Union[str, Path], in_meta_path: Union[str, Path], item_names: list[Union[str, Path]], num_objects: int, ) -> list[list[Union[Path, str]]]: Loading @@ -542,7 +523,7 @@ def metadata_search( for item in item_names: list_item = [] for obj_idx in range(num_objects): file_name_meta = in_meta / Path(item.stem).with_suffix( file_name_meta = in_meta_path / Path(item.stem).with_suffix( f"{item.suffix}.{obj_idx}.csv" ) # check if file exists and add to list Loading @@ -556,3 +537,35 @@ def metadata_search( list_meta.append(list_item) return list_meta def add_remove_preamble( metadata, preamble, add: Optional[bool] = True, ): preamble_frames = preamble / IVAS_FRAME_LEN_MS if not preamble_frames.is_integer(): raise ValueError( f"Application of preamble for ISM metadata is only possible if preamble length is multiple of frame length. " f"Frame length: {IVAS_FRAME_LEN_MS}ms" ) for obj_idx in range(len(metadata)): if metadata is not None and metadata[obj_idx] is not None: if add: metadata[obj_idx] = trim( metadata[obj_idx], limits=(-int(preamble_frames), 0), samples=True, ) # add radius 1 metadata[obj_idx][: int(preamble_frames), 2] = 1 else: metadata[obj_idx] = trim( metadata[obj_idx], limits=(int(preamble_frames), 0), samples=True, ) return metadata
ivas_processing_scripts/audiotools/wrappers/gen_patt.py +1 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ def create_error_pattern( tmp_sta_file = tmp_dir.joinpath("sta") # compute seed seed = random_seed(master_seed, prerun_seed) seed = random_seed((0, 99999999), master_seed, prerun_seed) # open file and modify lines = [] Loading