From d961c8c74574556b95a2c6a1d002dbc5f0afe4f4 Mon Sep 17 00:00:00 2001 From: veeravt Date: Mon, 24 Apr 2023 13:23:01 +0200 Subject: [PATCH 1/7] Added a function to get binary paths from a yaml file. --- ivas_processing_scripts/__init__.py | 10 +++++++++- ivas_processing_scripts/constants.py | 1 + ivas_processing_scripts/utils.py | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 5fedfc32..2445e835 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -50,7 +50,11 @@ from ivas_processing_scripts.processing.processing import ( process_item, reorder_items_list, ) -from ivas_processing_scripts.utils import DirManager, apply_func_parallel +from ivas_processing_scripts.utils import ( + DirManager, + apply_func_parallel, + get_binary_paths, +) def logging_init(args, cfg): @@ -94,6 +98,10 @@ def main(args): # set up logging logger = logging_init(args, cfg) + # updating binary paths + if cfg.binary_paths is not None: + get_binary_paths(cfg, cfg.binary_paths) + # 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) diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index 5d92d192..ce0c599c 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -69,6 +69,7 @@ DEFAULT_CONFIG = { "preamble": None, "pad_noise_preamble": False, "metadata_path": None, + "binary_paths": None, # postprocessing "postprocessing": { "hp50": False, diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index f28dd79f..5147a370 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -34,6 +34,7 @@ import logging import shutil import subprocess as sp import sys +import yaml from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor from itertools import repeat, tee from os import devnull @@ -144,16 +145,20 @@ def find_binary( binary: str, raise_error: Optional[bool] = True, logger: Optional[logging.Logger] = None, + binary_path: Optional[str] = None, ) -> Union[Path, None]: """Attempt to find and return the path to the given binary""" # prioritise binaries placed in the directory over $PATH - bin = which(binary, path=BIN_DIR) + if binary_path is not None: + bin = which(binary, path=binary_path) + else: + bin = which(binary, path=BIN_DIR) if not bin: bin = which(binary) if not bin and raise_error: raise FileNotFoundError( - f"Binary {binary} was not found in $PATH or in {BIN_DIR.absolute()}!" + f"Binary {binary} was neither found in {binary_path.absolute()} nor in {BIN_DIR.absolute()} or in $PATH!" ) elif not bin: if logger: @@ -280,3 +285,11 @@ def progressbar(iter: Iterable, width=80): yield item update(i + 1) print("\n", flush=True, file=sys.stdout) + + +def get_binary_paths(obj, binary_path): + with open(binary_path, "r") as f: + data = yaml.safe_load(f) + for key, value in data.items(): + p = Path(value) + setattr(obj, key + "_binary_path", p) -- GitLab From 11670ff030a10de33b9336a01dc69d4af18e2e71 Mon Sep 17 00:00:00 2001 From: veeravt Date: Mon, 24 Apr 2023 15:39:54 +0200 Subject: [PATCH 2/7] Modified the wrapper functions to accept an addiotinal binary_path arguemnt. --- .../audiotools/wrappers/bs1770.py | 6 +++++- .../audiotools/wrappers/eid_xor.py | 6 +++++- .../audiotools/wrappers/esdru.py | 6 +++++- .../audiotools/wrappers/filter.py | 6 +++++- .../audiotools/wrappers/gen_patt.py | 6 +++++- .../audiotools/wrappers/masaRenderer.py | 7 ++++++- .../audiotools/wrappers/networkSimulator.py | 14 ++++++++++++-- .../audiotools/wrappers/p50fbmnru.py | 7 ++++++- .../audiotools/wrappers/random_seed.py | 7 ++++++- 9 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index a047c339..088ceb28 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -51,6 +51,7 @@ logger.setLevel(logging.DEBUG) def bs1770demo( input: audio.Audio, target_loudness: Optional[float] = -26, + binary_path: Optional[Path] = None, ) -> Tuple[float, float]: """ Wrapper for ITU-R BS.1770-4, requires bs1770demo binary @@ -72,7 +73,10 @@ def bs1770demo( null_file = get_devnull() - binary = find_binary("bs1770demo") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("bs1770demo") if not isinstance(input, audio.BinauralAudio) and not isinstance( input, audio.ChannelBasedAudio diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index 72fb5ce2..39b0ea1f 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -42,6 +42,7 @@ def eid_xor( error_pattern: Union[str, Path], in_bitstream: Union[str, Path], out_bitstream: Union[str, Path], + binary_path: Optional[Path] = None, ) -> None: """ Wrapper for eid-xor binary to apply error patterns for the bitstream processing @@ -57,7 +58,10 @@ def eid_xor( """ # find binary - binary = find_binary("eid-xor") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("eid-xor") # check for valid inputs if not Path(in_bitstream).is_file(): diff --git a/ivas_processing_scripts/audiotools/wrappers/esdru.py b/ivas_processing_scripts/audiotools/wrappers/esdru.py index 4e0dfbea..2f2625b1 100755 --- a/ivas_processing_scripts/audiotools/wrappers/esdru.py +++ b/ivas_processing_scripts/audiotools/wrappers/esdru.py @@ -47,6 +47,7 @@ def esdru( sf: Optional[int] = 48000, e_step: Optional[float] = 0.5, seed: Optional[int] = 1, + binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for ESDRU (Ericsson spatial distortion reference unit) Recommendation ITU-T P.811, requires esdru binary @@ -70,7 +71,10 @@ def esdru( Output array (16 bit Stereo PCM) """ - binary = find_binary("esdru") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("esdru") if not isinstance(input, audio.BinauralAudio) and not input.name == "STEREO": raise Exception( diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 1efbf9be..3fc5ff2c 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -57,6 +57,7 @@ def filter_itu( is_async: Optional[bool] = False, delay: Optional[int] = None, skip_channel: Optional[list[int]] = None, + binary_path: Optional[Path] = None, ) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -88,7 +89,10 @@ def filter_itu( Output filtered array """ - binary = find_binary("filter") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("filter") # check if filter type is supported tmp = run([binary], check=False) diff --git a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py index aa480af1..ce00361d 100644 --- a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py +++ b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py @@ -47,6 +47,7 @@ def gen_patt( error_rate: float, start: Optional[int] = 0, working_dir: Optional[Union[Path, str]] = None, + binary_path: Optional[Path] = None, ) -> None: """ Wrapper for gen-patt binary to create error patterns for the bitstream processing @@ -66,7 +67,10 @@ def gen_patt( """ # find binary - binary = find_binary("gen-patt") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("gen-patt") if working_dir is None: working_dir = getcwd() diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index 7b5eafda..6b619bb4 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -32,6 +32,7 @@ from pathlib import Path from tempfile import TemporaryDirectory +from typing import Optional import numpy as np @@ -44,6 +45,7 @@ from ivas_processing_scripts.utils import find_binary, run def masaRenderer( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, + binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for masaRenderer (from MASA reference software) @@ -61,7 +63,10 @@ def masaRenderer( MASA rendered to out_fmt """ - binary = find_binary("masaRenderer") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("masaRenderer") if out_fmt not in ["5_1", "7_1_4", "BINAURAL"]: raise ValueError(f"Output format {out_fmt} is not supported by MasaRenderer!") diff --git a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py index fa1b7509..16dc582d 100644 --- a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py +++ b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py @@ -44,6 +44,7 @@ def validate_network_simulator( error_pattern: Optional[Union[Path, str]] = None, error_profile: Optional[int] = None, n_frames_per_packet: Optional[int] = None, + binary_path: Optional[Path] = None, ) -> None: """ Validate settings for the network simulator @@ -58,7 +59,12 @@ def validate_network_simulator( Number of frames per paket """ - if find_binary("networkSimulator_g192") is None: + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("networkSimulator_g192") + + if binary is None: raise FileNotFoundError( "The network simulator binary was not found! Please check the configuration." ) @@ -90,6 +96,7 @@ def network_simulator( out_bitstream: Union[str, Path], n_frames_per_packet: int, offset: int, + binary_path: Optional[Path] = None, ) -> None: """ Wrapper for networkSimulator_g192 binary to apply error patterns for the bitstream processing @@ -109,7 +116,10 @@ def network_simulator( """ # find binary - binary = find_binary("networkSimulator_g192") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("networkSimulator_g192") # check for valid inputs if not Path(in_bitstream).is_file(): diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index 76601048..36adb137 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -32,6 +32,7 @@ from pathlib import Path from tempfile import TemporaryDirectory +from typing import Optional from warnings import warn import numpy as np @@ -45,6 +46,7 @@ from ivas_processing_scripts.utils import find_binary, run def p50fbmnru( input: audio.Audio, q_db: float, + binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for P.50 Fullband MNRU (Modulated Noise Reference Unit), requires p50fbmnru binary @@ -63,7 +65,10 @@ def p50fbmnru( Output array """ - binary = find_binary("p50fbmnru") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("p50fbmnru") if input.fs != 48000: warn("P.50 Fullband MNRU requires a sampling rate of 48kHz.") diff --git a/ivas_processing_scripts/audiotools/wrappers/random_seed.py b/ivas_processing_scripts/audiotools/wrappers/random_seed.py index 802f68b9..50b3aaf2 100644 --- a/ivas_processing_scripts/audiotools/wrappers/random_seed.py +++ b/ivas_processing_scripts/audiotools/wrappers/random_seed.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.utils import find_binary, run @@ -39,6 +40,7 @@ def random_seed( master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, hexa: Optional[bool] = True, + binary_path: Optional[Path] = None, ) -> int: """ @@ -58,7 +60,10 @@ def random_seed( """ # find binary - binary = find_binary("random") + if binary_path is not None: + binary = find_binary(binary_path.name, binary_path=binary_path.parent) + else: + binary = find_binary("random") # set up command line cmd = [ -- GitLab From eee84e687945e53632305d1efa14e4867a151131 Mon Sep 17 00:00:00 2001 From: veeravt Date: Tue, 25 Apr 2023 12:07:30 +0200 Subject: [PATCH 3/7] Added functionality to allow user configurable binary paths. --- .gitignore | 2 +- README.md | 6 +++- examples/TEMPLATE.yml | 2 ++ ivas_processing_scripts/__init__.py | 5 ---- .../audiotools/wrappers/bs1770.py | 9 ++++-- .../audiotools/wrappers/eid_xor.py | 9 ++++-- .../audiotools/wrappers/esdru.py | 10 ++++--- .../audiotools/wrappers/filter.py | 9 ++++-- .../audiotools/wrappers/gen_patt.py | 9 ++++-- .../audiotools/wrappers/masaRenderer.py | 10 ++++--- .../audiotools/wrappers/networkSimulator.py | 21 +++++++++---- .../audiotools/wrappers/p50fbmnru.py | 10 ++++--- .../audiotools/wrappers/random_seed.py | 10 ++++--- ivas_processing_scripts/binary_paths.yml | 30 +++++++++++++++++++ ivas_processing_scripts/constants.py | 9 ++++-- ivas_processing_scripts/utils.py | 12 ++++---- 16 files changed, 115 insertions(+), 48 deletions(-) create mode 100644 ivas_processing_scripts/binary_paths.yml diff --git a/.gitignore b/.gitignore index 849ee6b3..a1261e3c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ venv/ *.pcm *.bs *.192 - +mc.double diff --git a/README.md b/README.md index e5731507..7865f4dd 100755 --- a/README.md +++ b/README.md @@ -53,12 +53,16 @@ The `ivas_processing_scripts` module helps to quickly setup listening tests with This module may be used by executing the top level python module i.e. `python -m ivas_processing_scripts CONFIG.YML`. -## Configuration file +## Configuration file for processing module The processing module can be configured to set up a test via a YAML configuration file. YAML is a superset of JSON, however unlike JSON comments are permitted, which allows for the addition of useful information in the configuration file. +## Configuration file for binaries/executables + +The user can specify custom binary paths and names via a YAML configuration file called [_binary_paths.yml_](ivas_processing_scripts/binary_paths.yml). More information on usage can be found in the comments mentioned in the file. + ## YAML reference A read through of the YAML reference card is highly recommended. This can be found here: diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index 68ffcb5e..51ce44d0 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -54,6 +54,8 @@ output_path: "./tmp_output" ### 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 +### Specify the filename with extension. +### For example, concatenation_order: ["file3.wav", "file1.wav", "file4.wav", "file2.wav"] # concatenation_order: [] ### Specify preamble duration in ms; default = 0 # preamble: 40 diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 2445e835..563b6697 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -53,7 +53,6 @@ from ivas_processing_scripts.processing.processing import ( from ivas_processing_scripts.utils import ( DirManager, apply_func_parallel, - get_binary_paths, ) @@ -98,10 +97,6 @@ def main(args): # set up logging logger = logging_init(args, cfg) - # updating binary paths - if cfg.binary_paths is not None: - get_binary_paths(cfg, cfg.binary_paths) - # 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) diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index 088ceb28..afffe283 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -43,6 +43,7 @@ from ivas_processing_scripts.audiotools import audio, convert from ivas_processing_scripts.audiotools.audiofile import write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.utils import find_binary, get_devnull, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES logger = logging.getLogger("__main__") logger.setLevel(logging.DEBUG) @@ -51,7 +52,6 @@ logger.setLevel(logging.DEBUG) def bs1770demo( input: audio.Audio, target_loudness: Optional[float] = -26, - binary_path: Optional[Path] = None, ) -> Tuple[float, float]: """ Wrapper for ITU-R BS.1770-4, requires bs1770demo binary @@ -73,8 +73,11 @@ def bs1770demo( null_file = get_devnull() - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "bs1770demo" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["bs1770demo"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["bs1770demo"].parent, + ) else: binary = find_binary("bs1770demo") diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index 39b0ea1f..bb5cc5d0 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -36,13 +36,13 @@ from typing import Optional, Union from ivas_processing_scripts.audiotools.wrappers.gen_patt import create_error_pattern from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES def eid_xor( error_pattern: Union[str, Path], in_bitstream: Union[str, Path], out_bitstream: Union[str, Path], - binary_path: Optional[Path] = None, ) -> None: """ Wrapper for eid-xor binary to apply error patterns for the bitstream processing @@ -58,8 +58,11 @@ def eid_xor( """ # find binary - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "eid-xor" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["eid-xor"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["eid-xor"].parent, + ) else: binary = find_binary("eid-xor") diff --git a/ivas_processing_scripts/audiotools/wrappers/esdru.py b/ivas_processing_scripts/audiotools/wrappers/esdru.py index 2f2625b1..b1250296 100755 --- a/ivas_processing_scripts/audiotools/wrappers/esdru.py +++ b/ivas_processing_scripts/audiotools/wrappers/esdru.py @@ -39,6 +39,7 @@ import numpy as np from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES def esdru( @@ -47,7 +48,6 @@ def esdru( sf: Optional[int] = 48000, e_step: Optional[float] = 0.5, seed: Optional[int] = 1, - binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for ESDRU (Ericsson spatial distortion reference unit) Recommendation ITU-T P.811, requires esdru binary @@ -70,9 +70,11 @@ def esdru( output: np.ndarray Output array (16 bit Stereo PCM) """ - - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "esdru" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["esdru"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["esdru"].parent, + ) else: binary = find_binary("esdru") diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 3fc5ff2c..8df44d39 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -43,6 +43,7 @@ from ivas_processing_scripts.audiotools.audio import Audio, ChannelBasedAudio from ivas_processing_scripts.audiotools.audioarray import delay_compensation from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES FILTER_TYPES_REGEX = r"[\n][\s]{3}[A-Z0-9]\w+\s+" @@ -57,7 +58,6 @@ def filter_itu( is_async: Optional[bool] = False, delay: Optional[int] = None, skip_channel: Optional[list[int]] = None, - binary_path: Optional[Path] = None, ) -> np.ndarray: """ Low-pass filter a multi-channel audio array @@ -89,8 +89,11 @@ def filter_itu( Output filtered array """ - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "filter" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["filter"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["filter"].parent, + ) else: binary = find_binary("filter") diff --git a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py index ce00361d..1999e880 100644 --- a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py +++ b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py @@ -37,6 +37,7 @@ from typing import Optional, Union from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("error_patterns") @@ -47,7 +48,6 @@ def gen_patt( error_rate: float, start: Optional[int] = 0, working_dir: Optional[Union[Path, str]] = None, - binary_path: Optional[Path] = None, ) -> None: """ Wrapper for gen-patt binary to create error patterns for the bitstream processing @@ -67,8 +67,11 @@ def gen_patt( """ # find binary - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "gen-patt" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["gen-patt"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["gen-patt"].parent, + ) else: binary = find_binary("gen-patt") diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index 6b619bb4..98a29625 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -32,7 +32,6 @@ from pathlib import Path from tempfile import TemporaryDirectory -from typing import Optional import numpy as np @@ -40,12 +39,12 @@ from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES def masaRenderer( masa: audio.MetadataAssistedSpatialAudio, out_fmt: str, - binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for masaRenderer (from MASA reference software) @@ -63,8 +62,11 @@ def masaRenderer( MASA rendered to out_fmt """ - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "masaRenderer" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["masaRenderer"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["masaRenderer"].parent, + ) else: binary = find_binary("masaRenderer") diff --git a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py index 16dc582d..cf7d00ab 100644 --- a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py +++ b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py @@ -35,6 +35,7 @@ from pathlib import Path from typing import Optional, Union from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES LIST_JBM_PROFILES = range(12) ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("dly_error_profiles") @@ -44,7 +45,6 @@ def validate_network_simulator( error_pattern: Optional[Union[Path, str]] = None, error_profile: Optional[int] = None, n_frames_per_packet: Optional[int] = None, - binary_path: Optional[Path] = None, ) -> None: """ Validate settings for the network simulator @@ -59,8 +59,13 @@ def validate_network_simulator( Number of frames per paket """ - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "networkSimulator_g192" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["networkSimulator_g192"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"][ + "networkSimulator_g192" + ].parent, + ) else: binary = find_binary("networkSimulator_g192") @@ -96,7 +101,6 @@ def network_simulator( out_bitstream: Union[str, Path], n_frames_per_packet: int, offset: int, - binary_path: Optional[Path] = None, ) -> None: """ Wrapper for networkSimulator_g192 binary to apply error patterns for the bitstream processing @@ -116,8 +120,13 @@ def network_simulator( """ # find binary - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "networkSimulator_g192" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["networkSimulator_g192"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"][ + "networkSimulator_g192" + ].parent, + ) else: binary = find_binary("networkSimulator_g192") diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index 36adb137..c51f3fd6 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -32,7 +32,6 @@ from pathlib import Path from tempfile import TemporaryDirectory -from typing import Optional from warnings import warn import numpy as np @@ -41,12 +40,12 @@ from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES def p50fbmnru( input: audio.Audio, q_db: float, - binary_path: Optional[Path] = None, ) -> np.ndarray: """ Wrapper for P.50 Fullband MNRU (Modulated Noise Reference Unit), requires p50fbmnru binary @@ -65,8 +64,11 @@ def p50fbmnru( Output array """ - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "p50fbmnru" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["p50fbmnru"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["p50fbmnru"].parent, + ) else: binary = find_binary("p50fbmnru") diff --git a/ivas_processing_scripts/audiotools/wrappers/random_seed.py b/ivas_processing_scripts/audiotools/wrappers/random_seed.py index 50b3aaf2..9ec41271 100644 --- a/ivas_processing_scripts/audiotools/wrappers/random_seed.py +++ b/ivas_processing_scripts/audiotools/wrappers/random_seed.py @@ -30,17 +30,16 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # -from pathlib import Path from typing import Optional from ivas_processing_scripts.utils import find_binary, run +from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES def random_seed( master_seed: Optional[int] = 0, prerun_seed: Optional[int] = 0, hexa: Optional[bool] = True, - binary_path: Optional[Path] = None, ) -> int: """ @@ -60,8 +59,11 @@ def random_seed( """ # find binary - if binary_path is not None: - binary = find_binary(binary_path.name, binary_path=binary_path.parent) + if "random" in DEFAULT_CONFIG_BINARIES["binary_paths"]: + binary = find_binary( + DEFAULT_CONFIG_BINARIES["binary_paths"]["random"].name, + path=DEFAULT_CONFIG_BINARIES["binary_paths"]["random"].parent, + ) else: binary = find_binary("random") diff --git a/ivas_processing_scripts/binary_paths.yml b/ivas_processing_scripts/binary_paths.yml new file mode 100644 index 00000000..a0ce4f5b --- /dev/null +++ b/ivas_processing_scripts/binary_paths.yml @@ -0,0 +1,30 @@ +--- +################################################ +# Binary paths +################################################ +### Custom binary paths and names can be specified here. +### If not defined here, the binaries in ivas_processing_scripts/bin would be used +### If binaries are neither specified here nor found in the bin folder, the scripts would look for them in $PATH +### DO NOT change the location of this file. +### DO NOT USE relative paths. The paths have to be absolute. +### DO NOT change the default keys. +### For example, if the user has renamed the 'filter' binary to 'foo' then use --> filter: path/to/binary/foo + +# ### Binary for resampling and filtering +# filter: "path/to/binary/filter_new" +# ### Binary for loudness adjustment +# bs1770demo: "path/to/binary/bs1880" +# ### Binary for MNRU +# p50fbmnru: "path/to/binary/p50fbmnru" +# ### Binary for ESDRU +# esdru: "path/to/binary/esdru" +# ### Binary for frame error pattern application +# eid-xor: "path/to/binary/eid-xor" +# ### Binary for error pattern generation +# gen-patt: "path/to/binary/gen-patt" +# ### Binary for random offset/seed generation +# random: "path/to/binary/random" +# ### Binary for JBM network similulator +# networkSimulator_g192: "path/to/binary/networkSimulator_g192" +# ### Binary for MASA rendering +# masaRenderer: "path/to/binary/masaRenderer" \ No newline at end of file diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index ce0c599c..24442443 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -30,9 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # +from pathlib import Path from datetime import datetime -from ivas_processing_scripts.utils import find_binary, get_gitsha +from ivas_processing_scripts.utils import find_binary, get_gitsha, get_binary_paths LOGGER_SUFFIX = ".log" LOGGER_FORMAT = ( @@ -69,7 +70,6 @@ DEFAULT_CONFIG = { "preamble": None, "pad_noise_preamble": False, "metadata_path": None, - "binary_paths": None, # postprocessing "postprocessing": { "hp50": False, @@ -93,6 +93,11 @@ DEFAULT_CONFIG_IVAS = { }, } +DEFAULT_CONFIG_BINARIES = { + "binary_paths": get_binary_paths( + Path(__file__).parent.joinpath("binary_paths.yml") + ), +} REQUIRED_KEYS = [ ("input", {"fmt"}), diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index 5147a370..bea68997 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -41,6 +41,7 @@ from os import devnull from pathlib import Path from shutil import which from typing import Callable, Iterable, Optional, Union +from warnings import warn ALLOWED_INPUT_EXT = (".wav", ".pcm", ".txt") BIN_DIR = Path(__file__).parent.joinpath("bin") @@ -287,9 +288,10 @@ def progressbar(iter: Iterable, width=80): print("\n", flush=True, file=sys.stdout) -def get_binary_paths(obj, binary_path): - with open(binary_path, "r") as f: +def get_binary_paths(yaml_file_with_binary_paths): + with open(yaml_file_with_binary_paths, "r") as f: data = yaml.safe_load(f) - for key, value in data.items(): - p = Path(value) - setattr(obj, key + "_binary_path", p) + if data is None: + return {} + else: + return {key: Path(value) for key, value in data.items()} -- GitLab From cc15bbc9c4a7210e0fd151aef33d0f1f1f250fe1 Mon Sep 17 00:00:00 2001 From: veeravt Date: Tue, 25 Apr 2023 12:14:30 +0200 Subject: [PATCH 4/7] Changed formatting. --- ivas_processing_scripts/__init__.py | 5 +---- ivas_processing_scripts/audiotools/wrappers/bs1770.py | 2 +- ivas_processing_scripts/audiotools/wrappers/eid_xor.py | 2 +- ivas_processing_scripts/audiotools/wrappers/esdru.py | 2 +- ivas_processing_scripts/audiotools/wrappers/filter.py | 2 +- ivas_processing_scripts/audiotools/wrappers/gen_patt.py | 2 +- ivas_processing_scripts/audiotools/wrappers/masaRenderer.py | 2 +- .../audiotools/wrappers/networkSimulator.py | 2 +- ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py | 2 +- ivas_processing_scripts/audiotools/wrappers/random_seed.py | 2 +- ivas_processing_scripts/constants.py | 4 ++-- ivas_processing_scripts/utils.py | 3 ++- 12 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 563b6697..5fedfc32 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -50,10 +50,7 @@ from ivas_processing_scripts.processing.processing import ( process_item, reorder_items_list, ) -from ivas_processing_scripts.utils import ( - DirManager, - apply_func_parallel, -) +from ivas_processing_scripts.utils import DirManager, apply_func_parallel def logging_init(args, cfg): diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index afffe283..4934d568 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -42,8 +42,8 @@ import numpy as np from ivas_processing_scripts.audiotools import audio, convert from ivas_processing_scripts.audiotools.audiofile import write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu -from ivas_processing_scripts.utils import find_binary, get_devnull, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, get_devnull, run logger = logging.getLogger("__main__") logger.setLevel(logging.DEBUG) diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index bb5cc5d0..f1aff87d 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -35,8 +35,8 @@ from pathlib import Path from typing import Optional, Union from ivas_processing_scripts.audiotools.wrappers.gen_patt import create_error_pattern -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run def eid_xor( diff --git a/ivas_processing_scripts/audiotools/wrappers/esdru.py b/ivas_processing_scripts/audiotools/wrappers/esdru.py index b1250296..b66e3d9e 100755 --- a/ivas_processing_scripts/audiotools/wrappers/esdru.py +++ b/ivas_processing_scripts/audiotools/wrappers/esdru.py @@ -38,8 +38,8 @@ import numpy as np from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run def esdru( diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 8df44d39..5c8d0922 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -42,8 +42,8 @@ import numpy as np from ivas_processing_scripts.audiotools.audio import Audio, ChannelBasedAudio from ivas_processing_scripts.audiotools.audioarray import delay_compensation from ivas_processing_scripts.audiotools.audiofile import read, write -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run FILTER_TYPES_REGEX = r"[\n][\s]{3}[A-Z0-9]\w+\s+" diff --git a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py index 1999e880..d59f6ce6 100644 --- a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py +++ b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py @@ -36,8 +36,8 @@ from tempfile import TemporaryDirectory from typing import Optional, Union from ivas_processing_scripts.audiotools.wrappers.random_seed import random_seed -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("error_patterns") diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index 98a29625..0ae799c2 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -38,8 +38,8 @@ import numpy as np from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run def masaRenderer( diff --git a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py index cf7d00ab..bb491824 100644 --- a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py +++ b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py @@ -34,8 +34,8 @@ import os.path from pathlib import Path from typing import Optional, Union -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run LIST_JBM_PROFILES = range(12) ERROR_PATTERNS_DIR = Path(__file__).parent.parent.parent.joinpath("dly_error_profiles") diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index c51f3fd6..099f996a 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -39,8 +39,8 @@ import numpy as np from ivas_processing_scripts.audiotools import audio from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.audiotools.wrappers.filter import resample_itu -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run def p50fbmnru( diff --git a/ivas_processing_scripts/audiotools/wrappers/random_seed.py b/ivas_processing_scripts/audiotools/wrappers/random_seed.py index 9ec41271..1fe04346 100644 --- a/ivas_processing_scripts/audiotools/wrappers/random_seed.py +++ b/ivas_processing_scripts/audiotools/wrappers/random_seed.py @@ -32,8 +32,8 @@ from typing import Optional -from ivas_processing_scripts.utils import find_binary, run from ivas_processing_scripts.constants import DEFAULT_CONFIG_BINARIES +from ivas_processing_scripts.utils import find_binary, run def random_seed( diff --git a/ivas_processing_scripts/constants.py b/ivas_processing_scripts/constants.py index 24442443..50ebd198 100755 --- a/ivas_processing_scripts/constants.py +++ b/ivas_processing_scripts/constants.py @@ -30,10 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # -from pathlib import Path from datetime import datetime +from pathlib import Path -from ivas_processing_scripts.utils import find_binary, get_gitsha, get_binary_paths +from ivas_processing_scripts.utils import find_binary, get_binary_paths, get_gitsha LOGGER_SUFFIX = ".log" LOGGER_FORMAT = ( diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index bea68997..69358638 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -34,7 +34,6 @@ import logging import shutil import subprocess as sp import sys -import yaml from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor from itertools import repeat, tee from os import devnull @@ -43,6 +42,8 @@ from shutil import which from typing import Callable, Iterable, Optional, Union from warnings import warn +import yaml + ALLOWED_INPUT_EXT = (".wav", ".pcm", ".txt") BIN_DIR = Path(__file__).parent.joinpath("bin") -- GitLab From d20c9fec7ae98fb4e8afb817c7194d43fa736956 Mon Sep 17 00:00:00 2001 From: veeravt Date: Tue, 25 Apr 2023 12:20:22 +0200 Subject: [PATCH 5/7] Fixed linitng error. --- ivas_processing_scripts/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index 69358638..73eda4a8 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -40,7 +40,6 @@ from os import devnull from pathlib import Path from shutil import which from typing import Callable, Iterable, Optional, Union -from warnings import warn import yaml -- GitLab From 4da7e05b8b8a15cac3baeb0ee8f509a0afe64a3a Mon Sep 17 00:00:00 2001 From: veeravt Date: Tue, 25 Apr 2023 15:52:20 +0200 Subject: [PATCH 6/7] Changed the wrong argument. --- ivas_processing_scripts/audiotools/wrappers/bs1770.py | 2 +- ivas_processing_scripts/audiotools/wrappers/eid_xor.py | 2 +- ivas_processing_scripts/audiotools/wrappers/esdru.py | 2 +- ivas_processing_scripts/audiotools/wrappers/filter.py | 2 +- ivas_processing_scripts/audiotools/wrappers/gen_patt.py | 2 +- ivas_processing_scripts/audiotools/wrappers/masaRenderer.py | 2 +- .../audiotools/wrappers/networkSimulator.py | 4 ++-- ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py | 2 +- ivas_processing_scripts/audiotools/wrappers/random_seed.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index 4934d568..fe756c07 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -76,7 +76,7 @@ def bs1770demo( if "bs1770demo" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["bs1770demo"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["bs1770demo"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["bs1770demo"].parent, ) else: binary = find_binary("bs1770demo") diff --git a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py index f1aff87d..86075b95 100644 --- a/ivas_processing_scripts/audiotools/wrappers/eid_xor.py +++ b/ivas_processing_scripts/audiotools/wrappers/eid_xor.py @@ -61,7 +61,7 @@ def eid_xor( if "eid-xor" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["eid-xor"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["eid-xor"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["eid-xor"].parent, ) else: binary = find_binary("eid-xor") diff --git a/ivas_processing_scripts/audiotools/wrappers/esdru.py b/ivas_processing_scripts/audiotools/wrappers/esdru.py index b66e3d9e..10c1719c 100755 --- a/ivas_processing_scripts/audiotools/wrappers/esdru.py +++ b/ivas_processing_scripts/audiotools/wrappers/esdru.py @@ -73,7 +73,7 @@ def esdru( if "esdru" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["esdru"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["esdru"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["esdru"].parent, ) else: binary = find_binary("esdru") diff --git a/ivas_processing_scripts/audiotools/wrappers/filter.py b/ivas_processing_scripts/audiotools/wrappers/filter.py index 5c8d0922..9be95758 100755 --- a/ivas_processing_scripts/audiotools/wrappers/filter.py +++ b/ivas_processing_scripts/audiotools/wrappers/filter.py @@ -92,7 +92,7 @@ def filter_itu( if "filter" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["filter"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["filter"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["filter"].parent, ) else: binary = find_binary("filter") diff --git a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py index d59f6ce6..3b17120b 100644 --- a/ivas_processing_scripts/audiotools/wrappers/gen_patt.py +++ b/ivas_processing_scripts/audiotools/wrappers/gen_patt.py @@ -70,7 +70,7 @@ def gen_patt( if "gen-patt" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["gen-patt"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["gen-patt"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["gen-patt"].parent, ) else: binary = find_binary("gen-patt") diff --git a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py index 0ae799c2..ed0c3013 100755 --- a/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py +++ b/ivas_processing_scripts/audiotools/wrappers/masaRenderer.py @@ -65,7 +65,7 @@ def masaRenderer( if "masaRenderer" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["masaRenderer"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["masaRenderer"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["masaRenderer"].parent, ) else: binary = find_binary("masaRenderer") diff --git a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py index bb491824..dec25a8e 100644 --- a/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py +++ b/ivas_processing_scripts/audiotools/wrappers/networkSimulator.py @@ -62,7 +62,7 @@ def validate_network_simulator( if "networkSimulator_g192" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["networkSimulator_g192"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"][ + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"][ "networkSimulator_g192" ].parent, ) @@ -123,7 +123,7 @@ def network_simulator( if "networkSimulator_g192" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["networkSimulator_g192"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"][ + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"][ "networkSimulator_g192" ].parent, ) diff --git a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py index 099f996a..4bc6b046 100755 --- a/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py +++ b/ivas_processing_scripts/audiotools/wrappers/p50fbmnru.py @@ -67,7 +67,7 @@ def p50fbmnru( if "p50fbmnru" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["p50fbmnru"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["p50fbmnru"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["p50fbmnru"].parent, ) else: binary = find_binary("p50fbmnru") diff --git a/ivas_processing_scripts/audiotools/wrappers/random_seed.py b/ivas_processing_scripts/audiotools/wrappers/random_seed.py index 1fe04346..2ef48952 100644 --- a/ivas_processing_scripts/audiotools/wrappers/random_seed.py +++ b/ivas_processing_scripts/audiotools/wrappers/random_seed.py @@ -62,7 +62,7 @@ def random_seed( if "random" in DEFAULT_CONFIG_BINARIES["binary_paths"]: binary = find_binary( DEFAULT_CONFIG_BINARIES["binary_paths"]["random"].name, - path=DEFAULT_CONFIG_BINARIES["binary_paths"]["random"].parent, + binary_path=DEFAULT_CONFIG_BINARIES["binary_paths"]["random"].parent, ) else: binary = find_binary("random") -- GitLab From 1168f452069df156f62275d132e4c8a73774967a Mon Sep 17 00:00:00 2001 From: veeravt Date: Tue, 25 Apr 2023 16:02:29 +0200 Subject: [PATCH 7/7] Made chanegs to resolve merge conflicts. --- examples/TEMPLATE.yml | 58 ++++++++++++++++++++------------ ivas_processing_scripts/utils.py | 2 +- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index 51ce44d0..441250ae 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -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) @@ -49,19 +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 -### Specify the filename with extension. -### For example, concatenation_order: ["file3.wav", "file1.wav", "file4.wav", "file2.wav"] -# 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 ################################################ @@ -72,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 @@ -98,6 +83,33 @@ input: # delay: 20 ### 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 + ### Specify the filename with extension. + ### For example, concatenation_order: ["file3.wav", "file1.wav", "file4.wav", "file2.wav"] + # 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 @@ -107,7 +119,7 @@ input: ### can be given globally here or in individual conditions of type ivas or evs # tx: ### REQUIRED: Type of bitstream processing; possible types: "JBM" or "FER" - #type: "JBM" + # type: "JBM" ### JBM ### REQUIRED: either error_pattern or error_profile @@ -124,6 +136,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 @@ -211,7 +225,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 @@ -246,8 +260,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) diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index 73eda4a8..1e21b0db 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -43,7 +43,7 @@ from typing import Callable, Iterable, Optional, Union import yaml -ALLOWED_INPUT_EXT = (".wav", ".pcm", ".txt") +ALLOWED_INPUT_EXT = (".wav", ".pcm", ".txt", ".raw") BIN_DIR = Path(__file__).parent.joinpath("bin") -- GitLab