Loading ivas_processing_scripts/constants.py +1 −16 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ DEFAULT_CONFIG = { "date": f"{datetime.now().strftime('%Y%m%d_%H.%M.%S')}", "git_sha": f"{get_gitsha()}", "multiprocessing": True, "use_windows_codec_binaries": True, "delete_tmp": False, "master_seed": 0, "prerun_seed": 0, Loading @@ -69,22 +70,6 @@ DEFAULT_CONFIG = { }, "condition_in_output_filename": False, } DEFAULT_CONFIG_EVS = { "cod": { "bin": find_binary("EVS_cod", raise_error=False), }, "dec": { "bin": find_binary("EVS_dec", raise_error=False), }, } DEFAULT_CONFIG_IVAS = { "cod": { "bin": find_binary("IVAS_cod", raise_error=False), }, "dec": { "bin": find_binary("IVAS_dec", raise_error=False), }, } DEFAULT_CONFIG_BINARIES = { "binary_paths": get_binary_paths( Loading ivas_processing_scripts/processing/chains.py +2 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,7 @@ def get_processing_chain( "preamble": preamble, "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb, "sba_fmt": cond_cfg.get("sba_fmt", tmp_in_fmt), "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) Loading Loading @@ -408,6 +409,7 @@ def get_processing_chain( "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": preamble, "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) Loading ivas_processing_scripts/processing/config.py +28 −7 Original line number Diff line number Diff line Loading @@ -34,11 +34,10 @@ from copy import deepcopy from pathlib import Path import yaml import platform from ivas_processing_scripts.constants import ( DEFAULT_CONFIG, DEFAULT_CONFIG_EVS, DEFAULT_CONFIG_IVAS, REQUIRED_KEYS, REQUIRED_KEYS_ESDRU, REQUIRED_KEYS_EVS, Loading @@ -46,7 +45,7 @@ from ivas_processing_scripts.constants import ( REQUIRED_KEYS_MNRU, SUPPORTED_CONDITIONS, ) from ivas_processing_scripts.utils import get_abs_path from ivas_processing_scripts.utils import get_abs_path, find_binary def merge_dicts(base: dict, other: dict) -> None: Loading @@ -64,6 +63,21 @@ def merge_dicts(base: dict, other: dict) -> None: base[k] = other[k] def get_default_config_for_codecs(codec_name: str, ext_with_dot: str = "") -> dict: cod_bin = f"{codec_name}_cod{ext_with_dot}" dec_bin = f"{codec_name}_dec{ext_with_dot}" cfg = { "cod": { "bin": find_binary(cod_bin, raise_error=False), }, "dec": { "bin": find_binary(dec_bin, raise_error=False), }, } return cfg class TestConfig: # avoid confusion with pytest tests due to naming __test__ = False Loading @@ -82,10 +96,11 @@ class TestConfig: file_cfg = self._parse_yaml(filename) # validate configuration from file self._validate(file_cfg) self._validate_file_cfg(file_cfg, cfg["use_windows_codec_binaries"]) # merge dictionaries, overriding from config file merge_dicts(cfg, file_cfg) self._validate_merged_config(cfg) # set attributes from merged dictionary self.__dict__.update(cfg) Loading Loading @@ -117,7 +132,7 @@ class TestConfig: return cfg def _validate(self, cfg: dict): def _validate_file_cfg(self, cfg: dict, use_windows_codec_binaries: bool): """ensure configuration contains required keys""" MISSING_KEYS = [] # check required keys Loading Loading @@ -170,6 +185,7 @@ class TestConfig: "Background noise file has to be placed outside the input folder!" ) codec_bin_extension = ".exe" if platform.system() == "Linux" and use_windows_codec_binaries else "" for cond_name, cond_cfg in cfg.get("conditions_to_generate").items(): type = cond_cfg.get("type") if not type: Loading @@ -181,7 +197,7 @@ class TestConfig: f"Condition type {cond_cfg.get('type')} is unsuported! Must be one of '{SUPPORTED_CONDITIONS}'" ) elif type == "evs": merged_cfg = deepcopy(DEFAULT_CONFIG_EVS) merged_cfg = get_default_config_for_codecs("EVS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_EVS.difference( Loading @@ -191,7 +207,7 @@ class TestConfig: f"The following key(s) must be specified for EVS: {REQUIRED_KEYS_EVS}" ) elif type == "ivas": merged_cfg = deepcopy(DEFAULT_CONFIG_IVAS) merged_cfg = get_default_config_for_codecs("IVAS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_IVAS.difference( Loading @@ -214,3 +230,8 @@ class TestConfig: raise KeyError( f"The following key must be specified for ESDRU: {REQUIRED_KEYS_ESDRU}" ) def _validate_merged_config(self, cfg: dict): # if not on windows, but "use_windows_codec_binaries" is given, assure that wine is there if platform.system() == "Linux" and cfg["use_windows_codec_binaries"] and find_binary("wine") is None: raise FileNotFoundError("Using windows binaries on Linux requires wine") No newline at end of file ivas_processing_scripts/processing/evs.py +8 −2 Original line number Diff line number Diff line Loading @@ -64,12 +64,14 @@ class EVS(Processing): self.name = "evs" self.in_fmt = audio.fromtype(self.in_fmt) self._validate() self._use_wine = platform.system() == "Linux" and self.use_windows_codec_binaries def _validate( self, ): need_exe_suffix = platform.system() == "Windows" or self.use_windows_codec_binaries if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") Loading @@ -78,7 +80,7 @@ class EVS(Processing): "The EVS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") Loading Loading @@ -286,6 +288,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.cod_bin] if self._use_wine: cmd.insert(0, "wine") # in case of LFE 9.6 kbps NB processing strip any "-max_band XX" from cmd.extend and amend by "-max_band NB" if proc_chan_lfe_9k6bps_nb is True: Loading Loading @@ -381,6 +385,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.dec_bin] if self._use_wine: cmd.insert(0, "wine") if self.dec_opts: cmd.extend(self.dec_opts) Loading ivas_processing_scripts/processing/ivas.py +9 −2 Original line number Diff line number Diff line Loading @@ -60,10 +60,12 @@ class IVAS(Processing): self.out_fmt = audio.fromtype(self.out_fmt) if not hasattr(self, "dec_opts"): self.dec_opts = None self._use_wine = platform.system() == "Linux" and self.use_windows_codec_binaries def _validate(self): need_exe_suffix = platform.system() == "Windows" or self.use_windows_codec_binaries if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") Loading @@ -72,7 +74,7 @@ class IVAS(Processing): "The IVAS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") Loading Loading @@ -181,6 +183,8 @@ class IVAS(Processing): raise ValueError(f"IVAS: invalid audio input extension: {in_file.suffix}") cmd = [self.cod_bin] if self._use_wine: cmd.insert(0, "wine") if self.cod_opts: cmd.extend(self.cod_opts) Loading Loading @@ -272,6 +276,9 @@ class IVAS(Processing): logger.debug(f"IVAS decoder {bitstream} -> {out_file}") cmd = [self.dec_bin] if self._use_wine: cmd.insert(0, "wine") if hasattr(self, "trajectory"): cmd.extend(["-T", self.trajectory]) Loading Loading
ivas_processing_scripts/constants.py +1 −16 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ DEFAULT_CONFIG = { "date": f"{datetime.now().strftime('%Y%m%d_%H.%M.%S')}", "git_sha": f"{get_gitsha()}", "multiprocessing": True, "use_windows_codec_binaries": True, "delete_tmp": False, "master_seed": 0, "prerun_seed": 0, Loading @@ -69,22 +70,6 @@ DEFAULT_CONFIG = { }, "condition_in_output_filename": False, } DEFAULT_CONFIG_EVS = { "cod": { "bin": find_binary("EVS_cod", raise_error=False), }, "dec": { "bin": find_binary("EVS_dec", raise_error=False), }, } DEFAULT_CONFIG_IVAS = { "cod": { "bin": find_binary("IVAS_cod", raise_error=False), }, "dec": { "bin": find_binary("IVAS_dec", raise_error=False), }, } DEFAULT_CONFIG_BINARIES = { "binary_paths": get_binary_paths( Loading
ivas_processing_scripts/processing/chains.py +2 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,7 @@ def get_processing_chain( "preamble": preamble, "evs_lfe_9k6bps_nb": evs_lfe_9k6bps_nb, "sba_fmt": cond_cfg.get("sba_fmt", tmp_in_fmt), "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) Loading Loading @@ -408,6 +409,7 @@ def get_processing_chain( "multiprocessing": cfg.multiprocessing, "tx": tx_cfg, "preamble": preamble, "use_windows_codec_binaries": cfg.use_windows_codec_binaries, } ) ) Loading
ivas_processing_scripts/processing/config.py +28 −7 Original line number Diff line number Diff line Loading @@ -34,11 +34,10 @@ from copy import deepcopy from pathlib import Path import yaml import platform from ivas_processing_scripts.constants import ( DEFAULT_CONFIG, DEFAULT_CONFIG_EVS, DEFAULT_CONFIG_IVAS, REQUIRED_KEYS, REQUIRED_KEYS_ESDRU, REQUIRED_KEYS_EVS, Loading @@ -46,7 +45,7 @@ from ivas_processing_scripts.constants import ( REQUIRED_KEYS_MNRU, SUPPORTED_CONDITIONS, ) from ivas_processing_scripts.utils import get_abs_path from ivas_processing_scripts.utils import get_abs_path, find_binary def merge_dicts(base: dict, other: dict) -> None: Loading @@ -64,6 +63,21 @@ def merge_dicts(base: dict, other: dict) -> None: base[k] = other[k] def get_default_config_for_codecs(codec_name: str, ext_with_dot: str = "") -> dict: cod_bin = f"{codec_name}_cod{ext_with_dot}" dec_bin = f"{codec_name}_dec{ext_with_dot}" cfg = { "cod": { "bin": find_binary(cod_bin, raise_error=False), }, "dec": { "bin": find_binary(dec_bin, raise_error=False), }, } return cfg class TestConfig: # avoid confusion with pytest tests due to naming __test__ = False Loading @@ -82,10 +96,11 @@ class TestConfig: file_cfg = self._parse_yaml(filename) # validate configuration from file self._validate(file_cfg) self._validate_file_cfg(file_cfg, cfg["use_windows_codec_binaries"]) # merge dictionaries, overriding from config file merge_dicts(cfg, file_cfg) self._validate_merged_config(cfg) # set attributes from merged dictionary self.__dict__.update(cfg) Loading Loading @@ -117,7 +132,7 @@ class TestConfig: return cfg def _validate(self, cfg: dict): def _validate_file_cfg(self, cfg: dict, use_windows_codec_binaries: bool): """ensure configuration contains required keys""" MISSING_KEYS = [] # check required keys Loading Loading @@ -170,6 +185,7 @@ class TestConfig: "Background noise file has to be placed outside the input folder!" ) codec_bin_extension = ".exe" if platform.system() == "Linux" and use_windows_codec_binaries else "" for cond_name, cond_cfg in cfg.get("conditions_to_generate").items(): type = cond_cfg.get("type") if not type: Loading @@ -181,7 +197,7 @@ class TestConfig: f"Condition type {cond_cfg.get('type')} is unsuported! Must be one of '{SUPPORTED_CONDITIONS}'" ) elif type == "evs": merged_cfg = deepcopy(DEFAULT_CONFIG_EVS) merged_cfg = get_default_config_for_codecs("EVS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_EVS.difference( Loading @@ -191,7 +207,7 @@ class TestConfig: f"The following key(s) must be specified for EVS: {REQUIRED_KEYS_EVS}" ) elif type == "ivas": merged_cfg = deepcopy(DEFAULT_CONFIG_IVAS) merged_cfg = get_default_config_for_codecs("IVAS", codec_bin_extension) merge_dicts(merged_cfg, cond_cfg) cfg["conditions_to_generate"][cond_name] = merged_cfg if REQUIRED_KEYS_IVAS.difference( Loading @@ -214,3 +230,8 @@ class TestConfig: raise KeyError( f"The following key must be specified for ESDRU: {REQUIRED_KEYS_ESDRU}" ) def _validate_merged_config(self, cfg: dict): # if not on windows, but "use_windows_codec_binaries" is given, assure that wine is there if platform.system() == "Linux" and cfg["use_windows_codec_binaries"] and find_binary("wine") is None: raise FileNotFoundError("Using windows binaries on Linux requires wine") No newline at end of file
ivas_processing_scripts/processing/evs.py +8 −2 Original line number Diff line number Diff line Loading @@ -64,12 +64,14 @@ class EVS(Processing): self.name = "evs" self.in_fmt = audio.fromtype(self.in_fmt) self._validate() self._use_wine = platform.system() == "Linux" and self.use_windows_codec_binaries def _validate( self, ): need_exe_suffix = platform.system() == "Windows" or self.use_windows_codec_binaries if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") Loading @@ -78,7 +80,7 @@ class EVS(Processing): "The EVS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") Loading Loading @@ -286,6 +288,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.cod_bin] if self._use_wine: cmd.insert(0, "wine") # in case of LFE 9.6 kbps NB processing strip any "-max_band XX" from cmd.extend and amend by "-max_band NB" if proc_chan_lfe_9k6bps_nb is True: Loading Loading @@ -381,6 +385,8 @@ class EVS(Processing): logger: Optional[logging.Logger] = None, ) -> None: cmd = [self.dec_bin] if self._use_wine: cmd.insert(0, "wine") if self.dec_opts: cmd.extend(self.dec_opts) Loading
ivas_processing_scripts/processing/ivas.py +9 −2 Original line number Diff line number Diff line Loading @@ -60,10 +60,12 @@ class IVAS(Processing): self.out_fmt = audio.fromtype(self.out_fmt) if not hasattr(self, "dec_opts"): self.dec_opts = None self._use_wine = platform.system() == "Linux" and self.use_windows_codec_binaries def _validate(self): need_exe_suffix = platform.system() == "Windows" or self.use_windows_codec_binaries if not self.cod_bin or not Path(self.cod_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.cod_bin and Path(self.cod_bin).with_suffix(".exe").exists() ): self.cod_bin = Path(self.cod_bin).with_suffix(".exe") Loading @@ -72,7 +74,7 @@ class IVAS(Processing): "The IVAS encoder binary was not found! Please check the configuration." ) if not self.dec_bin or not Path(self.dec_bin).exists(): if platform.system() == "Windows" and ( if need_exe_suffix and ( self.dec_bin and Path(self.dec_bin).with_suffix(".exe").exists() ): self.dec_bin = Path(self.dec_bin).with_suffix(".exe") Loading Loading @@ -181,6 +183,8 @@ class IVAS(Processing): raise ValueError(f"IVAS: invalid audio input extension: {in_file.suffix}") cmd = [self.cod_bin] if self._use_wine: cmd.insert(0, "wine") if self.cod_opts: cmd.extend(self.cod_opts) Loading Loading @@ -272,6 +276,9 @@ class IVAS(Processing): logger.debug(f"IVAS decoder {bitstream} -> {out_file}") cmd = [self.dec_bin] if self._use_wine: cmd.insert(0, "wine") if hasattr(self, "trajectory"): cmd.extend(["-T", self.trajectory]) Loading