sonusai 0.18.9__py3-none-any.whl → 0.19.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sonusai/__init__.py +20 -29
- sonusai/aawscd_probwrite.py +18 -18
- sonusai/audiofe.py +93 -80
- sonusai/calc_metric_spenh.py +395 -321
- sonusai/data/genmixdb.yml +5 -11
- sonusai/{gentcst.py → deprecated/gentcst.py} +146 -149
- sonusai/{plot.py → deprecated/plot.py} +177 -131
- sonusai/{tplot.py → deprecated/tplot.py} +124 -102
- sonusai/doc/__init__.py +1 -1
- sonusai/doc/doc.py +112 -177
- sonusai/doc.py +10 -10
- sonusai/genft.py +81 -91
- sonusai/genmetrics.py +51 -61
- sonusai/genmix.py +105 -115
- sonusai/genmixdb.py +201 -174
- sonusai/lsdb.py +56 -66
- sonusai/main.py +23 -20
- sonusai/metrics/__init__.py +2 -0
- sonusai/metrics/calc_audio_stats.py +29 -24
- sonusai/metrics/calc_class_weights.py +7 -7
- sonusai/metrics/calc_optimal_thresholds.py +5 -7
- sonusai/metrics/calc_pcm.py +3 -3
- sonusai/metrics/calc_pesq.py +10 -7
- sonusai/metrics/calc_phase_distance.py +3 -3
- sonusai/metrics/calc_sa_sdr.py +10 -8
- sonusai/metrics/calc_segsnr_f.py +16 -18
- sonusai/metrics/calc_speech.py +105 -47
- sonusai/metrics/calc_wer.py +35 -32
- sonusai/metrics/calc_wsdr.py +10 -7
- sonusai/metrics/class_summary.py +30 -27
- sonusai/metrics/confusion_matrix_summary.py +25 -22
- sonusai/metrics/one_hot.py +91 -57
- sonusai/metrics/snr_summary.py +53 -46
- sonusai/mixture/__init__.py +20 -14
- sonusai/mixture/audio.py +4 -6
- sonusai/mixture/augmentation.py +37 -43
- sonusai/mixture/class_count.py +5 -14
- sonusai/mixture/config.py +292 -225
- sonusai/mixture/constants.py +41 -30
- sonusai/mixture/data_io.py +155 -0
- sonusai/mixture/datatypes.py +111 -108
- sonusai/mixture/db_datatypes.py +54 -70
- sonusai/mixture/eq_rule_is_valid.py +6 -9
- sonusai/mixture/feature.py +40 -38
- sonusai/mixture/generation.py +522 -389
- sonusai/mixture/helpers.py +217 -272
- sonusai/mixture/log_duration_and_sizes.py +16 -13
- sonusai/mixture/mixdb.py +669 -477
- sonusai/mixture/soundfile_audio.py +12 -17
- sonusai/mixture/sox_audio.py +91 -112
- sonusai/mixture/sox_augmentation.py +8 -9
- sonusai/mixture/spectral_mask.py +4 -6
- sonusai/mixture/target_class_balancing.py +41 -36
- sonusai/mixture/targets.py +69 -67
- sonusai/mixture/tokenized_shell_vars.py +23 -23
- sonusai/mixture/torchaudio_audio.py +14 -15
- sonusai/mixture/torchaudio_augmentation.py +23 -27
- sonusai/mixture/truth.py +48 -26
- sonusai/mixture/truth_functions/__init__.py +26 -0
- sonusai/mixture/truth_functions/crm.py +56 -38
- sonusai/mixture/truth_functions/datatypes.py +37 -0
- sonusai/mixture/truth_functions/energy.py +85 -59
- sonusai/mixture/truth_functions/file.py +30 -30
- sonusai/mixture/truth_functions/phoneme.py +14 -7
- sonusai/mixture/truth_functions/sed.py +71 -45
- sonusai/mixture/truth_functions/target.py +69 -106
- sonusai/mkwav.py +58 -101
- sonusai/onnx_predict.py +46 -43
- sonusai/queries/__init__.py +3 -1
- sonusai/queries/queries.py +100 -59
- sonusai/speech/__init__.py +2 -0
- sonusai/speech/l2arctic.py +24 -23
- sonusai/speech/librispeech.py +16 -17
- sonusai/speech/mcgill.py +22 -21
- sonusai/speech/textgrid.py +32 -25
- sonusai/speech/timit.py +45 -42
- sonusai/speech/vctk.py +14 -13
- sonusai/speech/voxceleb.py +26 -20
- sonusai/summarize_metric_spenh.py +11 -10
- sonusai/utils/__init__.py +4 -3
- sonusai/utils/asl_p56.py +1 -1
- sonusai/utils/asr.py +37 -17
- sonusai/utils/asr_functions/__init__.py +2 -0
- sonusai/utils/asr_functions/aaware_whisper.py +18 -12
- sonusai/utils/audio_devices.py +12 -12
- sonusai/utils/braced_glob.py +6 -8
- sonusai/utils/calculate_input_shape.py +1 -4
- sonusai/utils/compress.py +2 -2
- sonusai/utils/convert_string_to_number.py +1 -3
- sonusai/utils/create_timestamp.py +1 -1
- sonusai/utils/create_ts_name.py +2 -2
- sonusai/utils/dataclass_from_dict.py +1 -1
- sonusai/utils/docstring.py +6 -6
- sonusai/utils/energy_f.py +9 -7
- sonusai/utils/engineering_number.py +56 -54
- sonusai/utils/get_label_names.py +8 -10
- sonusai/utils/human_readable_size.py +2 -2
- sonusai/utils/model_utils.py +3 -5
- sonusai/utils/numeric_conversion.py +2 -4
- sonusai/utils/onnx_utils.py +43 -32
- sonusai/utils/parallel.py +41 -30
- sonusai/utils/print_mixture_details.py +25 -22
- sonusai/utils/ranges.py +12 -12
- sonusai/utils/read_predict_data.py +11 -9
- sonusai/utils/reshape.py +19 -26
- sonusai/utils/seconds_to_hms.py +1 -1
- sonusai/utils/stacked_complex.py +8 -16
- sonusai/utils/stratified_shuffle_split.py +29 -27
- sonusai/utils/write_audio.py +2 -2
- sonusai/utils/yes_or_no.py +3 -3
- sonusai/vars.py +14 -14
- {sonusai-0.18.9.dist-info → sonusai-0.19.6.dist-info}/METADATA +20 -21
- sonusai-0.19.6.dist-info/RECORD +125 -0
- {sonusai-0.18.9.dist-info → sonusai-0.19.6.dist-info}/WHEEL +1 -1
- sonusai/mixture/truth_functions/data.py +0 -58
- sonusai/utils/read_mixture_data.py +0 -14
- sonusai-0.18.9.dist-info/RECORD +0 -125
- {sonusai-0.18.9.dist-info → sonusai-0.19.6.dist-info}/entry_points.txt +0 -0
sonusai/genmix.py
CHANGED
@@ -17,22 +17,21 @@ Inputs:
|
|
17
17
|
MIXID A glob of mixture ID(s) to generate.
|
18
18
|
|
19
19
|
Outputs the following to the mixture database directory:
|
20
|
-
<id
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
<id>
|
21
|
+
mixture.pkl
|
22
|
+
targets.pkl
|
23
|
+
noise.pkl
|
24
|
+
target.pkl (optional)
|
25
|
+
truth_t.pkl (optional)
|
26
|
+
segsnr_t.pkl (optional)
|
27
|
+
metadata.txt
|
28
28
|
genmix.log
|
29
29
|
"""
|
30
|
+
|
30
31
|
import signal
|
31
|
-
from dataclasses import dataclass
|
32
32
|
|
33
|
-
from sonusai.mixture import GenMixData
|
34
33
|
from sonusai.mixture import GeneralizedIDs
|
35
|
-
from sonusai.mixture import
|
34
|
+
from sonusai.mixture import GenMixData
|
36
35
|
|
37
36
|
|
38
37
|
def signal_handler(_sig, _frame):
|
@@ -40,116 +39,100 @@ def signal_handler(_sig, _frame):
|
|
40
39
|
|
41
40
|
from sonusai import logger
|
42
41
|
|
43
|
-
logger.info(
|
42
|
+
logger.info("Canceled due to keyboard interrupt")
|
44
43
|
sys.exit(1)
|
45
44
|
|
46
45
|
|
47
46
|
signal.signal(signal.SIGINT, signal_handler)
|
48
47
|
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
save_target: bool =
|
54
|
-
compute_truth: bool =
|
55
|
-
compute_segsnr: bool =
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
def genmix(
|
50
|
+
location: str,
|
51
|
+
mixids: GeneralizedIDs = "*",
|
52
|
+
save_target: bool = False,
|
53
|
+
compute_truth: bool = False,
|
54
|
+
compute_segsnr: bool = False,
|
55
|
+
write: bool = False,
|
56
|
+
show_progress: bool = False,
|
57
|
+
force: bool = True,
|
58
|
+
) -> list[GenMixData]:
|
59
|
+
from functools import partial
|
61
60
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
save_target: bool = False,
|
66
|
-
compute_truth: bool = False,
|
67
|
-
compute_segsnr: bool = False,
|
68
|
-
write: bool = False,
|
69
|
-
show_progress: bool = False,
|
70
|
-
force: bool = True) -> list[GenMixData]:
|
71
|
-
from tqdm import tqdm
|
72
|
-
|
73
|
-
from sonusai.utils import pp_tqdm_imap
|
61
|
+
from sonusai.mixture import MixtureDatabase
|
62
|
+
from sonusai.utils import par_track
|
63
|
+
from sonusai.utils import track
|
74
64
|
|
75
65
|
mixdb = MixtureDatabase(location)
|
76
66
|
mixids = mixdb.mixids_to_list(mixids)
|
77
|
-
progress =
|
78
|
-
results =
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
67
|
+
progress = track(total=len(mixids), disable=not show_progress)
|
68
|
+
results = par_track(
|
69
|
+
partial(
|
70
|
+
_genmix_kernel,
|
71
|
+
location=location,
|
72
|
+
save_target=save_target,
|
73
|
+
compute_truth=compute_truth,
|
74
|
+
compute_segsnr=compute_segsnr,
|
75
|
+
force=force,
|
76
|
+
write=write,
|
77
|
+
),
|
78
|
+
mixids,
|
79
|
+
progress=progress,
|
80
|
+
)
|
83
81
|
progress.close()
|
84
82
|
|
85
83
|
return results
|
86
84
|
|
87
85
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
MP_GLOBAL.write = write
|
100
|
-
|
101
|
-
|
102
|
-
def _genmix_kernel(m_id: int) -> GenMixData:
|
103
|
-
from sonusai.mixture import write_mixture_data
|
86
|
+
def _genmix_kernel(
|
87
|
+
m_id: int,
|
88
|
+
location: str,
|
89
|
+
save_target: bool,
|
90
|
+
compute_truth: bool,
|
91
|
+
compute_segsnr: bool,
|
92
|
+
force: bool,
|
93
|
+
write: bool,
|
94
|
+
) -> GenMixData:
|
95
|
+
from sonusai.mixture import MixtureDatabase
|
96
|
+
from sonusai.mixture import write_cached_data
|
104
97
|
from sonusai.mixture import write_mixture_metadata
|
105
98
|
|
106
|
-
mixdb =
|
107
|
-
save_target = MP_GLOBAL.save_target
|
108
|
-
compute_truth = MP_GLOBAL.compute_truth
|
109
|
-
compute_segsnr = MP_GLOBAL.compute_segsnr
|
110
|
-
force = MP_GLOBAL.force
|
111
|
-
write = MP_GLOBAL.write
|
99
|
+
mixdb = MixtureDatabase(location)
|
112
100
|
|
113
101
|
targets = mixdb.mixture_targets(m_id=m_id, force=force)
|
114
102
|
noise = mixdb.mixture_noise(m_id=m_id, force=force)
|
115
|
-
write_data = [(
|
103
|
+
write_data = [("targets", targets), ("noise", noise)]
|
116
104
|
|
117
105
|
if compute_truth:
|
118
106
|
truth_t = mixdb.mixture_truth_t(m_id=m_id, targets=targets, noise=noise, force=force)
|
119
|
-
write_data.append((
|
107
|
+
write_data.append(("truth_t", truth_t))
|
120
108
|
else:
|
121
109
|
truth_t = None
|
122
110
|
|
123
111
|
target = mixdb.mixture_target(m_id=m_id, targets=targets)
|
124
112
|
if save_target:
|
125
|
-
write_data.append((
|
113
|
+
write_data.append(("target", target))
|
126
114
|
|
127
115
|
if compute_segsnr:
|
128
|
-
segsnr_t = mixdb.mixture_segsnr_t(m_id=m_id,
|
129
|
-
|
130
|
-
target=target,
|
131
|
-
noise=noise,
|
132
|
-
force=force)
|
133
|
-
write_data.append(('segsnr_t', segsnr_t))
|
116
|
+
segsnr_t = mixdb.mixture_segsnr_t(m_id=m_id, targets=targets, target=target, noise=noise, force=force)
|
117
|
+
write_data.append(("segsnr_t", segsnr_t))
|
134
118
|
else:
|
135
119
|
segsnr_t = None
|
136
120
|
|
137
|
-
mixture = mixdb.mixture_mixture(m_id=m_id,
|
138
|
-
|
139
|
-
target=target,
|
140
|
-
noise=noise,
|
141
|
-
force=force)
|
142
|
-
write_data.append(('mixture', mixture))
|
121
|
+
mixture = mixdb.mixture_mixture(m_id=m_id, targets=targets, target=target, noise=noise, force=force)
|
122
|
+
write_data.append(("mixture", mixture))
|
143
123
|
|
144
124
|
if write:
|
145
|
-
|
125
|
+
write_cached_data(mixdb.location, "mixture", mixdb.mixture(m_id).name, write_data)
|
146
126
|
write_mixture_metadata(mixdb, mixdb.mixture(m_id))
|
147
127
|
|
148
|
-
return GenMixData(
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
128
|
+
return GenMixData(
|
129
|
+
targets=targets,
|
130
|
+
target=target,
|
131
|
+
noise=noise,
|
132
|
+
mixture=mixture,
|
133
|
+
truth_t=truth_t,
|
134
|
+
segsnr_t=segsnr_t,
|
135
|
+
)
|
153
136
|
|
154
137
|
|
155
138
|
def main() -> None:
|
@@ -167,59 +150,66 @@ def main() -> None:
|
|
167
150
|
from sonusai import initial_log_messages
|
168
151
|
from sonusai import logger
|
169
152
|
from sonusai import update_console_handler
|
153
|
+
from sonusai.mixture import MixtureDatabase
|
170
154
|
from sonusai.mixture import check_audio_files_exist
|
171
155
|
from sonusai.utils import human_readable_size
|
172
156
|
from sonusai.utils import seconds_to_hms
|
173
157
|
|
174
|
-
verbose = args[
|
175
|
-
location = args[
|
176
|
-
mixids = args[
|
177
|
-
save_target = args[
|
178
|
-
compute_truth = args[
|
179
|
-
compute_segsnr = args[
|
158
|
+
verbose = args["--verbose"]
|
159
|
+
location = args["LOC"]
|
160
|
+
mixids = args["--mixid"]
|
161
|
+
save_target = args["--target"]
|
162
|
+
compute_truth = args["--truth"]
|
163
|
+
compute_segsnr = args["--segsnr"]
|
180
164
|
|
181
165
|
start_time = time.monotonic()
|
182
166
|
|
183
|
-
create_file_handler(join(location,
|
167
|
+
create_file_handler(join(location, "genmix.log"))
|
184
168
|
update_console_handler(verbose)
|
185
|
-
initial_log_messages(
|
169
|
+
initial_log_messages("genmix")
|
186
170
|
|
187
|
-
logger.info(f
|
171
|
+
logger.info(f"Load mixture database from {location}")
|
188
172
|
mixdb = MixtureDatabase(location)
|
189
173
|
mixids = mixdb.mixids_to_list(mixids)
|
190
174
|
|
191
175
|
total_samples = mixdb.total_samples(mixids)
|
192
176
|
duration = total_samples / sonusai.mixture.SAMPLE_RATE
|
193
177
|
|
194
|
-
logger.info(
|
195
|
-
logger.info(f
|
196
|
-
logger.info(f
|
178
|
+
logger.info("")
|
179
|
+
logger.info(f"Found {len(mixids):,} mixtures to process")
|
180
|
+
logger.info(f"{total_samples:,} samples")
|
197
181
|
|
198
182
|
check_audio_files_exist(mixdb)
|
199
183
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
184
|
+
try:
|
185
|
+
genmix(
|
186
|
+
location=location,
|
187
|
+
mixids=mixids,
|
188
|
+
save_target=save_target,
|
189
|
+
compute_truth=compute_truth,
|
190
|
+
compute_segsnr=compute_segsnr,
|
191
|
+
write=True,
|
192
|
+
show_progress=True,
|
193
|
+
)
|
194
|
+
except Exception as e:
|
195
|
+
logger.debug(e)
|
196
|
+
raise
|
197
|
+
|
198
|
+
logger.info(f"Wrote {len(mixids)} mixtures to {location}")
|
199
|
+
logger.info("")
|
200
|
+
logger.info(f"Duration: {seconds_to_hms(seconds=duration)}")
|
201
|
+
logger.info(f"mixture: {human_readable_size(total_samples * 2, 1)}")
|
212
202
|
if compute_truth:
|
213
|
-
logger.info(f
|
214
|
-
logger.info(f
|
215
|
-
logger.info(f
|
203
|
+
logger.info(f"truth_t: {human_readable_size(total_samples * mixdb.num_classes * 4, 1)}")
|
204
|
+
logger.info(f"target: {human_readable_size(total_samples * 2, 1)}")
|
205
|
+
logger.info(f"noise: {human_readable_size(total_samples * 2, 1)}")
|
216
206
|
if compute_segsnr:
|
217
|
-
logger.info(f
|
207
|
+
logger.info(f"segsnr: {human_readable_size(total_samples * 4, 1)}")
|
218
208
|
|
219
209
|
end_time = time.monotonic()
|
220
|
-
logger.info(f
|
221
|
-
logger.info(
|
210
|
+
logger.info(f"Completed in {seconds_to_hms(seconds=end_time - start_time)}")
|
211
|
+
logger.info("")
|
222
212
|
|
223
213
|
|
224
|
-
if __name__ ==
|
214
|
+
if __name__ == "__main__":
|
225
215
|
main()
|