diff --git a/README.md b/README.md
index d70343e2366a7d862098e97a777583ff5eb07b5e..d3635cca246be3296a52dfe5e1209ae5ecb950cf 100755
--- a/README.md
+++ b/README.md
@@ -108,6 +108,7 @@ conditions_to_generate:
bin: ~/git/ivas-codec/IVAS_dec
postprocessing:
fmt: "BINAURAL"
+ fs: 48000
```
@@ -130,6 +131,8 @@ postprocessing:
### Deletion of temporary directories containing
### intermediate processing files, bitstreams etc.; default = false
# delete_tmp: true
+### Master seed for random processes like bitstream error pattern generation; default = 0
+# master_seed: 5
### Any relative paths will be interpreted relative to the working directory the script is called from!
### Usage of absolute paths is recommended.
@@ -160,13 +163,6 @@ output_path: "./tmp_output"
### searches for the specified substring in found filenames; default = null
# input_select:
# - "48kHz"
-
-### Horizontally concatenate input items into one long file; default = false
-# concatenate_input: true
-### Specify preamble duration in ms; default = 0
-# preamble: 40
-### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence)
-# pad_noise_preamble: true
```
@@ -220,6 +216,37 @@ input:
+### Optional pre-processing on whole signal(s)
+
+
+Click to expand
+
+```yaml
+# preprocessing_2:
+ ### Options for processing of the concatenated item (concatenate_input: true) or
+ ### the individual items (concatenate_input: false) after previous pre-processing step
+ ### Horizontally concatenate input items into one long file; default = false
+ # concatenate_input: true
+ ### 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
+ # concatenation_order: []
+ ### Specify preamble duration in ms; default = 0
+ # preamble: 10000
+ ### Flag wheter to use noise (amplitude +-4) for the preamble or silence; default = false (silence)
+ # preamble_noise: true
+ ### Additive background noise
+ # background_noise:
+ ### REQUIRED: SNR for background noise in dB
+ # snr: 10
+ ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s)
+ # background_noise_path: ".../noise.wav"
+ ### Seed for delay offest; default = 0
+ # seed_delay: 10
+```
+
+
+
### Bitstream processing
@@ -248,6 +275,8 @@ input:
# error_pattern: "path/pattern.192"
### Error rate in percent
# error_rate: 5
+ ### Additional seed to specify number of preruns; default = 0
+ # prerun_seed: 2
```
@@ -341,7 +370,7 @@ conditions_to_generate:
### Path to decoder binary; default search for IVAS_dec in bin folder (primary) and PATH (secondary)
bin: ~/git/ivas-codec/IVAS_dec
### Decoder output format; default = postprocessing fmt
- fmt: "CICP19"
+ fmt: "7_1_4"
### Decoder output sampling rate; default = null (same as input)
# fs: 48000
### Additional commandline options; default = null
@@ -382,8 +411,8 @@ conditions_to_generate:
postprocessing:
### REQUIRED: Target format for output
fmt: "BINAURAL"
- ### Target sampling rate in Hz for resampling; default = null (no resampling)
- # fs: 16000
+ ### REQUIRED: Target sampling rate in Hz for resampling; default = null (no resampling)
+ fs: 48000
### Low-pass cut-off frequency in Hz; default = null (no filtering)
# lp_cutoff: 24000
### Target loudness in LKFS; default = null (no loudness change applied)
diff --git a/examples/TEMPLATE.yml b/examples/TEMPLATE.yml
index 8b5ecea467ab309ad6c85e7560e0fa8803fc4537..47f6a195247227dfb2cf0e07eba5722ad86c6e06 100755
--- a/examples/TEMPLATE.yml
+++ b/examples/TEMPLATE.yml
@@ -106,7 +106,7 @@ input:
# background_noise:
### REQUIRED: SNR for background noise in dB
# snr: 10
- ### REQUIRED: Path to background noise
+ ### REQUIRED: Path to background noise, must have same format and sampling rate as input signal(s)
# background_noise_path: ".../noise.wav"
### Seed for delay offest; default = 0
# seed_delay: 10
diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py
index 036ddd6b9e9e6631827cb226546cbbbc71ec8496..b4d9c07b48b99b8316769c2f4d122660ba36bbc5 100755
--- a/ivas_processing_scripts/__init__.py
+++ b/ivas_processing_scripts/__init__.py
@@ -45,6 +45,7 @@ from ivas_processing_scripts.processing import chains, config
from ivas_processing_scripts.processing.processing import (
preprocess,
preprocess_2,
+ preprocess_background_noise,
process_item,
reorder_items_list,
reverse_process_2,
@@ -127,12 +128,18 @@ def main(args):
# run preprocessing only once
if hasattr(cfg, "preprocessing"):
+ # save process info for background noise
+ cfg.pre = cfg.proc_chains[0]["processes"][0]
preprocess(cfg, logger)
# preprocessing on whole signal(s)
if hasattr(cfg, "preprocessing_2"):
# save process info to revert it later
cfg.pre2 = cfg.proc_chains[0]["processes"][0]
+ # preprocess background noise
+ if hasattr(cfg, "preprocessing") and hasattr(cfg.pre2, "background_noise"):
+ preprocess_background_noise(cfg)
+ # preprocess 2
preprocess_2(cfg, logger)
# run conditions
diff --git a/ivas_processing_scripts/processing/chains.py b/ivas_processing_scripts/processing/chains.py
index db5df6ab7d00a9b285d3d896bcdceee661d354fb..e4f4a69ff70ef9689468268d484f185fb980b3af 100755
--- a/ivas_processing_scripts/processing/chains.py
+++ b/ivas_processing_scripts/processing/chains.py
@@ -139,6 +139,7 @@ def get_preprocessing_2(cfg: TestConfig) -> dict:
"seed_delay": background_cfg.get("seed_delay", 0),
"master_seed": cfg.master_seed,
"output_fmt": cfg.postprocessing["fmt"],
+ "background_object": None,
}
else:
background = None
diff --git a/ivas_processing_scripts/processing/preprocessing_2.py b/ivas_processing_scripts/processing/preprocessing_2.py
index 425dbd23cb20b4c8731823872741c4d3f3f072f5..0bacc8eeb6580fe8f05db7355a0839fc475c45a3 100644
--- a/ivas_processing_scripts/processing/preprocessing_2.py
+++ b/ivas_processing_scripts/processing/preprocessing_2.py
@@ -32,7 +32,6 @@
import logging
from pathlib import Path
-from warnings import warn
import numpy as np
@@ -104,18 +103,21 @@ class Preprocessing2(Processing):
range_delay = (1, 2400000)
# load background noise
- noise_object = audio.fromfile(
- self.in_fmt,
- self.background_noise["background_noise_path"],
- fs=self.in_fs,
- in_meta=in_meta,
- )
+ if self.background_noise["background_object"] is not None:
+ noise_object = self.background_noise["background_object"]
+ else:
+ noise_object = audio.fromfile(
+ self.in_fmt,
+ self.background_noise["background_noise_path"],
+ fs=self.in_fs,
+ in_meta=in_meta,
+ )
# if noise is too short raise error
if len(noise_object.audio) < len(audio_object.audio):
raise ValueError("Background noise too short for audio signal")
if len(noise_object.audio) - range_delay[1] < len(audio_object.audio):
- warn(
+ raise ValueError(
"Background noise may be to short for audio signal when considering the random delay"
)
diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py
index 4b367606abf120a0ebd97aa3635b36c9ea5b42b6..a4fcb2fff3f7bf4d12d1878b9b7b662d056fcd47 100755
--- a/ivas_processing_scripts/processing/processing.py
+++ b/ivas_processing_scripts/processing/processing.py
@@ -48,6 +48,7 @@ from ivas_processing_scripts.audiotools.audiofile import (
trim,
write,
)
+from ivas_processing_scripts.audiotools.convert.__init__ import convert
from ivas_processing_scripts.audiotools.metadata import (
add_remove_preamble,
concat_meta_from_file,
@@ -453,3 +454,36 @@ def remove_preamble(cfg):
write(path_input, x, fs)
return
+
+
+def preprocess_background_noise(cfg):
+ # TODO: add checks and errors for sampling rate and number channels compared to input signals
+ # create audio objects
+ input_audio = audio.fromfile(
+ cfg.input["fmt"],
+ cfg.pre2.background_noise["background_noise_path"],
+ fs=cfg.input.get("fs", None),
+ )
+ output_audio = audio.fromtype(cfg.pre.out_fmt)
+ output_audio.fs = input_audio.fs
+ if cfg.pre.out_fs is None:
+ out_fs = input_audio.fs
+ else:
+ out_fs = cfg.pre.out_fs
+
+ # only consider format conversion, resampling and high-pass filtering
+ convert(
+ input=input_audio,
+ output=output_audio,
+ in_fs=input_audio.fs,
+ out_fs=out_fs,
+ in_hp50=cfg.pre.in_hp50,
+ )
+
+ # save result in cfg
+ # cfg.preprocessing_2["background_noise"].update({"background_object": output_audio})
+ cfg.proc_chains[0]["processes"][0].background_noise[
+ "background_object"
+ ] = output_audio
+
+ return