| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
| 5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
| 6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 | 9 |
| 10 """Perform APM module quality assessment on one or more input files using one or | 10 """Perform APM module quality assessment on one or more input files using one or |
| 11 more audioproc_f configuration files and one or more noise generators. | 11 more audioproc_f configuration files and one or more test data generators. |
| 12 | 12 |
| 13 Usage: apm_quality_assessment.py -i audio1.wav [audio2.wav ...] | 13 Usage: apm_quality_assessment.py -i audio1.wav [audio2.wav ...] |
| 14 -c cfg1.json [cfg2.json ...] | 14 -c cfg1.json [cfg2.json ...] |
| 15 -n white [echo ...] | 15 -n white [echo ...] |
| 16 -e audio_level [polqa ...] | 16 -e audio_level [polqa ...] |
| 17 -o /path/to/output | 17 -o /path/to/output |
| 18 """ | 18 """ |
| 19 | 19 |
| 20 import argparse | 20 import argparse |
| 21 import logging | 21 import logging |
| 22 import sys | 22 import sys |
| 23 | 23 |
| 24 import quality_assessment.eval_scores as eval_scores | 24 import quality_assessment.eval_scores as eval_scores |
| 25 import quality_assessment.noise_generation as noise_generation | 25 import quality_assessment.test_data_generation as test_data_generation |
| 26 import quality_assessment.simulation as simulation | 26 import quality_assessment.simulation as simulation |
| 27 | 27 |
| 28 _NOISE_GENERATOR_CLASSES = noise_generation.NoiseGenerator.REGISTERED_CLASSES | 28 _TEST_DATA_GENERATOR_CLASSES = ( |
| 29 _NOISE_GENERATORS_NAMES = _NOISE_GENERATOR_CLASSES.keys() | 29 test_data_generation.TestDataGenerator.REGISTERED_CLASSES) |
| 30 _TEST_DATA_GENERATORS_NAMES = _TEST_DATA_GENERATOR_CLASSES.keys() |
| 30 _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES | 31 _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES |
| 31 _EVAL_SCORE_WORKER_NAMES = _EVAL_SCORE_WORKER_CLASSES.keys() | 32 _EVAL_SCORE_WORKER_NAMES = _EVAL_SCORE_WORKER_CLASSES.keys() |
| 32 | 33 |
| 33 _DEFAULT_CONFIG_FILE = 'apm_configs/default.json' | 34 _DEFAULT_CONFIG_FILE = 'apm_configs/default.json' |
| 34 | 35 |
| 35 | 36 |
| 36 def _InstanceArgumentsParser(): | 37 def _InstanceArgumentsParser(): |
| 37 """Arguments parser factory. | 38 """Arguments parser factory. |
| 38 """ | 39 """ |
| 39 parser = argparse.ArgumentParser(description=( | 40 parser = argparse.ArgumentParser(description=( |
| 40 'Perform APM module quality assessment on one or more input files using ' | 41 'Perform APM module quality assessment on one or more input files using ' |
| 41 'one or more audioproc_f configuration files and one or more noise ' | 42 'one or more audioproc_f configuration files and one or more ' |
| 42 'generators.')) | 43 'test data generators.')) |
| 43 | 44 |
| 44 parser.add_argument('-c', '--config_files', nargs='+', required=False, | 45 parser.add_argument('-c', '--config_files', nargs='+', required=False, |
| 45 help=('path to the configuration files defining the ' | 46 help=('path to the configuration files defining the ' |
| 46 'arguments with which the audioproc_f tool is ' | 47 'arguments with which the audioproc_f tool is ' |
| 47 'called'), | 48 'called'), |
| 48 default=[_DEFAULT_CONFIG_FILE]) | 49 default=[_DEFAULT_CONFIG_FILE]) |
| 49 | 50 |
| 50 parser.add_argument('-i', '--input_files', nargs='+', required=True, | 51 parser.add_argument('-i', '--input_files', nargs='+', required=True, |
| 51 help='path to the input wav files (one or more)') | 52 help='path to the input wav files (one or more)') |
| 52 | 53 |
| 53 parser.add_argument('-n', '--noise_generators', nargs='+', required=False, | 54 parser.add_argument('-t', '--test_data_generators', nargs='+', required=False, |
| 54 help='custom list of noise generators to use', | 55 help='custom list of test data generators to use', |
| 55 choices=_NOISE_GENERATORS_NAMES, | 56 choices=_TEST_DATA_GENERATORS_NAMES, |
| 56 default=_NOISE_GENERATORS_NAMES) | 57 default=_TEST_DATA_GENERATORS_NAMES) |
| 57 | 58 |
| 58 parser.add_argument('-e', '--eval_scores', nargs='+', required=False, | 59 parser.add_argument('-e', '--eval_scores', nargs='+', required=False, |
| 59 help='custom list of evaluation scores to use', | 60 help='custom list of evaluation scores to use', |
| 60 choices=_EVAL_SCORE_WORKER_NAMES, | 61 choices=_EVAL_SCORE_WORKER_NAMES, |
| 61 default=_EVAL_SCORE_WORKER_NAMES) | 62 default=_EVAL_SCORE_WORKER_NAMES) |
| 62 | 63 |
| 63 parser.add_argument('-o', '--output_dir', required=False, | 64 parser.add_argument('-o', '--output_dir', required=False, |
| 64 help=('base path to the output directory in which the ' | 65 help=('base path to the output directory in which the ' |
| 65 'output wav files and the evaluation outcomes ' | 66 'output wav files and the evaluation outcomes ' |
| 66 'are saved'), | 67 'are saved'), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 | 82 |
| 82 parser = _InstanceArgumentsParser() | 83 parser = _InstanceArgumentsParser() |
| 83 args = parser.parse_args() | 84 args = parser.parse_args() |
| 84 | 85 |
| 85 simulator = simulation.ApmModuleSimulator( | 86 simulator = simulation.ApmModuleSimulator( |
| 86 aechen_ir_database_path=args.air_db_path, | 87 aechen_ir_database_path=args.air_db_path, |
| 87 polqa_tool_path=args.polqa_path) | 88 polqa_tool_path=args.polqa_path) |
| 88 simulator.Run( | 89 simulator.Run( |
| 89 config_filepaths=args.config_files, | 90 config_filepaths=args.config_files, |
| 90 input_filepaths=args.input_files, | 91 input_filepaths=args.input_files, |
| 91 noise_generator_names=args.noise_generators, | 92 test_data_generator_names=args.test_data_generators, |
| 92 eval_score_names=args.eval_scores, | 93 eval_score_names=args.eval_scores, |
| 93 output_dir=args.output_dir) | 94 output_dir=args.output_dir) |
| 94 | 95 |
| 95 sys.exit(0) | 96 sys.exit(0) |
| 96 | 97 |
| 97 | 98 |
| 98 if __name__ == '__main__': | 99 if __name__ == '__main__': |
| 99 main() | 100 main() |
| OLD | NEW |