diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fc552bf75518c5e66af4ab4128062b1e01a8888..1eeca599605bdaf5d37562e2af8fde1d5c8bf35f 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/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 77c9590541b736392559d11afd47775969dea52d..f0bf5e413461241f7de6e40479d253a4ef543971 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/audiotools/wrappers/bs1770.py b/ivas_processing_scripts/audiotools/wrappers/bs1770.py index f8052bc41b940576bef4ac0732f5f1318f21514c..a808b2e6ccb1bd36c53d112dd5a7125646b44f4d 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}" ) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 717377535c2d290fa0ca6d1bff20faa5e628fc15..2d21d665896dcd258b7840f4ec57b9a7abcdb5fd 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() diff --git a/tests/constants.py b/tests/constants.py index 589714fdb32f5bd48f1beb6f738c3d3368326978..6dbae9ed4fd7de41b0d71a4b63bff722659e1192 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 51d50e635c56683043b94f0d6c119eb28b5ca059..e22e84e802f355ebefbf6d531caf260f2500457e 100644 --- a/tests/test_experiments.py +++ b/tests/test_experiments.py @@ -39,20 +39,22 @@ 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, ) HERE = Path(__file__).parent.absolute() 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() @@ -66,29 +68,25 @@ 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[:-4] + 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