sonusai 0.19.5__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/genft.py +13 -39
- sonusai/genmetrics.py +6 -29
- sonusai/genmix.py +22 -44
- sonusai/genmixdb.py +24 -38
- sonusai/metrics/calc_segsnr_f.py +1 -1
- sonusai/mixture/__init__.py +1 -0
- sonusai/mkwav.py +18 -28
- sonusai/utils/parallel.py +3 -5
- {sonusai-0.19.5.dist-info → sonusai-0.19.6.dist-info}/METADATA +1 -1
- {sonusai-0.19.5.dist-info → sonusai-0.19.6.dist-info}/RECORD +12 -12
- {sonusai-0.19.5.dist-info → sonusai-0.19.6.dist-info}/WHEEL +0 -0
- {sonusai-0.19.5.dist-info → sonusai-0.19.6.dist-info}/entry_points.txt +0 -0
sonusai/genft.py
CHANGED
@@ -25,11 +25,9 @@ Outputs the following to the mixture database directory:
|
|
25
25
|
"""
|
26
26
|
|
27
27
|
import signal
|
28
|
-
from dataclasses import dataclass
|
29
28
|
|
30
29
|
from sonusai.mixture import GeneralizedIDs
|
31
30
|
from sonusai.mixture import GenFTData
|
32
|
-
from sonusai.mixture import MixtureDatabase
|
33
31
|
|
34
32
|
|
35
33
|
def signal_handler(_sig, _frame):
|
@@ -44,20 +42,8 @@ def signal_handler(_sig, _frame):
|
|
44
42
|
signal.signal(signal.SIGINT, signal_handler)
|
45
43
|
|
46
44
|
|
47
|
-
@dataclass
|
48
|
-
class MPGlobal:
|
49
|
-
mixdb: MixtureDatabase
|
50
|
-
compute_truth: bool
|
51
|
-
compute_segsnr: bool
|
52
|
-
force: bool
|
53
|
-
write: bool
|
54
|
-
|
55
|
-
|
56
|
-
MP_GLOBAL: MPGlobal
|
57
|
-
|
58
|
-
|
59
45
|
def genft(
|
60
|
-
|
46
|
+
location: str,
|
61
47
|
mixids: GeneralizedIDs = "*",
|
62
48
|
compute_truth: bool = True,
|
63
49
|
compute_segsnr: bool = False,
|
@@ -65,17 +51,19 @@ def genft(
|
|
65
51
|
show_progress: bool = False,
|
66
52
|
force: bool = True,
|
67
53
|
) -> list[GenFTData]:
|
54
|
+
from functools import partial
|
55
|
+
|
56
|
+
from sonusai.mixture import MixtureDatabase
|
68
57
|
from sonusai.utils import par_track
|
69
58
|
from sonusai.utils import track
|
70
59
|
|
60
|
+
mixdb = MixtureDatabase(location)
|
71
61
|
mixids = mixdb.mixids_to_list(mixids)
|
72
62
|
|
73
63
|
progress = track(total=len(mixids), disable=not show_progress)
|
74
64
|
results = par_track(
|
75
|
-
_genft_kernel,
|
65
|
+
partial(_genft_kernel, location=location, compute_truth=compute_truth, compute_segsnr=compute_segsnr, force=force, write=write),
|
76
66
|
mixids,
|
77
|
-
initializer=_genft_initializer,
|
78
|
-
initargs=(mixdb.location, compute_truth, compute_segsnr, force, write),
|
79
67
|
progress=progress,
|
80
68
|
)
|
81
69
|
progress.close()
|
@@ -83,34 +71,19 @@ def genft(
|
|
83
71
|
return results
|
84
72
|
|
85
73
|
|
86
|
-
def
|
87
|
-
|
74
|
+
def _genft_kernel(m_id: int, location: str, compute_truth: bool, compute_segsnr: bool, force: bool, write: bool) -> GenFTData:
|
75
|
+
from typing import Any
|
88
76
|
|
89
|
-
|
90
|
-
mixdb=MixtureDatabase(location),
|
91
|
-
compute_truth=compute_truth,
|
92
|
-
compute_segsnr=compute_segsnr,
|
93
|
-
force=force,
|
94
|
-
write=write,
|
95
|
-
)
|
96
|
-
|
97
|
-
|
98
|
-
def _genft_kernel(m_id: int) -> GenFTData:
|
77
|
+
from sonusai.mixture import MixtureDatabase
|
99
78
|
from sonusai.mixture import write_cached_data
|
100
79
|
from sonusai.mixture import write_mixture_metadata
|
101
80
|
|
102
|
-
|
103
|
-
|
104
|
-
mixdb = MP_GLOBAL.mixdb
|
105
|
-
compute_truth = MP_GLOBAL.compute_truth
|
106
|
-
compute_segsnr = MP_GLOBAL.compute_segsnr
|
107
|
-
force = MP_GLOBAL.force
|
108
|
-
write = MP_GLOBAL.write
|
81
|
+
mixdb = MixtureDatabase(location)
|
109
82
|
|
110
83
|
result = GenFTData()
|
111
84
|
|
112
85
|
feature, truth_f = mixdb.mixture_ft(m_id=m_id, force=force)
|
113
|
-
write_data = [("feature", feature)]
|
86
|
+
write_data: list[tuple[str, Any]] = [("feature", feature)]
|
114
87
|
result.feature = feature
|
115
88
|
|
116
89
|
if compute_truth:
|
@@ -144,6 +117,7 @@ def main() -> None:
|
|
144
117
|
from sonusai import initial_log_messages
|
145
118
|
from sonusai import logger
|
146
119
|
from sonusai import update_console_handler
|
120
|
+
from sonusai.mixture import MixtureDatabase
|
147
121
|
from sonusai.mixture import check_audio_files_exist
|
148
122
|
from sonusai.utils import human_readable_size
|
149
123
|
from sonusai.utils import seconds_to_hms
|
@@ -180,7 +154,7 @@ def main() -> None:
|
|
180
154
|
|
181
155
|
try:
|
182
156
|
genft(
|
183
|
-
|
157
|
+
location=location,
|
184
158
|
mixids=mixids,
|
185
159
|
compute_segsnr=compute_segsnr,
|
186
160
|
write=True,
|
sonusai/genmetrics.py
CHANGED
@@ -34,9 +34,6 @@ Generate all available metrics except for mxwer.faster:
|
|
34
34
|
"""
|
35
35
|
|
36
36
|
import signal
|
37
|
-
from dataclasses import dataclass
|
38
|
-
|
39
|
-
from sonusai.mixture import MixtureDatabase
|
40
37
|
|
41
38
|
|
42
39
|
def signal_handler(_sig, _frame):
|
@@ -51,31 +48,11 @@ def signal_handler(_sig, _frame):
|
|
51
48
|
signal.signal(signal.SIGINT, signal_handler)
|
52
49
|
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
mixdb: MixtureDatabase
|
57
|
-
metrics: set[str]
|
58
|
-
|
59
|
-
|
60
|
-
MP_GLOBAL: MPGlobal
|
61
|
-
|
62
|
-
|
63
|
-
def _initializer(location: str, metrics: set[str]) -> None:
|
64
|
-
global MP_GLOBAL
|
65
|
-
|
66
|
-
MP_GLOBAL = MPGlobal(
|
67
|
-
mixdb=MixtureDatabase(location),
|
68
|
-
metrics=metrics,
|
69
|
-
)
|
70
|
-
|
71
|
-
|
72
|
-
def _process_mixture(mixid: int) -> None:
|
51
|
+
def _process_mixture(mixid: int, location: str, metrics: list[str]) -> None:
|
52
|
+
from sonusai.mixture import MixtureDatabase
|
73
53
|
from sonusai.mixture import write_cached_data
|
74
54
|
|
75
|
-
|
76
|
-
|
77
|
-
mixdb = MP_GLOBAL.mixdb
|
78
|
-
metrics = list(MP_GLOBAL.metrics)
|
55
|
+
mixdb = MixtureDatabase(location)
|
79
56
|
|
80
57
|
values = mixdb.mixture_metrics(m_id=mixid, metrics=metrics, force=True)
|
81
58
|
write_data = list(zip(metrics, values, strict=False))
|
@@ -87,6 +64,7 @@ def main() -> None:
|
|
87
64
|
from docopt import docopt
|
88
65
|
|
89
66
|
import sonusai
|
67
|
+
from sonusai.mixture import MixtureDatabase
|
90
68
|
from sonusai.utils import trim_docstring
|
91
69
|
|
92
70
|
args = docopt(trim_docstring(__doc__), version=sonusai.__version__, options_first=True)
|
@@ -100,6 +78,7 @@ def main() -> None:
|
|
100
78
|
|
101
79
|
import sys
|
102
80
|
import time
|
81
|
+
from functools import partial
|
103
82
|
from os.path import join
|
104
83
|
|
105
84
|
from sonusai import create_file_handler
|
@@ -167,11 +146,9 @@ def main() -> None:
|
|
167
146
|
|
168
147
|
progress = track(total=len(mixids), desc="genmetrics")
|
169
148
|
par_track(
|
170
|
-
_process_mixture,
|
149
|
+
partial(_process_mixture, location=location, metrics=list(metrics)),
|
171
150
|
mixids,
|
172
151
|
progress=progress,
|
173
|
-
initializer=_initializer,
|
174
|
-
initargs=(location, metrics),
|
175
152
|
)
|
176
153
|
progress.close()
|
177
154
|
|
sonusai/genmix.py
CHANGED
@@ -29,11 +29,9 @@ Outputs the following to the mixture database directory:
|
|
29
29
|
"""
|
30
30
|
|
31
31
|
import signal
|
32
|
-
from dataclasses import dataclass
|
33
32
|
|
34
33
|
from sonusai.mixture import GeneralizedIDs
|
35
34
|
from sonusai.mixture import GenMixData
|
36
|
-
from sonusai.mixture import MixtureDatabase
|
37
35
|
|
38
36
|
|
39
37
|
def signal_handler(_sig, _frame):
|
@@ -48,21 +46,8 @@ def signal_handler(_sig, _frame):
|
|
48
46
|
signal.signal(signal.SIGINT, signal_handler)
|
49
47
|
|
50
48
|
|
51
|
-
@dataclass
|
52
|
-
class MPGlobal:
|
53
|
-
mixdb: MixtureDatabase
|
54
|
-
save_target: bool
|
55
|
-
compute_truth: bool
|
56
|
-
compute_segsnr: bool
|
57
|
-
force: bool
|
58
|
-
write: bool
|
59
|
-
|
60
|
-
|
61
|
-
MP_GLOBAL: MPGlobal
|
62
|
-
|
63
|
-
|
64
49
|
def genmix(
|
65
|
-
|
50
|
+
location: str,
|
66
51
|
mixids: GeneralizedIDs = "*",
|
67
52
|
save_target: bool = False,
|
68
53
|
compute_truth: bool = False,
|
@@ -71,16 +56,26 @@ def genmix(
|
|
71
56
|
show_progress: bool = False,
|
72
57
|
force: bool = True,
|
73
58
|
) -> list[GenMixData]:
|
59
|
+
from functools import partial
|
60
|
+
|
61
|
+
from sonusai.mixture import MixtureDatabase
|
74
62
|
from sonusai.utils import par_track
|
75
63
|
from sonusai.utils import track
|
76
64
|
|
65
|
+
mixdb = MixtureDatabase(location)
|
77
66
|
mixids = mixdb.mixids_to_list(mixids)
|
78
67
|
progress = track(total=len(mixids), disable=not show_progress)
|
79
68
|
results = par_track(
|
80
|
-
|
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
|
+
),
|
81
78
|
mixids,
|
82
|
-
initializer=_genmix_initializer,
|
83
|
-
initargs=(mixdb, save_target, compute_truth, compute_segsnr, force, write),
|
84
79
|
progress=progress,
|
85
80
|
)
|
86
81
|
progress.close()
|
@@ -88,38 +83,20 @@ def genmix(
|
|
88
83
|
return results
|
89
84
|
|
90
85
|
|
91
|
-
def
|
92
|
-
|
86
|
+
def _genmix_kernel(
|
87
|
+
m_id: int,
|
88
|
+
location: str,
|
93
89
|
save_target: bool,
|
94
90
|
compute_truth: bool,
|
95
91
|
compute_segsnr: bool,
|
96
92
|
force: bool,
|
97
93
|
write: bool,
|
98
|
-
) ->
|
99
|
-
|
100
|
-
|
101
|
-
MP_GLOBAL = MPGlobal(
|
102
|
-
mixdb=mixdb,
|
103
|
-
save_target=save_target,
|
104
|
-
compute_truth=compute_truth,
|
105
|
-
compute_segsnr=compute_segsnr,
|
106
|
-
force=force,
|
107
|
-
write=write,
|
108
|
-
)
|
109
|
-
|
110
|
-
|
111
|
-
def _genmix_kernel(m_id: int) -> GenMixData:
|
94
|
+
) -> GenMixData:
|
95
|
+
from sonusai.mixture import MixtureDatabase
|
112
96
|
from sonusai.mixture import write_cached_data
|
113
97
|
from sonusai.mixture import write_mixture_metadata
|
114
98
|
|
115
|
-
|
116
|
-
|
117
|
-
mixdb = MP_GLOBAL.mixdb
|
118
|
-
save_target = MP_GLOBAL.save_target
|
119
|
-
compute_truth = MP_GLOBAL.compute_truth
|
120
|
-
compute_segsnr = MP_GLOBAL.compute_segsnr
|
121
|
-
force = MP_GLOBAL.force
|
122
|
-
write = MP_GLOBAL.write
|
99
|
+
mixdb = MixtureDatabase(location)
|
123
100
|
|
124
101
|
targets = mixdb.mixture_targets(m_id=m_id, force=force)
|
125
102
|
noise = mixdb.mixture_noise(m_id=m_id, force=force)
|
@@ -173,6 +150,7 @@ def main() -> None:
|
|
173
150
|
from sonusai import initial_log_messages
|
174
151
|
from sonusai import logger
|
175
152
|
from sonusai import update_console_handler
|
153
|
+
from sonusai.mixture import MixtureDatabase
|
176
154
|
from sonusai.mixture import check_audio_files_exist
|
177
155
|
from sonusai.utils import human_readable_size
|
178
156
|
from sonusai.utils import seconds_to_hms
|
@@ -205,7 +183,7 @@ def main() -> None:
|
|
205
183
|
|
206
184
|
try:
|
207
185
|
genmix(
|
208
|
-
|
186
|
+
location=location,
|
209
187
|
mixids=mixids,
|
210
188
|
save_target=save_target,
|
211
189
|
compute_truth=compute_truth,
|
sonusai/genmixdb.py
CHANGED
@@ -114,10 +114,8 @@ will find all .wav files in the specified directories and process them as target
|
|
114
114
|
"""
|
115
115
|
|
116
116
|
import signal
|
117
|
-
from dataclasses import dataclass
|
118
117
|
|
119
118
|
from sonusai.mixture import Mixture
|
120
|
-
from sonusai.mixture import MixtureDatabase
|
121
119
|
|
122
120
|
|
123
121
|
def signal_handler(_sig, _frame):
|
@@ -132,17 +130,6 @@ def signal_handler(_sig, _frame):
|
|
132
130
|
signal.signal(signal.SIGINT, signal_handler)
|
133
131
|
|
134
132
|
|
135
|
-
@dataclass
|
136
|
-
class MPGlobal:
|
137
|
-
mixdb: MixtureDatabase
|
138
|
-
save_mix: bool
|
139
|
-
save_ft: bool
|
140
|
-
save_segsnr: bool
|
141
|
-
|
142
|
-
|
143
|
-
MP_GLOBAL: MPGlobal
|
144
|
-
|
145
|
-
|
146
133
|
def genmixdb(
|
147
134
|
location: str,
|
148
135
|
save_mix: bool = False,
|
@@ -152,7 +139,8 @@ def genmixdb(
|
|
152
139
|
show_progress: bool = False,
|
153
140
|
test: bool = False,
|
154
141
|
save_json: bool = False,
|
155
|
-
) ->
|
142
|
+
) -> None:
|
143
|
+
from functools import partial
|
156
144
|
from random import seed
|
157
145
|
|
158
146
|
import yaml
|
@@ -376,11 +364,16 @@ def genmixdb(
|
|
376
364
|
logger.info("Generating mixtures")
|
377
365
|
progress = track(total=num_mixtures, disable=not show_progress)
|
378
366
|
mixtures = par_track(
|
379
|
-
|
367
|
+
partial(
|
368
|
+
_process_mixture,
|
369
|
+
location=location,
|
370
|
+
save_mix=save_mix,
|
371
|
+
save_ft=save_ft,
|
372
|
+
save_segsnr=save_segsnr,
|
373
|
+
test=test,
|
374
|
+
),
|
380
375
|
mixtures,
|
381
376
|
progress=progress,
|
382
|
-
initializer=_initializer,
|
383
|
-
initargs=(location, save_mix, save_ft, save_segsnr, test),
|
384
377
|
)
|
385
378
|
progress.close()
|
386
379
|
|
@@ -414,23 +407,18 @@ def genmixdb(
|
|
414
407
|
mixdb = MixtureDatabase(location)
|
415
408
|
mixdb.save()
|
416
409
|
|
417
|
-
return mixdb
|
418
410
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
save_segsnr=save_segsnr,
|
428
|
-
)
|
429
|
-
|
430
|
-
|
431
|
-
def _process_mixture(mixture: Mixture) -> Mixture:
|
411
|
+
def _process_mixture(
|
412
|
+
mixture: Mixture,
|
413
|
+
location: str,
|
414
|
+
save_mix: bool,
|
415
|
+
save_ft: bool,
|
416
|
+
save_segsnr: bool,
|
417
|
+
test: bool,
|
418
|
+
) -> Mixture:
|
432
419
|
from typing import Any
|
433
420
|
|
421
|
+
from sonusai.mixture import MixtureDatabase
|
434
422
|
from sonusai.mixture import get_ft
|
435
423
|
from sonusai.mixture import get_segsnr
|
436
424
|
from sonusai.mixture import get_truth
|
@@ -438,22 +426,20 @@ def _process_mixture(mixture: Mixture) -> Mixture:
|
|
438
426
|
from sonusai.mixture import write_cached_data
|
439
427
|
from sonusai.mixture import write_mixture_metadata
|
440
428
|
|
441
|
-
|
442
|
-
|
443
|
-
with_data = MP_GLOBAL.save_mix or MP_GLOBAL.save_ft
|
444
|
-
mixdb = MP_GLOBAL.mixdb
|
429
|
+
with_data = save_mix or save_ft
|
430
|
+
mixdb = MixtureDatabase(location, test)
|
445
431
|
|
446
432
|
mixture, genmix_data = update_mixture(mixdb, mixture, with_data)
|
447
433
|
|
448
434
|
if with_data:
|
449
435
|
write_data: list[tuple[str, Any]] = []
|
450
436
|
|
451
|
-
if
|
437
|
+
if save_mix:
|
452
438
|
write_data.append(("targets", genmix_data.targets))
|
453
439
|
write_data.append(("noise", genmix_data.noise))
|
454
440
|
write_data.append(("mixture", genmix_data.mixture))
|
455
441
|
|
456
|
-
if
|
442
|
+
if save_ft:
|
457
443
|
if genmix_data.targets is None or genmix_data.noise is None or genmix_data.mixture is None:
|
458
444
|
raise RuntimeError("Mixture data was not generated properly")
|
459
445
|
truth_t = get_truth(
|
@@ -472,7 +458,7 @@ def _process_mixture(mixture: Mixture) -> Mixture:
|
|
472
458
|
write_data.append(("feature", feature))
|
473
459
|
write_data.append(("truth_f", truth_f))
|
474
460
|
|
475
|
-
if
|
461
|
+
if save_segsnr:
|
476
462
|
if genmix_data.target is None:
|
477
463
|
raise RuntimeError("Target data was not generated properly")
|
478
464
|
segsnr = get_segsnr(
|
sonusai/metrics/calc_segsnr_f.py
CHANGED
@@ -45,7 +45,7 @@ def calc_segsnr_f_bin(target_f: AudioF, noise_f: AudioF) -> SnrFBinMetrics:
|
|
45
45
|
if target_f.ndim != 2 and noise_f.ndim != 2:
|
46
46
|
raise ValueError("target_f and noise_f must have 2 dimensions")
|
47
47
|
|
48
|
-
segsnr_f = (np.abs(target_f) ** 2) / (np.abs(noise_f) ** 2)
|
48
|
+
segsnr_f = (np.abs(target_f) ** 2) / (np.abs(noise_f) ** 2 + np.finfo(np.float32).eps)
|
49
49
|
|
50
50
|
frames, bins = segsnr_f.shape
|
51
51
|
if np.count_nonzero(segsnr_f) == 0:
|
sonusai/mixture/__init__.py
CHANGED
@@ -92,6 +92,7 @@ from .datatypes import TransformConfig
|
|
92
92
|
from .datatypes import Truth
|
93
93
|
from .datatypes import TruthConfig
|
94
94
|
from .datatypes import TruthConfigs
|
95
|
+
from .datatypes import TruthDict
|
95
96
|
from .datatypes import TruthParameter
|
96
97
|
from .datatypes import TruthParameters
|
97
98
|
from .datatypes import UniversalSNR
|
sonusai/mkwav.py
CHANGED
@@ -26,9 +26,6 @@ Outputs the following to the mixture database directory:
|
|
26
26
|
"""
|
27
27
|
|
28
28
|
import signal
|
29
|
-
from dataclasses import dataclass
|
30
|
-
|
31
|
-
from sonusai.mixture import MixtureDatabase
|
32
29
|
|
33
30
|
|
34
31
|
def signal_handler(_sig, _frame):
|
@@ -43,28 +40,15 @@ def signal_handler(_sig, _frame):
|
|
43
40
|
signal.signal(signal.SIGINT, signal_handler)
|
44
41
|
|
45
42
|
|
46
|
-
|
47
|
-
class MPGlobal:
|
48
|
-
mixdb: MixtureDatabase
|
49
|
-
write_target: bool
|
50
|
-
write_noise: bool
|
51
|
-
|
52
|
-
|
53
|
-
MP_GLOBAL: MPGlobal
|
54
|
-
|
55
|
-
|
56
|
-
def _process_mixture(m_id: int) -> None:
|
43
|
+
def _process_mixture(m_id: int, location: str, write_target: bool, write_noise: bool) -> None:
|
57
44
|
from os.path import join
|
58
45
|
|
46
|
+
from sonusai.mixture import MixtureDatabase
|
59
47
|
from sonusai.mixture import write_mixture_metadata
|
60
48
|
from sonusai.utils import float_to_int16
|
61
49
|
from sonusai.utils import write_audio
|
62
50
|
|
63
|
-
|
64
|
-
|
65
|
-
mixdb = MP_GLOBAL.mixdb
|
66
|
-
write_target = MP_GLOBAL.write_target
|
67
|
-
write_noise = MP_GLOBAL.write_noise
|
51
|
+
mixdb = MixtureDatabase(location)
|
68
52
|
|
69
53
|
mixture = mixdb.mixture(m_id)
|
70
54
|
location = join(mixdb.location, mixture.name)
|
@@ -88,11 +72,12 @@ def main() -> None:
|
|
88
72
|
|
89
73
|
verbose = args["--verbose"]
|
90
74
|
mixid = args["--mixid"]
|
91
|
-
|
92
|
-
|
75
|
+
write_target = args["--target"]
|
76
|
+
write_noise = args["--noise"]
|
93
77
|
location = args["LOC"]
|
94
78
|
|
95
79
|
import time
|
80
|
+
from functools import partial
|
96
81
|
from os.path import join
|
97
82
|
|
98
83
|
import sonusai
|
@@ -100,6 +85,7 @@ def main() -> None:
|
|
100
85
|
from sonusai import initial_log_messages
|
101
86
|
from sonusai import logger
|
102
87
|
from sonusai import update_console_handler
|
88
|
+
from sonusai.mixture import MixtureDatabase
|
103
89
|
from sonusai.mixture import check_audio_files_exist
|
104
90
|
from sonusai.utils import human_readable_size
|
105
91
|
from sonusai.utils import par_track
|
@@ -113,29 +99,33 @@ def main() -> None:
|
|
113
99
|
initial_log_messages("mkwav")
|
114
100
|
|
115
101
|
logger.info(f"Load mixture database from {location}")
|
116
|
-
|
117
|
-
mixid =
|
102
|
+
mixdb = MixtureDatabase(location)
|
103
|
+
mixid = mixdb.mixids_to_list(mixid)
|
118
104
|
|
119
|
-
total_samples =
|
105
|
+
total_samples = mixdb.total_samples(mixid)
|
120
106
|
duration = total_samples / sonusai.mixture.SAMPLE_RATE
|
121
107
|
|
122
108
|
logger.info("")
|
123
109
|
logger.info(f"Found {len(mixid):,} mixtures to process")
|
124
110
|
logger.info(f"{total_samples:,} samples")
|
125
111
|
|
126
|
-
check_audio_files_exist(
|
112
|
+
check_audio_files_exist(mixdb)
|
127
113
|
|
128
114
|
progress = track(total=len(mixid))
|
129
|
-
par_track(
|
115
|
+
par_track(
|
116
|
+
partial(_process_mixture, location=location, write_target=write_target, write_noise=write_noise),
|
117
|
+
mixid,
|
118
|
+
progress=progress,
|
119
|
+
)
|
130
120
|
progress.close()
|
131
121
|
|
132
122
|
logger.info(f"Wrote {len(mixid)} mixtures to {location}")
|
133
123
|
logger.info("")
|
134
124
|
logger.info(f"Duration: {seconds_to_hms(seconds=duration)}")
|
135
125
|
logger.info(f"mixture: {human_readable_size(total_samples * 2, 1)}")
|
136
|
-
if
|
126
|
+
if write_target:
|
137
127
|
logger.info(f"target: {human_readable_size(total_samples * 2, 1)}")
|
138
|
-
if
|
128
|
+
if write_noise:
|
139
129
|
logger.info(f"noise: {human_readable_size(total_samples * 2, 1)}")
|
140
130
|
|
141
131
|
end_time = time.monotonic()
|
sonusai/utils/parallel.py
CHANGED
@@ -36,7 +36,6 @@ def par_track(
|
|
36
36
|
_total = int(total)
|
37
37
|
|
38
38
|
results: list[Any] = [None] * _total
|
39
|
-
n = 0
|
40
39
|
if no_par or current_process().daemon:
|
41
40
|
if initializer is not None:
|
42
41
|
if initargs is not None:
|
@@ -44,9 +43,8 @@ def par_track(
|
|
44
43
|
else:
|
45
44
|
initializer()
|
46
45
|
|
47
|
-
for result in map(func, *iterables):
|
46
|
+
for n, result in enumerate(map(func, *iterables)):
|
48
47
|
results[n] = result
|
49
|
-
n += 1
|
50
48
|
if progress is not None:
|
51
49
|
progress.update()
|
52
50
|
else:
|
@@ -57,13 +55,13 @@ def par_track(
|
|
57
55
|
else:
|
58
56
|
_num_cpus = int(num_cpus)
|
59
57
|
|
60
|
-
|
61
|
-
num_cpus = _total
|
58
|
+
_num_cpus = min(_num_cpus, _total)
|
62
59
|
|
63
60
|
if initargs is None:
|
64
61
|
initargs = []
|
65
62
|
|
66
63
|
with get_context(CONTEXT).Pool(processes=_num_cpus, initializer=initializer, initargs=initargs) as pool:
|
64
|
+
n = 0
|
67
65
|
for result in pool.imap(func, *iterables): # type: ignore[arg-type]
|
68
66
|
results[n] = result
|
69
67
|
n += 1
|
@@ -12,10 +12,10 @@ sonusai/deprecated/tplot.py,sha256=0p238DvTaP4oU9y-dp0JdLaTV4TKrooAwbx7zdz_QAc,1
|
|
12
12
|
sonusai/doc/__init__.py,sha256=KyQ26Um0RM8A3GYsb_tbFH64RwpoAw6lja2f_moUWas,33
|
13
13
|
sonusai/doc/doc.py,sha256=VZXauwbOb-VIufWw-lu0yfrd6jMRPeFeVPaaEjZNvn4,18881
|
14
14
|
sonusai/doc.py,sha256=zSmXpioB0YS_5-7kqfS5cr--veSaXkxRKzldId9Hyoc,878
|
15
|
-
sonusai/genft.py,sha256=
|
16
|
-
sonusai/genmetrics.py,sha256=
|
17
|
-
sonusai/genmix.py,sha256=
|
18
|
-
sonusai/genmixdb.py,sha256=
|
15
|
+
sonusai/genft.py,sha256=z9J4-aYZdPw50_56QMOSaofLNadO5b7htxtDgd0Qu88,5227
|
16
|
+
sonusai/genmetrics.py,sha256=G1lIgeIAu5EmalDR7j0rbSRP0dyndY4w35xUT5iToYU,4958
|
17
|
+
sonusai/genmix.py,sha256=4YEPvUnFCAexwW540LyzXsFq9QODE4GgOrCZOvigVJA,6179
|
18
|
+
sonusai/genmixdb.py,sha256=UmkiQTK8W5hRBVGlCBCJnBBnXCK1yJj7bhuXNtyGM38,19203
|
19
19
|
sonusai/lsdb.py,sha256=0HOGDDndB3LT9cz9AaxKIpt9vslAoSP4F239gply4Xg,5149
|
20
20
|
sonusai/main.py,sha256=HbnEia1B1-Z-mlHkLfojH8aj9GIpL1Btw3oH60T_CCQ,2590
|
21
21
|
sonusai/metrics/__init__.py,sha256=ssV6JEK_oklRSocsp6HMcG-GtJvV8IkRQtdKhHHmwU8,878
|
@@ -27,7 +27,7 @@ sonusai/metrics/calc_pesq.py,sha256=dCztUTaPyyjkUI2DpejqhiPzQv4FOtigzffFnDXDs-M,
|
|
27
27
|
sonusai/metrics/calc_phase_distance.py,sha256=-aNZEkfqxv3UjQsYcGqJ-Ips-ZAktBcykGJ6O2seHjA,1863
|
28
28
|
sonusai/metrics/calc_sa_sdr.py,sha256=IdCzlQ_w94A3eK42t-gy_DrFN_tziwfDjTU6-WKuCFs,2531
|
29
29
|
sonusai/metrics/calc_sample_weights.py,sha256=0O2EH1-FKlCa0HFgKPUF1BJiknR1hCH7zLbXnoXH7Ag,945
|
30
|
-
sonusai/metrics/calc_segsnr_f.py,sha256
|
30
|
+
sonusai/metrics/calc_segsnr_f.py,sha256=-ncM0OGRcOBDh2PnGsQOQccHs1QXHBTd3eCv4YpF3fs,2923
|
31
31
|
sonusai/metrics/calc_speech.py,sha256=8QhOpupbQOte9l3a4RsUrmSsG0qXtAeMcGfT2tMDzhs,14776
|
32
32
|
sonusai/metrics/calc_wer.py,sha256=1MQYMx8ldHeodtJEtGibvDKhvSaGe6DBmZV4L8qOMgg,2362
|
33
33
|
sonusai/metrics/calc_wsdr.py,sha256=vcALY-zuhyThRa1QMz2qW8L9kSBc2v32gV9u8bV7VaM,2556
|
@@ -35,7 +35,7 @@ sonusai/metrics/class_summary.py,sha256=qBWxtQ9YKJUzk5LsjDuwnYEKrpfwubF-vZZL0Hbc
|
|
35
35
|
sonusai/metrics/confusion_matrix_summary.py,sha256=eZFmt7k5Eanx7FYPwcfnzVq-AMYNSP03gfj9GtsfHWI,3841
|
36
36
|
sonusai/metrics/one_hot.py,sha256=jo-YsiDVr3PYoZTHhA0t24-VpSXEsZ4lukrP1xFbXAQ,13810
|
37
37
|
sonusai/metrics/snr_summary.py,sha256=sRUE6XI5PFFhaSpag537WUnukbMizOeMCwVQ2ww34Cw,5617
|
38
|
-
sonusai/mixture/__init__.py,sha256=
|
38
|
+
sonusai/mixture/__init__.py,sha256=NeXnrPIgDB-33WA0wva7m41SGOiO6biyKiDKK9o_W28,5650
|
39
39
|
sonusai/mixture/audio.py,sha256=Tg0-HzSgZDttKwWwONqgK6qK4maTSmWcfiL1atZcIXQ,2390
|
40
40
|
sonusai/mixture/augmentation.py,sha256=QqAuM2mN5S4SkQtCg1eDSJEtGsxsa6MBYZ9IOGVBvxg,10372
|
41
41
|
sonusai/mixture/class_count.py,sha256=U_FiWBU_yH6_ZAmZRdeDKUQyS0fnTtyfJ2V1lgqkFls,605
|
@@ -68,7 +68,7 @@ sonusai/mixture/truth_functions/file.py,sha256=1jw7C3d45NXh4AZYfycyZm1aipX4xgEkp
|
|
68
68
|
sonusai/mixture/truth_functions/phoneme.py,sha256=5DbELzq6CDKmjvVndQzq_RzqOLCL7oBqiMEsAuak_UU,855
|
69
69
|
sonusai/mixture/truth_functions/sed.py,sha256=2Aq_q5POrGbfpBCPFbuXY7LTjiVi5-gNHHr6-mezZqs,3471
|
70
70
|
sonusai/mixture/truth_functions/target.py,sha256=FaIlsQUqEpP7pokCVQ_x19SLKzRT0Ncw4rgbv0e4_dw,3664
|
71
|
-
sonusai/mkwav.py,sha256=
|
71
|
+
sonusai/mkwav.py,sha256=scSULegmcm7zCCbi4YVI5sIEumxy2T01yNOQt5DlmOI,4064
|
72
72
|
sonusai/onnx_predict.py,sha256=Y1VUN0wuvloEW46uxg7X4ywaec_Xx92djCU3BP0KAx0,8699
|
73
73
|
sonusai/queries/__init__.py,sha256=bhoeOFfu9GA5DOUuxRrIev7MYdXaGN8xdKJ6BXyNNtQ,277
|
74
74
|
sonusai/queries/queries.py,sha256=u8tZCJVnw9wJlwc03ue63FFqD5CHAKe4PWLJk0z4rto,7589
|
@@ -107,7 +107,7 @@ sonusai/utils/max_text_width.py,sha256=pxiJMwb_zlkNntexgo7S6lAuF7NLLZvFdOCkxdsQJ
|
|
107
107
|
sonusai/utils/model_utils.py,sha256=OIJBhOjxR0wpxsd7A2r6J2AjqfdYgZzi6UEThw4S1lI,828
|
108
108
|
sonusai/utils/numeric_conversion.py,sha256=iFPXFU8C_1mW5tmDqHq8-xP1tL8nVaSmhQRakdCqy30,328
|
109
109
|
sonusai/utils/onnx_utils.py,sha256=mbat4xvLhKMSvMC2kTEc4ukc7PI_gjsG4IVGvzpcOd4,5764
|
110
|
-
sonusai/utils/parallel.py,sha256=
|
110
|
+
sonusai/utils/parallel.py,sha256=yvRZvZWPR5slM51i08m7sYx-Mvsb5oryCqqJXVoJ8tQ,2190
|
111
111
|
sonusai/utils/path_info.py,sha256=QY7iQ0nYpeEDnPN9RyPh4DsgYmVYsLrrlAzKuzkqX1o,118
|
112
112
|
sonusai/utils/print_mixture_details.py,sha256=Wh5M0aTy3NzxvR3P0HDlSq_S3G9L7LoQx-FnDCrHODs,2911
|
113
113
|
sonusai/utils/ranges.py,sha256=-TtAR0Vg_j4kYtJOvEOYQllBZEat_KfUKsfRxr5oj-o,1235
|
@@ -119,7 +119,7 @@ sonusai/utils/stratified_shuffle_split.py,sha256=d7WLUirywSvgZWkt_5a0F8YvTnJjuXl
|
|
119
119
|
sonusai/utils/write_audio.py,sha256=0lKdaX57N6H-UWdioqmXCJMjwT1eBz5B-bSGqDvloAc,838
|
120
120
|
sonusai/utils/yes_or_no.py,sha256=0h1okjXmDNbJp7rZJFR2V-HFU1GJDm3YFTUVmYExkOU,263
|
121
121
|
sonusai/vars.py,sha256=kBBzuvC8szmdIZEEDA7XXmD765addZKdM2aFipeGO1w,933
|
122
|
-
sonusai-0.19.
|
123
|
-
sonusai-0.19.
|
124
|
-
sonusai-0.19.
|
125
|
-
sonusai-0.19.
|
122
|
+
sonusai-0.19.6.dist-info/METADATA,sha256=29GCEKJsRdTRsDJw4_wdxUWgKckdPBDPO2WVo9Bz_sY,2536
|
123
|
+
sonusai-0.19.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
124
|
+
sonusai-0.19.6.dist-info/entry_points.txt,sha256=zMNjEphEPO6B3cD1GNpit7z-yA9tUU5-j3W2v-UWstU,92
|
125
|
+
sonusai-0.19.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|