OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python3 | |
2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 # | |
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 | |
6 # tree. An additional intellectual property rights grant can be found | |
7 # in the file PATENTS. All contributing project authors may | |
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 audioproc_f tool is ' | |
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) | |
aleloi2
2017/03/02 01:14:03
Interesting! I didn't know about the logging syste
AleBzk
2017/03/02 09:58:37
Done.
| |
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() | |
OLD | NEW |