Loading ivas_processing_scripts/processing/processing.py +3 −3 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ def process_item( copyfile(ppm, out_meta[idx]) def remove_preamble( def remove_pre_and_postamble( x, out_fmt, fs, repeat_signal, preamble_len_ms, postamble_len_ms, meta, logger ): # remove preamble for ISM metadata Loading @@ -417,18 +417,18 @@ def remove_preamble( # get number of samples to cut from start trim_len_samples = (preamble_len_ms * fs) // 1000 postamble_len_samples = (postamble_len_ms * fs) // 1000 if repeat_signal: if logger: logger.debug("Remove first half of signal") # need to subtract the postamble length before getting half of signal length - it was added after concatenation postamble_len_samples = (postamble_len_ms * fs) // 1000 trim_len_samples += (len(x) - postamble_len_samples) // 2 if trim_len_samples > 0 and logger: logger.debug("Remove preamble") x = trim(x, fs, (trim_len_samples, 0), samples=True) x = trim(x, fs, (trim_len_samples, postamble_len_samples), samples=True) return x, meta Loading ivas_processing_scripts/processing/processing_splitting_scaling.py +3 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import loudness_norm from ivas_processing_scripts.processing.processing import ( Processing, concat_teardown, remove_preamble, remove_pre_and_postamble, ) # Loading Loading @@ -191,8 +191,8 @@ class Processing_splitting_scaling(Processing): self, x, fs, in_file, out_file, in_meta, noerror=False, logger=None ): # remove preamble and first half of signal due to repetition if self.preamble or self.repeat_signal: x, in_meta = remove_preamble( if self.preamble or self.postamble or self.repeat_signal: x, in_meta = remove_pre_and_postamble( x, self.out_fmt, self.fs, Loading tests/test_experiments.py +7 −10 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ 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.utils import list_audio from ivas_processing_scripts.audiotools.audiofile import concat, write, read from ivas_processing_scripts.processing.config import TestConfig from tests.constants import ( Loading Loading @@ -99,19 +100,18 @@ def setup_input_files_for_config(config): def all_lengths_equal(cfg): input_files = cfg.items_list output_folder = cfg.output_path all_lengths_equal = True for condition in cfg.conditions_to_generate.keys(): output_condition_folder = output_folder.joinpath(condition) for input_file in input_files: output_file = output_condition_folder.joinpath(input_file.name) in_signal = read(input_file) out_signal = read(output_file) for input_file in list_audio(cfg.input_path): output_file = output_condition_folder.joinpath(input_file.name).with_suffix(f".{condition}.wav") in_signal, _ = read(input_file) out_signal, _ = read(output_file) shapes_equal = in_signal.shape == out_signal.shape if not shapes_equal: print("Unequal file length for {input_file.name} in condition {condition}") print(f"Unequal file length for {input_file.name} in condition {condition}") all_lengths_equal = False return all_lengths_equal Loading @@ -128,11 +128,8 @@ def test_generate_test_items(exp_lab_pair): args = Arguments(str(cfg)) config = TestConfig(cfg) # patch key to make checking for same input and output file length easier config.condition_in_output_filename = False setup_input_files_for_config(config) generate_test(args) if not all_lengths_equal(cfg): if not all_lengths_equal(config): raise RuntimeError("Unequal lengths between input and output files detected") Loading
ivas_processing_scripts/processing/processing.py +3 −3 Original line number Diff line number Diff line Loading @@ -402,7 +402,7 @@ def process_item( copyfile(ppm, out_meta[idx]) def remove_preamble( def remove_pre_and_postamble( x, out_fmt, fs, repeat_signal, preamble_len_ms, postamble_len_ms, meta, logger ): # remove preamble for ISM metadata Loading @@ -417,18 +417,18 @@ def remove_preamble( # get number of samples to cut from start trim_len_samples = (preamble_len_ms * fs) // 1000 postamble_len_samples = (postamble_len_ms * fs) // 1000 if repeat_signal: if logger: logger.debug("Remove first half of signal") # need to subtract the postamble length before getting half of signal length - it was added after concatenation postamble_len_samples = (postamble_len_ms * fs) // 1000 trim_len_samples += (len(x) - postamble_len_samples) // 2 if trim_len_samples > 0 and logger: logger.debug("Remove preamble") x = trim(x, fs, (trim_len_samples, 0), samples=True) x = trim(x, fs, (trim_len_samples, postamble_len_samples), samples=True) return x, meta Loading
ivas_processing_scripts/processing/processing_splitting_scaling.py +3 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ from ivas_processing_scripts.audiotools.wrappers.bs1770 import loudness_norm from ivas_processing_scripts.processing.processing import ( Processing, concat_teardown, remove_preamble, remove_pre_and_postamble, ) # Loading Loading @@ -191,8 +191,8 @@ class Processing_splitting_scaling(Processing): self, x, fs, in_file, out_file, in_meta, noerror=False, logger=None ): # remove preamble and first half of signal due to repetition if self.preamble or self.repeat_signal: x, in_meta = remove_preamble( if self.preamble or self.postamble or self.repeat_signal: x, in_meta = remove_pre_and_postamble( x, self.out_fmt, self.fs, Loading
tests/test_experiments.py +7 −10 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ 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.utils import list_audio from ivas_processing_scripts.audiotools.audiofile import concat, write, read from ivas_processing_scripts.processing.config import TestConfig from tests.constants import ( Loading Loading @@ -99,19 +100,18 @@ def setup_input_files_for_config(config): def all_lengths_equal(cfg): input_files = cfg.items_list output_folder = cfg.output_path all_lengths_equal = True for condition in cfg.conditions_to_generate.keys(): output_condition_folder = output_folder.joinpath(condition) for input_file in input_files: output_file = output_condition_folder.joinpath(input_file.name) in_signal = read(input_file) out_signal = read(output_file) for input_file in list_audio(cfg.input_path): output_file = output_condition_folder.joinpath(input_file.name).with_suffix(f".{condition}.wav") in_signal, _ = read(input_file) out_signal, _ = read(output_file) shapes_equal = in_signal.shape == out_signal.shape if not shapes_equal: print("Unequal file length for {input_file.name} in condition {condition}") print(f"Unequal file length for {input_file.name} in condition {condition}") all_lengths_equal = False return all_lengths_equal Loading @@ -128,11 +128,8 @@ def test_generate_test_items(exp_lab_pair): args = Arguments(str(cfg)) config = TestConfig(cfg) # patch key to make checking for same input and output file length easier config.condition_in_output_filename = False setup_input_files_for_config(config) generate_test(args) if not all_lengths_equal(cfg): if not all_lengths_equal(config): raise RuntimeError("Unequal lengths between input and output files detected")