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

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

Issue 2715233003: APM Quality Generator, noise generator and evaluation score workers factory + echo noise generator (Closed)
Patch Set: Noise generation and evaluation score workers now instantiated through factory objects, class decor… Created 3 years, 9 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 noise generators. 11 more audioproc_f configuration files and one or more noise 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 sys 23 import sys
23 24
24 import quality_assessment.eval_scores as eval_scores 25 import quality_assessment.eval_scores as eval_scores
25 import quality_assessment.noise_generation as noise_generation 26 import quality_assessment.noise_generation as noise_generation
26 import quality_assessment.simulation as simulation 27 import quality_assessment.simulation as simulation
27 28
28 _NOISE_GENERATOR_CLASSES = noise_generation.NoiseGenerator.REGISTERED_CLASSES 29 _NOISE_GENERATOR_CLASSES = noise_generation.NoiseGenerator.REGISTERED_CLASSES
29 _NOISE_GENERATORS_NAMES = _NOISE_GENERATOR_CLASSES.keys() 30 _NOISE_GENERATORS_NAMES = _NOISE_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()
(...skipping 24 matching lines...) Expand all
56 help='custom list of evaluation scores to use', 57 help='custom list of evaluation scores to use',
57 choices=_EVAL_SCORE_WORKER_NAMES, 58 choices=_EVAL_SCORE_WORKER_NAMES,
58 default=_EVAL_SCORE_WORKER_NAMES) 59 default=_EVAL_SCORE_WORKER_NAMES)
59 60
60 parser.add_argument('-o', '--output_dir', required=False, 61 parser.add_argument('-o', '--output_dir', required=False,
61 help=('base path to the output directory in which the ' 62 help=('base path to the output directory in which the '
62 'output wav files and the evaluation outcomes ' 63 'output wav files and the evaluation outcomes '
63 'are saved'), 64 'are saved'),
64 default='output') 65 default='output')
65 66
67 default_polqa_path = None if 'POLQA_PATH' not in os.environ else (
68 os.environ['POLQA_PATH'])
69 parser.add_argument('--polqa_path', nargs='+',
70 required=default_polqa_path is None,
71 help='path to the POLQA tool',
72 default=default_polqa_path)
73
74 default_air_db_path = None if 'AECHEN_IR_DATABASE_PATH' not in (
75 os.environ) else os.environ['AECHEN_IR_DATABASE_PATH']
76 parser.add_argument('--air_db_path', nargs='+',
77 required=default_air_db_path is None,
78 help='path to the Aechen IR database',
79 default=default_air_db_path)
80
AleBzk 2017/03/06 11:29:53 @kjellander: the environment variable, if defined,
kjellander_webrtc 2017/03/09 07:49:31 That's better, but I'd still like to never even at
AleBzk 2017/03/09 11:31:19 Done. Now both paths are required and with no defa
kjellander_webrtc 2017/03/09 14:05:41 Thanks! Environment variables are the cause of muc
66 return parser 81 return parser
67 82
68 83
69 def main(): 84 def main():
70 # TODO(alessiob): level = logging.INFO once debugged. 85 # TODO(alessiob): level = logging.INFO once debugged.
71 logging.basicConfig(level=logging.DEBUG) 86 logging.basicConfig(level=logging.DEBUG)
72 87
73 parser = _instance_arguments_parser() 88 parser = _instance_arguments_parser()
74 args = parser.parse_args() 89 args = parser.parse_args()
75 90
76 simulator = simulation.ApmModuleSimulator() 91 simulator = simulation.ApmModuleSimulator(
92 aechen_ir_database_path=args.air_db_path,
93 polqa_tool_path=args.polqa_path)
AleBzk 2017/03/06 11:29:53 @kjellander: the required paths are now passed to
77 simulator.run( 94 simulator.run(
78 config_filepaths=args.config_files, 95 config_filepaths=args.config_files,
79 input_filepaths=args.input_files, 96 input_filepaths=args.input_files,
80 noise_generator_names=args.noise_generators, 97 noise_generator_names=args.noise_generators,
81 eval_score_names=args.eval_scores, 98 eval_score_names=args.eval_scores,
82 output_dir=args.output_dir) 99 output_dir=args.output_dir)
83 100
84 sys.exit(0) 101 sys.exit(0)
85 102
86 103
87 if __name__ == '__main__': 104 if __name__ == '__main__':
88 main() 105 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698