Mercurial > hg > auditok
comparison tests/test_cmdline_util.py @ 292:9907db0843cb
Refactor main script
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Sun, 06 Oct 2019 18:46:04 +0200 |
parents | cd9897f4519f |
children | 9741b52f194a |
comparison
equal
deleted
inserted
replaced
291:cd9897f4519f | 292:9907db0843cb |
---|---|
24 | 24 |
25 _ArgsNamespece = namedtuple( | 25 _ArgsNamespece = namedtuple( |
26 "_ArgsNamespece", | 26 "_ArgsNamespece", |
27 [ | 27 [ |
28 "input", | 28 "input", |
29 "max_time", | 29 "max_read", |
30 "analysis_window", | 30 "analysis_window", |
31 "sampling_rate", | 31 "sampling_rate", |
32 "sample_width", | 32 "sample_width", |
33 "channels", | 33 "channels", |
34 "use_channel", | 34 "use_channel", |
36 "output_format", | 36 "output_format", |
37 "large_file", | 37 "large_file", |
38 "frame_per_buffer", | 38 "frame_per_buffer", |
39 "input_device_index", | 39 "input_device_index", |
40 "save_stream", | 40 "save_stream", |
41 "save_detections_as", | |
41 "plot", | 42 "plot", |
42 "save_image", | 43 "save_image", |
43 "min_duration", | 44 "min_duration", |
44 "max_duration", | 45 "max_duration", |
45 "max_silence", | 46 "max_silence", |
46 "drop_trailing_silence", | 47 "drop_trailing_silence", |
47 "strict_min_duration", | 48 "strict_min_duration", |
48 "energy_threshold", | 49 "energy_threshold", |
49 "echo", | 50 "echo", |
51 "progress_bar", | |
50 "command", | 52 "command", |
51 "quiet", | 53 "quiet", |
52 "printf", | 54 "printf", |
53 "time_format", | 55 "time_format", |
54 "timestamp_format", | 56 "timestamp_format", |
55 ], | 57 ], |
56 ) | 58 ) |
57 | 59 |
58 | 60 |
59 @genty | 61 @genty |
60 class _TestCmdLineUtil(TestCase): | 62 class TestCmdLineUtil(TestCase): |
61 @genty_dataset( | 63 @genty_dataset( |
62 no_record=("stream.ogg", False, None, "mix", "mix", False), | 64 no_record=("stream.ogg", None, False, None, "mix", "mix", False), |
63 no_record_plot=("stream.ogg", True, None, None, None, False), | 65 no_record_plot=("stream.ogg", None, True, None, None, None, False), |
64 no_record_save_image=( | 66 no_record_save_image=( |
65 "stream.ogg", | 67 "stream.ogg", |
68 None, | |
66 True, | 69 True, |
67 "image.png", | 70 "image.png", |
68 None, | 71 None, |
69 None, | 72 None, |
70 False, | 73 False, |
71 ), | 74 ), |
72 record_plot=(None, True, None, None, None, True), | 75 record_plot=(None, None, True, None, None, None, True), |
73 record_save_image=(None, False, "image.png", None, None, True), | 76 record_save_image=(None, None, False, "image.png", None, None, True), |
74 int_use_channel=("stream.ogg", False, None, "1", 1, False), | 77 int_use_channel=("stream.ogg", None, False, None, "1", 1, False), |
78 save_detections_as=("stream.ogg", "{id}.wav", False, None, None, None, False) | |
75 ) | 79 ) |
76 def test_make_kwargs( | 80 def test_make_kwargs( |
77 self, | 81 self, |
78 save_stream, | 82 save_stream, |
83 save_detections_as, | |
79 plot, | 84 plot, |
80 save_image, | 85 save_image, |
81 use_channel, | 86 use_channel, |
82 exp_use_channel, | 87 exp_use_channel, |
83 exp_record, | 88 exp_record, |
95 "ogg", | 100 "ogg", |
96 True, | 101 True, |
97 None, | 102 None, |
98 1, | 103 1, |
99 save_stream, | 104 save_stream, |
105 save_detections_as, | |
100 plot, | 106 plot, |
101 save_image, | 107 save_image, |
102 0.2, | 108 0.2, |
103 10, | 109 10, |
104 0.3, | 110 0.3, |
105 False, | 111 False, |
106 False, | 112 False, |
107 55, | 113 55, |
108 ) | 114 ) |
109 misc = (False, None, True, None, "TIME_FORMAT", "TIMESTAMP_FORMAT") | 115 misc = (False, False, None, True, None, "TIME_FORMAT", "TIMESTAMP_FORMAT") |
110 | |
111 args_ns = _ArgsNamespece(*(args + misc)) | 116 args_ns = _ArgsNamespece(*(args + misc)) |
112 | 117 |
113 io_kwargs = { | 118 io_kwargs = { |
114 "input": "file", | 119 "input": "file", |
115 "max_read": 30, | 120 "max_read": 30, |
117 "sampling_rate": 16000, | 122 "sampling_rate": 16000, |
118 "sample_width": 2, | 123 "sample_width": 2, |
119 "channels": 2, | 124 "channels": 2, |
120 "use_channel": exp_use_channel, | 125 "use_channel": exp_use_channel, |
121 "save_stream": save_stream, | 126 "save_stream": save_stream, |
127 "save_detections_as": save_detections_as, | |
122 "audio_format": "raw", | 128 "audio_format": "raw", |
123 "export_format": "ogg", | 129 "export_format": "ogg", |
124 "large_file": True, | 130 "large_file": True, |
125 "frames_per_buffer": None, | 131 "frames_per_buffer": None, |
126 "input_device_index": 1, | 132 "input_device_index": 1, |
137 } | 143 } |
138 | 144 |
139 miscellaneous = { | 145 miscellaneous = { |
140 "echo": False, | 146 "echo": False, |
141 "command": None, | 147 "command": None, |
148 "progress_bar": False, | |
142 "quiet": True, | 149 "quiet": True, |
143 "printf": None, | 150 "printf": None, |
144 "time_format": "TIME_FORMAT", | 151 "time_format": "TIME_FORMAT", |
145 "timestamp_format": "TIMESTAMP_FORMAT", | 152 "timestamp_format": "TIMESTAMP_FORMAT", |
146 } | 153 } |