Commit c03ac513 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

Merge branch 'background_noise_modification' into 'main'

Background noise modification

See merge request !23
parents a25aa301 989878fb
Loading
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ conditions_to_generate:
          bin: ~/git/ivas-codec/IVAS_dec
postprocessing:
    fmt: "BINAURAL"
	fs: 48000
```

</details>
@@ -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
```

</details>
@@ -220,6 +216,37 @@ input:

</details>

### Optional pre-processing on whole signal(s)

<details>
<summary>Click to expand</summary>

```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
```

</details>

### Bitstream processing

<details>
@@ -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
```
</details>

@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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
+10 −8
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@

import logging
from pathlib import Path
from warnings import warn

import numpy as np

@@ -104,6 +103,9 @@ class Preprocessing2(Processing):
        range_delay = (1, 2400000)

        # load background noise
        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"],
@@ -115,7 +117,7 @@ class Preprocessing2(Processing):
        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"
            )

Loading