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

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

Issue 2715943002: APM Quality Assessment, simulation controller and libraries (Closed)
Patch Set: Created 3 years, 10 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 python3 1 #!/usr/bin/env python3
ivoc 2017/02/24 14:41:47 Why is this is some python files but not in some o
AleBzk 2017/03/01 09:07:12 Thanks for asking. As documented in our style guid
ivoc 2017/03/01 22:51:28 Acknowledged.
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
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.
12
13 Usage: apm_quality_assessment.py -i audio1.wav [audio2.wav ...]
14 -c cfg1.json [cfg2.json ...]
15 -n white [echo ...]
16 -e audio_level [polqa ...]
17 -o /path/to/output
18 """
19
20 import argparse
21 import logging
22 import sys
23
24 import quality_assessment.eval_scores as eval_scores
25 import quality_assessment.noise_generation as noise_generation
26 import quality_assessment.simulation as simulation
27
28 _NOISE_GENERATOR_CLASSES = noise_generation.NoiseGenerator.REGISTERED_CLASSES
29 _NOISE_GENERATORS_NAMES = _NOISE_GENERATOR_CLASSES.keys()
30 _EVAL_SCORE_WORKER_CLASSES = eval_scores.EvaluationScore.REGISTERED_CLASSES
31 _EVAL_SCORE_WORKER_NAMES = _EVAL_SCORE_WORKER_CLASSES.keys()
32
33 _DEFAULT_CONFIG_FILE = 'apm_configs/default.json'
34
35 def _instance_arguments_parser():
36 parser = argparse.ArgumentParser(description=(
37 'Perform APM module quality assessment on one or more input files using '
38 'one or more audioproc_f configuration files and one or more noise '
39 'generators.'))
40
41 parser.add_argument('-c', '--config_files', nargs='+', required=False,
42 help=('path to the configuration files defining the '
43 'arguments with which the auiodproc_f tool is '
ivoc 2017/02/24 14:41:47 audioproc_f
AleBzk 2017/03/01 09:07:12 Acknowledged.
44 'called'),
45 default=[_DEFAULT_CONFIG_FILE])
46
47 parser.add_argument('-i', '--input_files', nargs='+', required=True,
48 help='path to the input wav files (one or more)')
49
50 parser.add_argument('-n', '--noise_generators', nargs='+', required=False,
51 help='custom list of noise generators to use',
52 choices=_NOISE_GENERATORS_NAMES,
53 default=_NOISE_GENERATORS_NAMES)
54
55 parser.add_argument('-e', '--eval_scores', nargs='+', required=False,
56 help='custom list of evaluation scores to use',
57 choices=_EVAL_SCORE_WORKER_NAMES,
58 default=_EVAL_SCORE_WORKER_NAMES)
59
60 parser.add_argument('-o', '--output_dir', required=True,
61 help=('base path to the output directory in which the '
62 'output wav files and the evaluation outcomes '
63 'are saved'))
64
65 return parser
66
67
68 def main():
69 # TODO(alessiob): level = logging.INFO once debugged.
70 logging.basicConfig(level=logging.DEBUG)
71
72 parser = _instance_arguments_parser()
73 args = parser.parse_args()
74
75 simulator = simulation.ApmModuleSimulator()
76 simulator.run(
77 config_filepaths=args.config_files,
78 input_filepaths=args.input_files,
79 noise_generator_names=args.noise_generators,
80 eval_score_names=args.eval_scores,
81 output_dir=args.output_dir)
82
83 sys.exit(0)
84
85
86 if __name__ == '__main__':
87 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698