From dabf07f2572c99e812bbd75259671400a5d46cea Mon Sep 17 00:00:00 2001 From: Treffehn Date: Fri, 16 Jun 2023 12:22:06 +0200 Subject: [PATCH 1/6] changed warning to error, might fail pipeline tests --- ivas_processing_scripts/audiotools/wrappers/bs1770.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivas_processing_scripts/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index f8052bc4..a808b2e6 100755 --- a/ivas_processing_scripts/audiotools/wrappers/bs1770.py +++ b/ivas_processing_scripts/audiotools/wrappers/bs1770.py @@ -291,7 +291,7 @@ def loudness_norm( ) if num_iter >= 10: - warn( + raise ValueError( f"Loudness did not converge to desired value, stopping at: {loudness_after:.2f}" ) -- GitLab From be1cbdb0d28c8d640bf80ff6cac00023ae497071 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 16 Jun 2023 16:35:53 +0200 Subject: [PATCH 2/6] use testvectors from codec in test --- .gitlab-ci.yml | 6 ++++++ tests/constants.py | 14 +++++++++++++ tests/test_experiments.py | 42 +++++++++++++++++++-------------------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fc552bf..1eeca599 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,11 @@ stages: - make -j - cd $dir +.get-codec-testvectors: &get-codec-testvectors + - to_dir=$(pwd)/tests/data/testv + - mkdir -p $to_dir + - from_dir=$CODEC_DIR/scripts/testv + - cp $from_dir/*.wav $to_dir/ # ------------------------------------ # check pre-conditions are met @@ -82,6 +87,7 @@ experiments: script: - *print-common-info - *get-codec-binaries + - *get-codec-testvectors - python3 -m pytest tests/test_experiments.py::test_generate_test_items -n auto | tee log.txt artifacts: paths: diff --git a/tests/constants.py b/tests/constants.py index 589714fd..6dbae9ed 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -36,6 +36,7 @@ from pathlib import PurePath """ Set up paths """ TESTS_DIR = PurePath(__file__).parent TEST_VECTOR_DIR = TESTS_DIR.joinpath("data") +CODEC_TEST_VECTOR_DIR = TEST_VECTOR_DIR.joinpath("testv") EXPERIMENTS_DIR = "../experiments/selection" ISM_METADATA_DIR = TEST_VECTOR_DIR.joinpath("ism_metadata") @@ -84,6 +85,19 @@ NCHAN_TO_FILE = { 16: TEST_VECTOR_DIR.joinpath("spectral").joinpath("spectral_test_16ch_48kHz.wav"), } +NCHAN_TO_TESTV = { + 1: CODEC_TEST_VECTOR_DIR.joinpath("stv48c.wav"), + 2: CODEC_TEST_VECTOR_DIR.joinpath("stvST48c.wav"), + 3: CODEC_TEST_VECTOR_DIR.joinpath("stv3ISM48s.wav"), + 4: CODEC_TEST_VECTOR_DIR.joinpath("stv4ISM48n.wav"), + 6: CODEC_TEST_VECTOR_DIR.joinpath("stv51MC48c.wav"), + 8: CODEC_TEST_VECTOR_DIR.joinpath("stv71MC48.wav"), + 9: CODEC_TEST_VECTOR_DIR.joinpath("stv2OA48c.wav"), + 10: CODEC_TEST_VECTOR_DIR.joinpath("stv514MC48c.wav"), + 12: CODEC_TEST_VECTOR_DIR.joinpath("stv714MC48c.wav"), + 16: CODEC_TEST_VECTOR_DIR.joinpath("stv3OA48c.wav"), +} + FORMAT_TO_FILE = { "MONO": NCHAN_TO_FILE[1], "STEREO": NCHAN_TO_FILE[2], diff --git a/tests/test_experiments.py b/tests/test_experiments.py index 51d50e63..f029dfe3 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -47,6 +47,7 @@ from tests.constants import ( INPUT_EXPERIMENT_NAMES, LAB_IDS_FOR_EXPERIMENTS, NCHAN_TO_FILE, + NCHAN_TO_TESTV, ) HERE = Path(__file__).parent.absolute() @@ -54,6 +55,9 @@ sys.path.append(HERE.parent) from generate_test import Arguments, create_experiment_setup # NOQA +N_INPUT_SIGNALS = 2 + + def setup_input_files_for_config(config): input_path = Path(config.input_path).resolve().absolute() input_fmt = config.input["fmt"] @@ -66,29 +70,23 @@ def setup_input_files_for_config(config): if not input_path.exists(): raise ValueError("Input path from experiments config does not exist") - # get dummy input files: - spectral_dummy = NCHAN_TO_FILE[num_channels] - pink_noise_dummy = Path( - str(spectral_dummy).replace("spectral/spectral_test", "pinknoise/pink_noise") - ) - dummy_input_files = [spectral_dummy, pink_noise_dummy] - - # get dummy metadata files - dummy_md_files = FORMAT_TO_METADATA_FILES.get(input_fmt, list()) - - # copy input files + # get testvector for format and create to one-second items from it files_copied = list() - for f in dummy_input_files: - f_out = input_path.joinpath(f.name).resolve().absolute() - # need at least 2s of input files for gen-patt to be happy (can not keep the tolerance for 50 frames only) - concat([str(f)] * 2, str(f_out)) - for i, md_f in enumerate(dummy_md_files): - suffix = f"{i}.csv" + testv_file = NCHAN_TO_TESTV[num_channels] + testv_signal, fs = read(testv_file) + assert fs == 48000 + for i in range(N_INPUT_SIGNALS): + f_out = input_path.joinpath(testv_file.name).with_suffix(f".{i}.wav").resolve().absolute() + write(f_out, testv_signal[i * 48000 : (i + 1) * 48000, :]) + files_copied.append(f_out.name) + + # get dummy metadata files + dummy_md_files = FORMAT_TO_METADATA_FILES.get(input_fmt, list()) + for j, md_f in enumerate(dummy_md_files): + suffix = f"{j}.csv" md_f_out = ".".join([str(f_out), suffix]) shutil.copy(md_f, md_f_out) - files_copied.append(f_out.name) - # create background noise files with white noise if "background_noise" in config.preprocessing_2: # always set the same seed to have reproducible test noises @@ -143,7 +141,7 @@ def test_generate_test_items(exp_lab_pair): config.preprocessing_2["concatenation_order"] = sorted(input_filenames) config.to_file(cfg) - generate_test(args) + # generate_test(args) - if not all_lengths_equal(config): - raise RuntimeError("Unequal lengths between input and output files detected") + # if not all_lengths_equal(config): + # raise RuntimeError("Unequal lengths between input and output files detected") -- GitLab From d1474a55a1f8b5201f196e7cbd2d6c9f52b105b4 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 16 Jun 2023 16:39:06 +0200 Subject: [PATCH 3/6] uncomment accidentally commented code --- tests/test_experiments.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_experiments.py b/tests/test_experiments.py index f029dfe3..8df852c6 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -141,7 +141,7 @@ def test_generate_test_items(exp_lab_pair): config.preprocessing_2["concatenation_order"] = sorted(input_filenames) config.to_file(cfg) - # generate_test(args) + generate_test(args) - # if not all_lengths_equal(config): - # raise RuntimeError("Unequal lengths between input and output files detected") + if not all_lengths_equal(config): + raise RuntimeError("Unequal lengths between input and output files detected") -- GitLab From ec75754f301b506412780511101ca433f6482a81 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 16 Jun 2023 17:04:02 +0200 Subject: [PATCH 4/6] fix file naming --- tests/test_experiments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_experiments.py b/tests/test_experiments.py index 8df852c6..0b7151fc 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -76,7 +76,7 @@ def setup_input_files_for_config(config): testv_signal, fs = read(testv_file) assert fs == 48000 for i in range(N_INPUT_SIGNALS): - f_out = input_path.joinpath(testv_file.name).with_suffix(f".{i}.wav").resolve().absolute() + f_out = input_path.joinpath(testv_file.name[:-4] + f"_{i}.wav").resolve().absolute() write(f_out, testv_signal[i * 48000 : (i + 1) * 48000, :]) files_copied.append(f_out.name) -- GitLab From ab6fa4efced6ae09580a12ff9d77db4ea1ecccd8 Mon Sep 17 00:00:00 2001 From: Treffehn Date: Fri, 16 Jun 2023 17:08:29 +0200 Subject: [PATCH 5/6] added results.get to get exceptions from subprocess --- ivas_processing_scripts/__init__.py | 1 + ivas_processing_scripts/processing/processing.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 77c95905..f0bf5e41 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -187,6 +187,7 @@ def main(args): sleep(0.1) progressbar_update(count, count, width) print("\n", flush=True, file=sys.stdout) + results.get() p.close() p.join() diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 71737753..2d21d665 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -270,6 +270,7 @@ def preprocess(cfg, logger): sleep(0.1) progressbar_update(count, count, width) print("\n", flush=True, file=sys.stdout) + results.get() p.close() p.join() @@ -341,6 +342,7 @@ def preprocess_2(cfg, logger): sleep(0.1) progressbar_update(count, count, width) print("\n", flush=True, file=sys.stdout) + results.get() p.close() p.join() -- GitLab From 0d7a14f60007af5ae0e52305a2ccb14f1889855a Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 16 Jun 2023 17:27:04 +0200 Subject: [PATCH 6/6] fix formatting and linter complaints --- tests/test_experiments.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_experiments.py b/tests/test_experiments.py index 0b7151fc..e22e84e8 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -39,22 +39,20 @@ from numpy.random import random, seed from ivas_processing_scripts import main as generate_test from ivas_processing_scripts.audiotools import audio -from ivas_processing_scripts.audiotools.audiofile import concat, read, write +from ivas_processing_scripts.audiotools.audiofile import read, write from ivas_processing_scripts.processing.config import TestConfig from ivas_processing_scripts.utils import list_audio from tests.constants import ( FORMAT_TO_METADATA_FILES, INPUT_EXPERIMENT_NAMES, LAB_IDS_FOR_EXPERIMENTS, - NCHAN_TO_FILE, - NCHAN_TO_TESTV, + NCHAN_TO_TESTV, ) HERE = Path(__file__).parent.absolute() sys.path.append(HERE.parent) from generate_test import Arguments, create_experiment_setup # NOQA - N_INPUT_SIGNALS = 2 @@ -76,7 +74,9 @@ def setup_input_files_for_config(config): testv_signal, fs = read(testv_file) assert fs == 48000 for i in range(N_INPUT_SIGNALS): - f_out = input_path.joinpath(testv_file.name[:-4] + f"_{i}.wav").resolve().absolute() + f_out = ( + input_path.joinpath(testv_file.name[:-4] + f"_{i}.wav").resolve().absolute() + ) write(f_out, testv_signal[i * 48000 : (i + 1) * 48000, :]) files_copied.append(f_out.name) -- GitLab