diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml index 65bf5bc58d07feab0fc73e5cdfba2944dcb8b983..c6151e6a607d1d65a55f617b6dc403cda1dec2e6 100755 --- a/examples/TEMPLATE.yml +++ b/examples/TEMPLATE.yml @@ -114,6 +114,10 @@ input: ### the individual items (concatenate_input: false) after previous pre-processing step ### Horizontally concatenate input items into one long file; default = false # concatenate_input: true + ### if concatenation is applied, the following two keys can be used to add zeros before or after the items + ### duration is specified in miliseconds + # silence_pre: 2000 + # silence_post: 2000 ### Specify the concatenation order in a list of strings. If not specified, the concatenation order would be ### as per the filesystem on the users' device ### Should only be used if concatenate_input = true diff --git a/ivas_processing_scripts/audiotools/audiofile.py b/ivas_processing_scripts/audiotools/audiofile.py index fa3ef05d28b6dbd34a28f9a6cfe28f8d68805990..44ef2abc9e123f2784bf629bfa85f868e07b40e5 100755 --- a/ivas_processing_scripts/audiotools/audiofile.py +++ b/ivas_processing_scripts/audiotools/audiofile.py @@ -166,8 +166,8 @@ def write( def concat( in_filenames: list, out_file: str, - silence_pre: Optional[int] = 0, - silence_post: Optional[int] = 0, + silence_pre: int = 0, + silence_post: int = 0, in_fs: Optional[int] = 48000, num_channels: Optional[int] = None, pad_noise: Optional[bool] = False, diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py index 21b20a0e4dbdcf33fccc738d159290f0dd6a1605..fadcebbb08a38d4f56429ecc63f53e92ba60791f 100755 --- a/ivas_processing_scripts/processing/chains.py +++ b/ivas_processing_scripts/processing/chains.py @@ -201,6 +201,8 @@ def get_preprocessing_2(cfg: TestConfig) -> dict: "in_mask": pre2_cfg.get("mask", None), "multiprocessing": cfg.multiprocessing, "repeat_signal": pre2_cfg.get("repeat_signal", False), + "silence_pre": pre2_cfg.get("silence_pre", 0), + "silence_post": pre2_cfg.get("silence_post", 0), } ) ) diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index 4d96571f5d10059e214de6f46d3ae4cfbb06c8ce..35c44fdaae16c68a603345db54c72a009b4ab2d9 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -163,11 +163,25 @@ def concat_setup(cfg: TestConfig, chain, logger: logging.Logger): tmp_audio = audio.fromtype(cfg_pre2.in_fmt) tmp_num_chans = tmp_audio.num_channels + # convert from milisecs to samples + silence_pre = 0 + silence_post = 0 + if cfg_pre2.silence_pre != 0 or silence_post != 0: + if cfg_pre2.in_fs is None: + raise ValueError( + "silence_pre and silence_post can only be non-zero if you provide the sampling rate in the input section!" + ) + + silence_pre = int(cfg_pre2.silence_pre / 1000 * cfg_pre2.in_fs) + silence_post = int(cfg_pre2.silence_post / 1000 * cfg_pre2.in_fs) + cfg.splits, fs = concat( cfg.items_list, cfg.concat_file, in_fs=cfg_pre2.in_fs, num_channels=tmp_num_chans, + silence_pre=silence_pre, + silence_post=silence_post, ) # save item naming for splits naming in the end