| Index: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/simulation.py
|
| diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/simulation.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/simulation.py
|
| index ce73e65709e3ee47df9bad6b5a7cc7dfb90276b4..9ed0d4317c55aa5942d33749342541c5c6c6ed66 100644
|
| --- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/simulation.py
|
| +++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/simulation.py
|
| @@ -17,15 +17,16 @@ from . import data_access
|
| from . import eval_scores
|
| from . import eval_scores_factory
|
| from . import evaluation
|
| -from . import noise_generation
|
| -from . import noise_generation_factory
|
| +from . import test_data_generation
|
| +from . import test_data_generation_factory
|
|
|
|
|
| class ApmModuleSimulator(object):
|
| """APM module simulator class.
|
| """
|
|
|
| - _NOISE_GENERATOR_CLASSES = noise_generation.NoiseGenerator.REGISTERED_CLASSES
|
| + _TEST_DATA_GENERATOR_CLASSES = (
|
| + test_data_generation.TestDataGenerator.REGISTERED_CLASSES)
|
| _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES
|
|
|
| def __init__(self, aechen_ir_database_path, polqa_tool_path):
|
| @@ -34,8 +35,8 @@ class ApmModuleSimulator(object):
|
| self._evaluator = evaluation.ApmModuleEvaluator()
|
|
|
| # Instance factory objects.
|
| - self._noise_generator_factory = (
|
| - noise_generation_factory.NoiseGeneratorFactory(
|
| + self._test_data_generator_factory = (
|
| + test_data_generation_factory.TestDataGeneratorFactory(
|
| aechen_ir_database_path=aechen_ir_database_path))
|
| self._evaluation_score_factory = (
|
| eval_scores_factory.EvaluationScoreWorkerFactory(
|
| @@ -43,12 +44,12 @@ class ApmModuleSimulator(object):
|
|
|
| # Properties for each run.
|
| self._base_output_path = None
|
| - self._noise_generators = None
|
| + self._test_data_generators = None
|
| self._evaluation_score_workers = None
|
| self._config_filepaths = None
|
| self._input_filepaths = None
|
|
|
| - def Run(self, config_filepaths, input_filepaths, noise_generator_names,
|
| + def Run(self, config_filepaths, input_filepaths, test_data_generator_names,
|
| eval_score_names, output_dir):
|
| """Runs the APM simulation.
|
|
|
| @@ -57,16 +58,17 @@ class ApmModuleSimulator(object):
|
| Args:
|
| config_filepaths: set of APM configuration files to test.
|
| input_filepaths: set of input audio track files to test.
|
| - noise_generator_names: set of noise generator names to test.
|
| + test_data_generator_names: set of test data generator names to test.
|
| eval_score_names: set of evaluation score names to test.
|
| output_dir: base path to the output directory for wav files and outcomes.
|
| """
|
| self._base_output_path = os.path.abspath(output_dir)
|
|
|
| - # Instance noise generators.
|
| - self._noise_generators = [self._noise_generator_factory.GetInstance(
|
| - noise_generator_class=self._NOISE_GENERATOR_CLASSES[name]) for name in (
|
| - noise_generator_names)]
|
| + # Instance test data generators.
|
| + self._test_data_generators = [self._test_data_generator_factory.GetInstance(
|
| + test_data_generators_class=(
|
| + self._TEST_DATA_GENERATOR_CLASSES[name])) for name in (
|
| + test_data_generator_names)]
|
|
|
| # Instance evaluation score workers.
|
| self._evaluation_score_workers = [
|
| @@ -86,7 +88,7 @@ class ApmModuleSimulator(object):
|
| """Runs all the simulations.
|
|
|
| Iterates over the combinations of APM configurations, probing signals, and
|
| - noise generators.
|
| + test data generators.
|
| """
|
| # Try different APM config files.
|
| for config_name in self._config_filepaths:
|
| @@ -96,17 +98,17 @@ class ApmModuleSimulator(object):
|
| for input_name in self._input_filepaths:
|
| input_filepath = self._input_filepaths[input_name]
|
|
|
| - # Try different noise generators.
|
| - for noise_generator in self._noise_generators:
|
| + # Try different test data generators.
|
| + for test_data_generators in self._test_data_generators:
|
| logging.info('config: <%s>, input: <%s>, noise: <%s>',
|
| - config_name, input_name, noise_generator.NAME)
|
| + config_name, input_name, test_data_generators.NAME)
|
|
|
| # Output path for the input-noise pairs. It is used to cache the noisy
|
| # copies of the probing signals (shared across some simulations).
|
| input_noise_cache_path = os.path.join(
|
| self._base_output_path,
|
| '_cache',
|
| - 'input_{}-noise_{}'.format(input_name, noise_generator.NAME))
|
| + 'input_{}-noise_{}'.format(input_name, test_data_generators.NAME))
|
| data_access.MakeDirectory(input_noise_cache_path)
|
| logging.debug('input-noise cache path: <%s>', input_noise_cache_path)
|
|
|
| @@ -115,43 +117,44 @@ class ApmModuleSimulator(object):
|
| self._base_output_path,
|
| 'cfg-{}'.format(config_name),
|
| 'input-{}'.format(input_name),
|
| - 'noise-{}'.format(noise_generator.NAME))
|
| + 'gen-{}'.format(test_data_generators.NAME))
|
| data_access.MakeDirectory(output_path)
|
| logging.debug('output path: <%s>', output_path)
|
|
|
| - self._Simulate(noise_generator, input_filepath,
|
| + self._Simulate(test_data_generators, input_filepath,
|
| input_noise_cache_path, output_path, config_filepath)
|
|
|
| - def _Simulate(self, noise_generator, input_filepath, input_noise_cache_path,
|
| - output_path, config_filepath):
|
| + def _Simulate(self, test_data_generators, input_filepath,
|
| + input_noise_cache_path, output_path, config_filepath):
|
| """Runs a single set of simulation.
|
|
|
| Simulates a given combination of APM configuration, probing signal, and
|
| - noise generator. It iterates over the noise generator internal
|
| - configurations.
|
| + test data generator. It iterates over the test data generator
|
| + internal configurations.
|
|
|
| Args:
|
| - noise_generator: NoiseGenerator instance.
|
| + test_data_generators: TestDataGenerator instance.
|
| input_filepath: input audio track file to test.
|
| input_noise_cache_path: path for the noisy audio track files.
|
| - output_path: base output path for the noise generator.
|
| + output_path: base output path for the test data generator.
|
| config_filepath: APM configuration file to test.
|
| """
|
| # Generate pairs of noisy input and reference signal files.
|
| - noise_generator.Generate(
|
| + test_data_generators.Generate(
|
| input_signal_filepath=input_filepath,
|
| input_noise_cache_path=input_noise_cache_path,
|
| base_output_path=output_path)
|
|
|
| - # For each input-reference pair, simulate a call and evaluate.
|
| - for noise_generator_config_name in noise_generator.config_names:
|
| - logging.info(' - noise config: <%s>', noise_generator_config_name)
|
| + # For each test data pair, simulate a call and evaluate.
|
| + for test_data_generators_config_name in test_data_generators.config_names:
|
| + logging.info(' - test data generator config: <%s>',
|
| + test_data_generators_config_name)
|
|
|
| # APM input and output signal paths.
|
| - noisy_signal_filepath = noise_generator.noisy_signal_filepaths[
|
| - noise_generator_config_name]
|
| - evaluation_output_path = noise_generator.apm_output_paths[
|
| - noise_generator_config_name]
|
| + noisy_signal_filepath = test_data_generators.noisy_signal_filepaths[
|
| + test_data_generators_config_name]
|
| + evaluation_output_path = test_data_generators.apm_output_paths[
|
| + test_data_generators_config_name]
|
|
|
| # Simulate a call using the audio processing module.
|
| self._audioproc_wrapper.Run(
|
| @@ -160,8 +163,9 @@ class ApmModuleSimulator(object):
|
| output_path=evaluation_output_path)
|
|
|
| # Reference signal path for the evaluation step.
|
| - reference_signal_filepath = noise_generator.reference_signal_filepaths[
|
| - noise_generator_config_name]
|
| + reference_signal_filepath = (
|
| + test_data_generators.reference_signal_filepaths[
|
| + test_data_generators_config_name])
|
|
|
| # Evaluate.
|
| self._evaluator.Run(
|
|
|