OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
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 """Generate .json files with which the APM module can be tested using the | |
11 apm_quality_assessment.py script. | |
12 """ | |
13 | |
14 import logging | |
15 import os | |
16 | |
17 import quality_assessment.data_access as data_access | |
18 | |
19 OUTPUT_PATH = os.path.abspath('apm_configs') | |
20 | |
21 def _generate_default_overridden(config_override): | |
22 """ | |
23 For each item in config_override, it overrides the default configuration and | |
24 writes a new APM configuration file. | |
25 | |
26 The default settings are loaded via "-all_default". | |
27 Check "src/webrtc/modules/audio_processing/test/audioproc_float.cc" and search | |
28 for "if (FLAGS_all_default) {". | |
29 | |
30 For instance, in 55eb6d621489730084927868fed195d3645a9ec9 the default is this: | |
31 settings.use_aec = rtc::Optional<bool>(true); | |
32 settings.use_aecm = rtc::Optional<bool>(false); | |
33 settings.use_agc = rtc::Optional<bool>(true); | |
34 settings.use_bf = rtc::Optional<bool>(false); | |
35 settings.use_ed = rtc::Optional<bool>(false); | |
36 settings.use_hpf = rtc::Optional<bool>(true); | |
37 settings.use_ie = rtc::Optional<bool>(false); | |
38 settings.use_le = rtc::Optional<bool>(true); | |
39 settings.use_ns = rtc::Optional<bool>(true); | |
40 settings.use_ts = rtc::Optional<bool>(true); | |
41 settings.use_vad = rtc::Optional<bool>(true); | |
42 """ | |
43 | |
44 for config_filename in config_override: | |
45 config = config_override[config_filename] | |
46 config['-all_default'] = None | |
47 | |
48 config_filepath = os.path.join(OUTPUT_PATH, 'default-{}.json'.format( | |
49 config_filename)) | |
50 logging.debug('config file <%s> | %s', config_filepath, config) | |
51 | |
52 data_access.AudioProcConfigFile.save(config_filepath, config) | |
53 logging.info('config file created: <%s>', config_filepath) | |
54 | |
55 | |
56 def generate_all_default_but_one(): | |
57 """ | |
58 Generate configurations in which all the default flags are used but one (one | |
59 flag at a time is excluded). | |
60 """ | |
61 CONFIG_SETS = { | |
62 'no_AEC': {'-aec': 0,}, | |
63 'no_AGC': {'-agc': 0,}, | |
64 'no_HP_filter': {'-hpf': 0,}, | |
65 'no_level_estimator': {'-le': 0,}, | |
66 'no_noise_suppressor': {'-ns': 0,}, | |
67 'no_transient_suppressor': {'-ts': 0,}, | |
68 'no_vad': {'-vad': 0,}, | |
69 } | |
70 | |
71 return _generate_default_overridden(CONFIG_SETS) | |
72 | |
73 | |
74 def generate_all_default_plus_one(): | |
75 """ | |
76 Generate configuratoins in which all the default flags are used and each | |
77 unused flag is added one at a time. | |
78 """ | |
79 CONFIG_SETS = { | |
80 'with_AECM': {'-aec': 0, '-aecm': 1,}, # AEC and AECM are exclusive. | |
81 'with_AGC_limiter': {'-agc_limiter': 1,}, | |
82 'with_AEC_delay_agnostic': {'-delay_agnostic': 1,}, | |
83 'with_drift_compensation': {'-drift_compensation': 1,}, | |
84 'with_residual_echo_detector': {'-ed': 1,}, | |
85 'with_AEC_extended_filter': {'-extended_filter': 1,}, | |
86 'with_intelligibility_enhancer': {'-ie': 1,}, | |
87 'with_LC': {'-lc': 1,}, | |
88 'with_refined_adaptive_filter': {'-refined_adaptive_filter': 1,}, | |
89 } | |
90 | |
91 return _generate_default_overridden(CONFIG_SETS) | |
92 | |
93 | |
94 def main(): | |
95 logging.basicConfig(level=logging.INFO) | |
96 generate_all_default_plus_one() | |
97 generate_all_default_but_one() | |
98 | |
99 | |
100 if __name__ == '__main__': | |
101 main() | |
OLD | NEW |