Commit bc8e76c9 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

relative path available for input, output, executables, background noise and error patterns

parent 7c6aa734
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
# ### 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"
gen-patt: ".\\ivas_processing_scripts\\bin\\bla\\gen-patt"
# ### Binary for random offset/seed generation
# random: "path/to/binary/random"
# ### Binary for JBM network similulator
+20 −6
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#

from typing import Optional
from pathlib import Path

from ivas_processing_scripts.processing.config import TestConfig
from ivas_processing_scripts.processing.evs import EVS
@@ -79,7 +80,7 @@ def init_processing_chains(cfg: TestConfig) -> None:

    # list items in input directory
    cfg.items_list = list_audio(
        cfg.input_path, absolute=False, select_list=getattr(cfg, "input_select", None)
        cfg.input_path, select_list=getattr(cfg, "input_select", None)
    )
    if not cfg.items_list:
        raise SystemExit(
@@ -133,9 +134,14 @@ def get_preprocessing_2(cfg: TestConfig) -> dict:
    pre2_cfg = cfg.preprocessing_2
    background_cfg = pre2_cfg.get("background_noise", None)
    if background_cfg:
        if background_cfg.get("background_noise_path", None) is not None:
            background_noise = Path(background_cfg.get("background_noise_path", None)).resolve()
        else:
            background_noise = None

        background = {
            "snr": background_cfg.get("snr", None),
            "background_noise_path": background_cfg.get("background_noise_path", None),
            "background_noise_path": background_noise,
            "seed_delay": background_cfg.get("seed_delay", 0),
            "master_seed": cfg.master_seed,
            "output_fmt": cfg.postprocessing["fmt"],
@@ -246,11 +252,15 @@ def get_processing_chain(
                tx_cfg_tmp = cond_cfg["tx"]
            else:
                tx_cfg_tmp = cfg.tx
            if tx_cfg_tmp.get("error_pattern", None) is not None:
                error_pattern = Path(tx_cfg_tmp.get("error_pattern", None)).resolve()
            else:
                error_pattern = None

            if tx_cfg_tmp.get("type", None) == "FER":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": error_pattern,
                    "error_rate": tx_cfg_tmp.get("error_rate", None),
                    "master_seed": cfg.master_seed,
                    "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0),
@@ -258,7 +268,7 @@ def get_processing_chain(
            elif tx_cfg_tmp.get("type", None) == "JBM":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": error_pattern,
                    "error_profile": tx_cfg_tmp.get("error_profile", None),
                    "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None),
                }
@@ -305,11 +315,15 @@ def get_processing_chain(
                tx_cfg_tmp = cond_cfg["tx"]
            else:
                tx_cfg_tmp = cfg.tx
            if tx_cfg_tmp.get("error_pattern", None) is not None:
                error_pattern = Path(tx_cfg_tmp.get("error_pattern", None)).resolve()
            else:
                error_pattern = None

            if tx_cfg_tmp.get("type", None) == "FER":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": error_pattern,
                    "error_rate": tx_cfg_tmp.get("error_rate", None),
                    "master_seed": cfg.master_seed,
                    "prerun_seed": tx_cfg_tmp.get("prerun_seed", 0),
@@ -317,7 +331,7 @@ def get_processing_chain(
            elif tx_cfg_tmp.get("type", None) == "JBM":
                tx_cfg = {
                    "type": tx_cfg_tmp.get("type", None),
                    "error_pattern": tx_cfg_tmp.get("error_pattern", None),
                    "error_pattern": error_pattern,
                    "error_profile": tx_cfg_tmp.get("error_profile", None),
                    "n_frames_per_packet": tx_cfg_tmp.get("n_frames_per_packet", None),
                }
+2 −2
Original line number Diff line number Diff line
@@ -90,8 +90,8 @@ class TestConfig:
        self._yaml_dump = self._dump_yaml(cfg)

        # convert to Path
        self.input_path = Path(self.input_path)
        self.output_path = Path(self.output_path)
        self.input_path = Path(self.input_path).resolve()
        self.output_path = Path(self.output_path).resolve()

    def _parse_yaml(self, filename):
        """parse configuration file"""
+3 −3
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ def preprocess(cfg, logger):

    # update the configuration to use preprocessing outputs as new inputs
    cfg.items_list = list_audio(
        cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None)
        cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None)
    )

    # Re-ordering items based on concatenation order
@@ -274,7 +274,7 @@ def preprocess_2(cfg, logger):

    # update the configuration to use preprocessing 2 outputs as new inputs
    cfg.items_list = list_audio(
        cfg.out_dirs[0], absolute=False, select_list=getattr(cfg, "input_select", None)
        cfg.out_dirs[0], select_list=getattr(cfg, "input_select", None)
    )

    # Re-ordering items based on concatenation order
@@ -313,7 +313,7 @@ def reverse_process_2(cfg, logger):
        # if no concatenation read files from folder
        out_paths_splits = []
        for out_dir in cfg.out_dirs:
            list_audio_dir = list_audio(out_dir, absolute=True)
            list_audio_dir = list_audio(out_dir)
            out_paths_splits.append(list_audio_dir)
        if cfg.postprocessing["fmt"].startswith("ISM"):
            out_meta_splits = []
+6 −14
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ class DirManager:
                )


def list_audio(path: str, absolute: bool = False, select_list: list = None) -> list:
def list_audio(path: str, select_list: list = None) -> list:
    """
    Return list with all files with ALLOWED_INPUT_EXT found under the given path.

@@ -105,21 +105,13 @@ def list_audio(path: str, absolute: bool = False, select_list: list = None) -> l

    if path.exists():
        if path.is_dir():
            if absolute:
                [audio_list.extend(list(path.glob(ext))) for ext in ALLOWED_INPUT_EXT]
            audio_list = [
                    path.joinpath(f)
                    for f in path.iterdir()
                    if f.suffix in ALLOWED_INPUT_EXT
                ]
            else:
                audio_list = [
                    f for f in path.iterdir() if f.suffix in ALLOWED_INPUT_EXT
                f.resolve() for f in path.iterdir() if f.suffix in ALLOWED_INPUT_EXT
            ]
        else:
            ext = path.suffix
            if ext in ALLOWED_INPUT_EXT:
                audio_list.append(path)
                audio_list.append(path.resolve())

    # filter according to select list
    if select_list:
@@ -166,7 +158,7 @@ def find_binary(
    else:
        if logger:
            logger.debug(f"Found binary {bin}")
        return Path(bin)
        return Path(bin).resolve()


def get_devnull():