Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: webrtc/modules/audio_processing/test/py_quality_assessment/apm_quality_assessment.py

Issue 2813883002: APM QA refactoring: render stream support, echo path simulation, new export engine (Closed)
Patch Set: merge Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 test data 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 os 22 import os
23 import sys 23 import sys
24 24
25 import quality_assessment.audioproc_wrapper as audioproc_wrapper 25 import quality_assessment.audioproc_wrapper as audioproc_wrapper
26 import quality_assessment.echo_path_simulation as echo_path_simulation
26 import quality_assessment.eval_scores as eval_scores 27 import quality_assessment.eval_scores as eval_scores
27 import quality_assessment.evaluation as evaluation 28 import quality_assessment.evaluation as evaluation
28 import quality_assessment.test_data_generation as test_data_generation 29 import quality_assessment.test_data_generation as test_data_generation
29 import quality_assessment.simulation as simulation 30 import quality_assessment.simulation as simulation
30 31
32 _ECHO_PATH_SIMULATOR_NAMES = (
33 echo_path_simulation.EchoPathSimulator.REGISTERED_CLASSES)
31 _TEST_DATA_GENERATOR_CLASSES = ( 34 _TEST_DATA_GENERATOR_CLASSES = (
32 test_data_generation.TestDataGenerator.REGISTERED_CLASSES) 35 test_data_generation.TestDataGenerator.REGISTERED_CLASSES)
33 _TEST_DATA_GENERATORS_NAMES = _TEST_DATA_GENERATOR_CLASSES.keys() 36 _TEST_DATA_GENERATORS_NAMES = _TEST_DATA_GENERATOR_CLASSES.keys()
34 _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES 37 _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES
35 _EVAL_SCORE_WORKER_NAMES = _EVAL_SCORE_WORKER_CLASSES.keys() 38 _EVAL_SCORE_WORKER_NAMES = _EVAL_SCORE_WORKER_CLASSES.keys()
36 39
37 _DEFAULT_CONFIG_FILE = 'apm_configs/default.json' 40 _DEFAULT_CONFIG_FILE = 'apm_configs/default.json'
38 41
39 _POLQA_BIN_NAME = 'PolqaOem64' 42 _POLQA_BIN_NAME = 'PolqaOem64'
40 43
41 44
42 def _InstanceArgumentsParser(): 45 def _InstanceArgumentsParser():
43 """Arguments parser factory. 46 """Arguments parser factory.
44 """ 47 """
45 parser = argparse.ArgumentParser(description=( 48 parser = argparse.ArgumentParser(description=(
46 'Perform APM module quality assessment on one or more input files using ' 49 'Perform APM module quality assessment on one or more input files using '
47 'one or more audioproc_f configuration files and one or more ' 50 'one or more audioproc_f configuration files and one or more '
48 'test data generators.')) 51 'test data generators.'))
49 52
50 parser.add_argument('-c', '--config_files', nargs='+', required=False, 53 parser.add_argument('-c', '--config_files', nargs='+', required=False,
51 help=('path to the configuration files defining the ' 54 help=('path to the configuration files defining the '
52 'arguments with which the audioproc_f tool is ' 55 'arguments with which the audioproc_f tool is '
53 'called'), 56 'called'),
54 default=[_DEFAULT_CONFIG_FILE]) 57 default=[_DEFAULT_CONFIG_FILE])
55 58
56 parser.add_argument('-i', '--input_files', nargs='+', required=True, 59 parser.add_argument('-i', '--capture_input_files', nargs='+', required=True,
57 help='path to the input wav files (one or more)') 60 help='path to the capture input wav files (one or more)')
61
62 parser.add_argument('-r', '--render_input_files', nargs='+', required=False,
63 help=('path to the render input wav files; either '
64 'omitted or one file for each file in '
65 '--capture_input_files (files will be paired by '
66 'index)'), default=None)
67
68 parser.add_argument('-p', '--echo_path_simulator', required=False,
69 help=('custom echo path simulator name; required if '
70 '--render_input_files is specified'),
71 choices=_ECHO_PATH_SIMULATOR_NAMES,
72 default=echo_path_simulation.NoEchoPathSimulator.NAME)
58 73
59 parser.add_argument('-t', '--test_data_generators', nargs='+', required=False, 74 parser.add_argument('-t', '--test_data_generators', nargs='+', required=False,
60 help='custom list of test data generators to use', 75 help='custom list of test data generators to use',
61 choices=_TEST_DATA_GENERATORS_NAMES, 76 choices=_TEST_DATA_GENERATORS_NAMES,
62 default=_TEST_DATA_GENERATORS_NAMES) 77 default=_TEST_DATA_GENERATORS_NAMES)
63 78
64 parser.add_argument('-e', '--eval_scores', nargs='+', required=False, 79 parser.add_argument('-e', '--eval_scores', nargs='+', required=False,
65 help='custom list of evaluation scores to use', 80 help='custom list of evaluation scores to use',
66 choices=_EVAL_SCORE_WORKER_NAMES, 81 choices=_EVAL_SCORE_WORKER_NAMES,
67 default=_EVAL_SCORE_WORKER_NAMES) 82 default=_EVAL_SCORE_WORKER_NAMES)
(...skipping 12 matching lines...) Expand all
80 95
81 return parser 96 return parser
82 97
83 98
84 def main(): 99 def main():
85 # TODO(alessiob): level = logging.INFO once debugged. 100 # TODO(alessiob): level = logging.INFO once debugged.
86 logging.basicConfig(level=logging.DEBUG) 101 logging.basicConfig(level=logging.DEBUG)
87 102
88 parser = _InstanceArgumentsParser() 103 parser = _InstanceArgumentsParser()
89 args = parser.parse_args() 104 args = parser.parse_args()
105 if args.capture_input_files and args.render_input_files and (
106 len(args.capture_input_files) != len(args.render_input_files)):
107 parser.error('--render_input_files and --capture_input_files must be lists '
108 'having the same length')
109 sys.exit(1)
110 if args.render_input_files and not args.echo_path_simulator:
111 parser.error('when --render_input_files is set, --echo_path_simulator is '
112 'also required')
113 sys.exit(1)
90 114
91 simulator = simulation.ApmModuleSimulator( 115 simulator = simulation.ApmModuleSimulator(
92 aechen_ir_database_path=args.air_db_path, 116 aechen_ir_database_path=args.air_db_path,
93 polqa_tool_bin_path=os.path.join(args.polqa_path, _POLQA_BIN_NAME), 117 polqa_tool_bin_path=os.path.join(args.polqa_path, _POLQA_BIN_NAME),
94 ap_wrapper=audioproc_wrapper.AudioProcWrapper(), 118 ap_wrapper=audioproc_wrapper.AudioProcWrapper(),
95 evaluator=evaluation.ApmModuleEvaluator()) 119 evaluator=evaluation.ApmModuleEvaluator())
96 simulator.Run( 120 simulator.Run(
97 config_filepaths=args.config_files, 121 config_filepaths=args.config_files,
98 input_filepaths=args.input_files, 122 capture_input_filepaths=args.capture_input_files,
123 render_input_filepaths=args.render_input_files,
124 echo_path_simulator_name=args.echo_path_simulator,
99 test_data_generator_names=args.test_data_generators, 125 test_data_generator_names=args.test_data_generators,
100 eval_score_names=args.eval_scores, 126 eval_score_names=args.eval_scores,
101 output_dir=args.output_dir) 127 output_dir=args.output_dir)
102 128
103 sys.exit(0) 129 sys.exit(0)
104 130
105 131
106 if __name__ == '__main__': 132 if __name__ == '__main__':
107 main() 133 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698