| Index: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
|
| diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/noise_generation.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
|
| similarity index 86%
|
| rename from webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/noise_generation.py
|
| rename to webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
|
| index 090d3506ab8cb78bb319083a90d706fa9469e652..9f4df941ad6e26f8cdb117debb44ee457f3192d8 100644
|
| --- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/noise_generation.py
|
| +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
|
| @@ -6,19 +6,19 @@
|
| # in the file PATENTS. All contributing project authors may
|
| # be found in the AUTHORS file in the root of the source tree.
|
|
|
| -"""Noise generators producing pairs of signals intended to be used to test the
|
| - APM module. Each pair consists of a noisy and a reference signal. The former
|
| - is used as input for APM, and it is generated by adding noise to a signal.
|
| - The reference is the expected APM output when using the generated input.
|
| +"""Test data generators producing signals pairs intended to be used to
|
| +test the APM module. Each pair consists of a noisy input and a reference signal.
|
| +The former is used as APM input and it is generated by adding noise to a
|
| +clean audio track. The reference is the expected APM output.
|
|
|
| - Throughout this file, the following naming convention is used:
|
| +Throughout this file, the following naming convention is used:
|
| - input signal: the clean signal (e.g., speech),
|
| - noise signal: the noise to be summed up to the input signal (e.g., white
|
| noise, Gaussian noise),
|
| - noisy signal: input + noise.
|
| - The noise signal may or may not be a function of the clean signal. For
|
| - instance, white noise is independently generated, whereas reverberation is
|
| - obtained by convolving the input signal with an impulse response.
|
| +The noise signal may or may not be a function of the clean signal. For
|
| +instance, white noise is independently generated, whereas reverberation is
|
| +obtained by convolving the input signal with an impulse response.
|
| """
|
|
|
| import logging
|
| @@ -36,7 +36,7 @@ from . import exceptions
|
| from . import signal_processing
|
|
|
|
|
| -class NoiseGenerator(object):
|
| +class TestDataGenerator(object):
|
| """Abstract class responsible for the generation of noisy signals.
|
|
|
| Given a clean signal, it generates two streams named noisy signal and
|
| @@ -46,17 +46,15 @@ class NoiseGenerator(object):
|
| expected at the output of the APM module when the latter is fed with the nosiy
|
| signal.
|
|
|
| - A noise generator generates one or more input-reference pairs.
|
| -
|
| - TODO(alessiob): Rename from NoiseGenerator to InputReferencePairGenerator.
|
| + An test data generator generates one or more pairs.
|
| """
|
|
|
| NAME = None
|
| REGISTERED_CLASSES = {}
|
|
|
| def __init__(self):
|
| - # Init dictionaries with one entry for each noise generator configuration
|
| - # (e.g., different SNRs).
|
| + # Init dictionaries with one entry for each test data generator
|
| + # configuration (e.g., different SNRs).
|
| # Noisy audio track files (stored separately in a cache folder).
|
| self._noisy_signal_filepaths = None
|
| # Path to be used for the APM simulation output files.
|
| @@ -67,13 +65,14 @@ class NoiseGenerator(object):
|
|
|
| @classmethod
|
| def RegisterClass(cls, class_to_register):
|
| - """Registers an NoiseGenerator implementation.
|
| + """Registers an TestDataGenerator implementation.
|
|
|
| - Decorator to automatically register the classes that extend NoiseGenerator.
|
| + Decorator to automatically register the classes that extend
|
| + TestDataGenerator.
|
| Example usage:
|
|
|
| - @NoiseGenerator.RegisterClass
|
| - class IdentityGenerator(NoiseGenerator):
|
| + @TestDataGenerator.RegisterClass
|
| + class IdentityGenerator(TestDataGenerator):
|
| pass
|
| """
|
| cls.REGISTERED_CLASSES[class_to_register.NAME] = class_to_register
|
| @@ -165,21 +164,21 @@ class NoiseGenerator(object):
|
| reference_signal_filepath)
|
|
|
| # Save noisy and reference file paths.
|
| - data_access.Metadata.SaveAudioInRefPaths(
|
| + data_access.Metadata.SaveAudioTestDataPaths(
|
| output_path=output_path,
|
| audio_in_filepath=self._noisy_signal_filepaths[config_name],
|
| audio_ref_filepath=self._reference_signal_filepaths[config_name])
|
|
|
| @classmethod
|
| - def _MakeDir(cls, base_output_path, noise_generator_config_name):
|
| - output_path = os.path.join(base_output_path, noise_generator_config_name)
|
| + def _MakeDir(cls, base_output_path, test_data_generator_config_name):
|
| + output_path = os.path.join(
|
| + base_output_path, test_data_generator_config_name)
|
| data_access.MakeDirectory(output_path)
|
| return output_path
|
|
|
|
|
| -# Identity generator.
|
| -@NoiseGenerator.RegisterClass
|
| -class IdentityGenerator(NoiseGenerator):
|
| +@TestDataGenerator.RegisterClass
|
| +class IdentityTestDataGenerator(TestDataGenerator):
|
| """Generator that adds no noise.
|
|
|
| Both the noisy and the reference signals are the input signal.
|
| @@ -188,7 +187,7 @@ class IdentityGenerator(NoiseGenerator):
|
| NAME = 'identity'
|
|
|
| def __init__(self):
|
| - NoiseGenerator.__init__(self)
|
| + TestDataGenerator.__init__(self)
|
|
|
| def _Generate(
|
| self, input_signal_filepath, input_noise_cache_path, base_output_path):
|
| @@ -201,12 +200,12 @@ class IdentityGenerator(NoiseGenerator):
|
| output_path=output_path)
|
|
|
|
|
| -@NoiseGenerator.RegisterClass
|
| -class WhiteNoiseGenerator(NoiseGenerator):
|
| - """Additive white noise generator.
|
| +@TestDataGenerator.RegisterClass
|
| +class WhiteNoiseTestDataGenerator(TestDataGenerator):
|
| + """Generator that adds white noise.
|
| """
|
|
|
| - NAME = 'white'
|
| + NAME = 'white_noise'
|
|
|
| # Each pair indicates the clean vs. noisy and reference vs. noisy SNRs.
|
| # The reference (second value of each pair) always has a lower amount of noise
|
| @@ -221,7 +220,7 @@ class WhiteNoiseGenerator(NoiseGenerator):
|
| _NOISY_SIGNAL_FILENAME_TEMPLATE = 'noise_{0:d}_SNR.wav'
|
|
|
| def __init__(self):
|
| - NoiseGenerator.__init__(self)
|
| + TestDataGenerator.__init__(self)
|
|
|
| def _Generate(
|
| self, input_signal_filepath, input_noise_cache_path, base_output_path):
|
| @@ -270,15 +269,15 @@ class WhiteNoiseGenerator(NoiseGenerator):
|
|
|
|
|
| # TODO(alessiob): remove comment when class implemented.
|
| -# @NoiseGenerator.RegisterClass
|
| -class NarrowBandNoiseGenerator(NoiseGenerator):
|
| - """Additive narrow-band noise generator.
|
| +# @TestDataGenerator.RegisterClass
|
| +class NarrowBandNoiseTestDataGenerator(TestDataGenerator):
|
| + """Generator that adds narrow-band noise.
|
| """
|
|
|
| - NAME = 'narrow_band'
|
| + NAME = 'narrow_band_noise'
|
|
|
| def __init__(self):
|
| - NoiseGenerator.__init__(self)
|
| + TestDataGenerator.__init__(self)
|
|
|
| def _Generate(
|
| self, input_signal_filepath, input_noise_cache_path, base_output_path):
|
| @@ -286,19 +285,22 @@ class NarrowBandNoiseGenerator(NoiseGenerator):
|
| pass
|
|
|
|
|
| -@NoiseGenerator.RegisterClass
|
| -class EnvironmentalNoiseGenerator(NoiseGenerator):
|
| - """Additive environmental noise generator.
|
| +@TestDataGenerator.RegisterClass
|
| +class EnvironmentalNoiseTestDataGenerator(TestDataGenerator):
|
| + """Generator that adds environmental noise.
|
| +
|
| + TODO(alessiob): Make the class more generic e.g.,
|
| + MixNoiseTrackTestDataGenerator.
|
| """
|
|
|
| - NAME = 'environmental'
|
| + NAME = 'environmental_noise'
|
| _NOISY_SIGNAL_FILENAME_TEMPLATE = '{0}_{1:d}_SNR.wav'
|
|
|
| # TODO(alessiob): allow the user to store the noise tracks in a custom path.
|
| _NOISE_TRACKS_PATH = os.path.join(os.getcwd(), 'noise_tracks')
|
|
|
| # TODO(alessiob): allow the user to have custom noise tracks.
|
| - # TODO(alessiob): exploit NoiseGeneratorFactory.GetInstance().
|
| + # TODO(alessiob): exploit TestDataGeneratorFactory.GetInstance().
|
| _NOISE_TRACKS = [
|
| 'city.wav'
|
| ]
|
| @@ -314,11 +316,11 @@ class EnvironmentalNoiseGenerator(NoiseGenerator):
|
| ]
|
|
|
| def __init__(self):
|
| - NoiseGenerator.__init__(self)
|
| + TestDataGenerator.__init__(self)
|
|
|
| def _Generate(
|
| self, input_signal_filepath, input_noise_cache_path, base_output_path):
|
| - """Generates environmental noise.
|
| + """Generates test data pairs using environmental noise.
|
|
|
| For each noise track and pair of SNR values, the following two audio tracks
|
| are created: the noisy signal and the reference signal. The former is
|
| @@ -374,14 +376,16 @@ class EnvironmentalNoiseGenerator(NoiseGenerator):
|
| base_output_path, noisy_mix_filepaths, self._SNR_VALUE_PAIRS)
|
|
|
|
|
| -@NoiseGenerator.RegisterClass
|
| -class EchoNoiseGenerator(NoiseGenerator):
|
| - """Echo noise generator.
|
| +@TestDataGenerator.RegisterClass
|
| +class ReverberationTestDataGenerator(TestDataGenerator):
|
| + """Generator that adds reverberation noise.
|
|
|
| - TODO(alessiob): Rename from echo to reverberation.
|
| + TODO(alessiob): Make this class more generic since the impulse response can be
|
| + anything (not just reverberation); call it e.g.,
|
| + ConvolutionalNoiseTestDataGenerator.
|
| """
|
|
|
| - NAME = 'echo'
|
| + NAME = 'reverberation'
|
|
|
| _IMPULSE_RESPONSES = {
|
| 'lecture': 'air_binaural_lecture_0_0_1.mat', # Long echo.
|
| @@ -401,12 +405,12 @@ class EchoNoiseGenerator(NoiseGenerator):
|
| _NOISY_SIGNAL_FILENAME_TEMPLATE = '{0}_{1:d}_SNR.wav'
|
|
|
| def __init__(self, aechen_ir_database_path):
|
| - NoiseGenerator.__init__(self)
|
| + TestDataGenerator.__init__(self)
|
| self._aechen_ir_database_path = aechen_ir_database_path
|
|
|
| def _Generate(
|
| self, input_signal_filepath, input_noise_cache_path, base_output_path):
|
| - """Generates echo noise.
|
| + """Generates test data pairs using reverberation noise.
|
|
|
| For each impulse response, one noise track is created. For each impulse
|
| response and pair of SNR values, the following 2 audio tracks are
|
|
|