sonusai 0.19.9__py3-none-any.whl → 0.20.2__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/calc_metric_spenh.py +265 -233
- sonusai/data/genmixdb.yml +4 -2
- sonusai/data/silero_vad_v5.1.jit +0 -0
- sonusai/data/silero_vad_v5.1.onnx +0 -0
- sonusai/doc/doc.py +14 -0
- sonusai/genft.py +1 -1
- sonusai/genmetrics.py +15 -18
- sonusai/genmix.py +1 -1
- sonusai/genmixdb.py +30 -52
- sonusai/ir_metric.py +555 -0
- sonusai/metrics_summary.py +322 -0
- sonusai/mixture/__init__.py +6 -2
- sonusai/mixture/audio.py +139 -15
- sonusai/mixture/augmentation.py +199 -84
- sonusai/mixture/config.py +9 -4
- sonusai/mixture/constants.py +0 -1
- sonusai/mixture/datatypes.py +19 -10
- sonusai/mixture/generation.py +52 -64
- sonusai/mixture/helpers.py +38 -26
- sonusai/mixture/ir_delay.py +63 -0
- sonusai/mixture/mixdb.py +190 -46
- sonusai/mixture/targets.py +3 -6
- sonusai/mixture/truth_functions/energy.py +9 -5
- sonusai/mixture/truth_functions/metrics.py +1 -1
- sonusai/mkwav.py +1 -1
- sonusai/onnx_predict.py +1 -1
- sonusai/queries/queries.py +1 -1
- sonusai/utils/__init__.py +2 -0
- sonusai/utils/asr.py +1 -1
- sonusai/utils/load_object.py +8 -2
- sonusai/utils/stratified_shuffle_split.py +1 -1
- sonusai/utils/temp_seed.py +13 -0
- {sonusai-0.19.9.dist-info → sonusai-0.20.2.dist-info}/METADATA +2 -2
- {sonusai-0.19.9.dist-info → sonusai-0.20.2.dist-info}/RECORD +36 -35
- {sonusai-0.19.9.dist-info → sonusai-0.20.2.dist-info}/WHEEL +1 -1
- sonusai/mixture/soundfile_audio.py +0 -130
- sonusai/mixture/sox_audio.py +0 -476
- sonusai/mixture/sox_augmentation.py +0 -136
- sonusai/mixture/torchaudio_audio.py +0 -106
- sonusai/mixture/torchaudio_augmentation.py +0 -109
- {sonusai-0.19.9.dist-info → sonusai-0.20.2.dist-info}/entry_points.txt +0 -0
sonusai/data/genmixdb.yml
CHANGED
@@ -23,7 +23,8 @@ truth_configs: { }
|
|
23
23
|
|
24
24
|
asr_manifest: [ ]
|
25
25
|
|
26
|
-
target_augmentations:
|
26
|
+
target_augmentations:
|
27
|
+
- pre:
|
27
28
|
|
28
29
|
class_balancing_augmentation:
|
29
30
|
normalize: -3.5
|
@@ -39,7 +40,8 @@ noises:
|
|
39
40
|
- "${default_noise}"
|
40
41
|
|
41
42
|
noise_augmentations:
|
42
|
-
-
|
43
|
+
- pre:
|
44
|
+
normalize: -3.5
|
43
45
|
|
44
46
|
snrs:
|
45
47
|
- 99
|
Binary file
|
Binary file
|
sonusai/doc/doc.py
CHANGED
@@ -329,6 +329,20 @@ See 'augmentations' for details on augmentation rules.
|
|
329
329
|
# fmt: on
|
330
330
|
|
331
331
|
|
332
|
+
def doc_target_distortions() -> str:
|
333
|
+
import yaml
|
334
|
+
|
335
|
+
default = f"\nDefault value:\n\n{yaml.dump(get_default_config()['target_distortions'])}"
|
336
|
+
# fmt: off
|
337
|
+
return """
|
338
|
+
'target_distortions' is a mixture database configuration parameter that
|
339
|
+
specifies a list of distortion rules to use for each target.
|
340
|
+
|
341
|
+
See 'augmentations' for details on distortion rules.
|
342
|
+
""" + default
|
343
|
+
# fmt: on
|
344
|
+
|
345
|
+
|
332
346
|
def doc_noises() -> str:
|
333
347
|
default = f"\nDefault value: {get_default_config()['class_balancing']}"
|
334
348
|
# fmt: off
|
sonusai/genft.py
CHANGED
sonusai/genmetrics.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""sonusai genmetrics
|
2
2
|
|
3
|
-
usage: genmetrics [-
|
3
|
+
usage: genmetrics [-hvusd] [-i MIXID] [-n INCLUDE] [-x EXCLUDE] LOC
|
4
4
|
|
5
5
|
options:
|
6
6
|
-h, --help
|
@@ -8,6 +8,7 @@ options:
|
|
8
8
|
-i MIXID, --mixid MIXID Mixture ID(s) to generate. [default: *].
|
9
9
|
-n INCLUDE, --include INCLUDE Metrics to include. [default: all]
|
10
10
|
-x EXCLUDE, --exclude EXCLUDE Metrics to exclude. [default: none]
|
11
|
+
-u, --update Update metrics (do not regenerate existing metrics).
|
11
12
|
-s, --supported Show list of supported metrics.
|
12
13
|
-d, --dryrun Show list of metrics that will be generated and exit.
|
13
14
|
|
@@ -60,16 +61,15 @@ def signal_handler(_sig, _frame):
|
|
60
61
|
signal.signal(signal.SIGINT, signal_handler)
|
61
62
|
|
62
63
|
|
63
|
-
def _process_mixture(mixid: int, location: str, metrics: list[str]) ->
|
64
|
+
def _process_mixture(mixid: int, location: str, metrics: list[str], update: bool = False) -> set[str]:
|
64
65
|
from sonusai.mixture import MixtureDatabase
|
65
66
|
from sonusai.mixture import write_cached_data
|
66
67
|
|
67
68
|
mixdb = MixtureDatabase(location)
|
69
|
+
results = mixdb.mixture_metrics(m_id=mixid, metrics=metrics, force=not update)
|
70
|
+
write_cached_data(mixdb.location, "mixture", mixdb.mixture(mixid).name, list(results.items()))
|
68
71
|
|
69
|
-
|
70
|
-
write_data = list(zip(metrics, values, strict=False))
|
71
|
-
|
72
|
-
write_cached_data(mixdb.location, "mixture", mixdb.mixture(mixid).name, write_data)
|
72
|
+
return set(results.keys())
|
73
73
|
|
74
74
|
|
75
75
|
def main() -> None:
|
@@ -85,6 +85,7 @@ def main() -> None:
|
|
85
85
|
mixids = args["--mixid"]
|
86
86
|
includes = {x.strip() for x in args["--include"].replace(" ", ",").lower().split(",") if x != ""}
|
87
87
|
excludes = {x.strip() for x in args["--exclude"].replace(" ", ",").lower().split(",") if x != ""}
|
88
|
+
update = args["--update"]
|
88
89
|
show_supported = args["--supported"]
|
89
90
|
dryrun = args["--dryrun"]
|
90
91
|
location = args["LOC"]
|
@@ -141,20 +142,14 @@ def main() -> None:
|
|
141
142
|
|
142
143
|
requested = included_metrics - excluded_metrics
|
143
144
|
|
144
|
-
|
145
|
-
dependencies: set[str] = set()
|
146
|
-
for metric in requested:
|
147
|
-
if metric.startswith("mxwer"):
|
148
|
-
dependencies.add("mxasr." + metric[6:])
|
149
|
-
dependencies.add("tasr." + metric[6:])
|
150
|
-
|
151
|
-
metrics = sorted(requested | dependencies)
|
145
|
+
metrics = sorted(requested)
|
152
146
|
|
153
147
|
if len(metrics) == 0:
|
154
148
|
logger.warning("No metrics were requested")
|
155
149
|
sys.exit(1)
|
156
150
|
|
157
|
-
logger.info(
|
151
|
+
logger.info("Generating metrics:")
|
152
|
+
logger.info(f"{', '.join(metrics)}")
|
158
153
|
if dryrun:
|
159
154
|
sys.exit(0)
|
160
155
|
|
@@ -163,14 +158,16 @@ def main() -> None:
|
|
163
158
|
logger.info(f"Found {len(mixids):,} mixtures to process")
|
164
159
|
|
165
160
|
progress = track(total=len(mixids), desc="genmetrics")
|
166
|
-
par_track(
|
167
|
-
partial(_process_mixture, location=location, metrics=metrics),
|
161
|
+
results = par_track(
|
162
|
+
partial(_process_mixture, location=location, metrics=metrics, update=update),
|
168
163
|
mixids,
|
169
164
|
progress=progress,
|
170
165
|
)
|
171
166
|
progress.close()
|
172
167
|
|
173
|
-
|
168
|
+
written_metrics = sorted(set().union(*results))
|
169
|
+
logger.info(f"Wrote metrics for {len(mixids)} mixtures to {location}:")
|
170
|
+
logger.info(f"{', '.join(written_metrics)}")
|
174
171
|
logger.info("")
|
175
172
|
|
176
173
|
end_time = time.monotonic()
|
sonusai/genmix.py
CHANGED
@@ -139,7 +139,7 @@ def _genmix_kernel(
|
|
139
139
|
result.mixture = mixture
|
140
140
|
if write:
|
141
141
|
write_cached_data(mixdb.location, "mixture", mixdb.mixture(m_id).name, [("mixture", mixture)])
|
142
|
-
write_mixture_metadata(mixdb, m_id)
|
142
|
+
write_mixture_metadata(mixdb, m_id=m_id)
|
143
143
|
|
144
144
|
return result
|
145
145
|
|
sonusai/genmixdb.py
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
"""sonusai genmixdb
|
2
2
|
|
3
|
-
usage: genmixdb [-
|
3
|
+
usage: genmixdb [-hvmdjn] LOC
|
4
4
|
|
5
5
|
options:
|
6
6
|
-h, --help
|
7
7
|
-v, --verbose Be verbose.
|
8
8
|
-m, --mix ave mixture data. [default: False].
|
9
|
-
-f, --ft Save feature/truth_f data. [default: False].
|
10
|
-
-s, --segsnr Save segsnr data. [default: False].
|
11
9
|
-d, --dryrun Perform a dry run showing the processed config. [default: False].
|
12
10
|
-j, --json Save JSON version of database. [default: False].
|
13
11
|
-n, --nopar Do not run in parallel. [default: False].
|
@@ -116,6 +114,9 @@ will find all .wav files in the specified directories and process them as target
|
|
116
114
|
|
117
115
|
import signal
|
118
116
|
|
117
|
+
from sonusai.mixture import Mixture
|
118
|
+
from sonusai.mixture import MixtureDatabase
|
119
|
+
|
119
120
|
|
120
121
|
def signal_handler(_sig, _frame):
|
121
122
|
import sys
|
@@ -132,8 +133,6 @@ signal.signal(signal.SIGINT, signal_handler)
|
|
132
133
|
def genmixdb(
|
133
134
|
location: str,
|
134
135
|
save_mix: bool = False,
|
135
|
-
save_ft: bool = False,
|
136
|
-
save_segsnr: bool = False,
|
137
136
|
logging: bool = True,
|
138
137
|
show_progress: bool = False,
|
139
138
|
test: bool = False,
|
@@ -151,6 +150,7 @@ def genmixdb(
|
|
151
150
|
from sonusai.mixture import AugmentationRule
|
152
151
|
from sonusai.mixture import MixtureDatabase
|
153
152
|
from sonusai.mixture import balance_targets
|
153
|
+
from sonusai.mixture import generate_mixtures
|
154
154
|
from sonusai.mixture import get_all_snrs_from_config
|
155
155
|
from sonusai.mixture import get_augmentation_rules
|
156
156
|
from sonusai.mixture import get_augmented_targets
|
@@ -316,8 +316,10 @@ def genmixdb(
|
|
316
316
|
f"{seconds_to_hms(seconds=noise_audio_duration)}"
|
317
317
|
)
|
318
318
|
|
319
|
-
|
320
|
-
|
319
|
+
if logging:
|
320
|
+
logger.info("Generating mixtures")
|
321
|
+
|
322
|
+
used_noise_files, used_noise_samples, mixtures = generate_mixtures(
|
321
323
|
noise_mix_mode=mixdb.noise_mix_mode,
|
322
324
|
augmented_targets=augmented_targets,
|
323
325
|
target_files=target_files,
|
@@ -330,17 +332,16 @@ def genmixdb(
|
|
330
332
|
num_classes=mixdb.num_classes,
|
331
333
|
feature_step_samples=mixdb.feature_step_samples,
|
332
334
|
num_ir=mixdb.num_impulse_response_files,
|
333
|
-
test=test,
|
334
335
|
)
|
335
336
|
|
336
|
-
num_mixtures = len(
|
337
|
+
num_mixtures = len(mixtures)
|
337
338
|
update_mixid_width(location, num_mixtures, test)
|
338
339
|
|
339
340
|
if logging:
|
340
341
|
logger.info("")
|
341
342
|
logger.info(f"Found {num_mixtures:,} mixtures to process")
|
342
343
|
|
343
|
-
total_duration = float(sum([mixture.samples for mixture in
|
344
|
+
total_duration = float(sum([mixture.samples for mixture in mixtures])) / SAMPLE_RATE
|
344
345
|
|
345
346
|
if logging:
|
346
347
|
log_duration_and_sizes(
|
@@ -362,23 +363,29 @@ def genmixdb(
|
|
362
363
|
|
363
364
|
# Fill in the details
|
364
365
|
if logging:
|
365
|
-
logger.info("
|
366
|
+
logger.info("Processing mixtures")
|
366
367
|
progress = track(total=num_mixtures, disable=not show_progress)
|
367
|
-
par_track(
|
368
|
+
mixtures = par_track(
|
368
369
|
partial(
|
369
370
|
_process_mixture,
|
370
371
|
location=location,
|
371
372
|
save_mix=save_mix,
|
372
|
-
save_ft=save_ft,
|
373
|
-
save_segsnr=save_segsnr,
|
374
373
|
test=test,
|
375
374
|
),
|
376
|
-
|
375
|
+
mixtures,
|
377
376
|
progress=progress,
|
378
377
|
no_par=no_par,
|
379
378
|
)
|
380
379
|
progress.close()
|
381
380
|
|
381
|
+
populate_mixture_table(
|
382
|
+
location=location,
|
383
|
+
mixtures=mixtures,
|
384
|
+
test=test,
|
385
|
+
logging=logging,
|
386
|
+
show_progress=show_progress,
|
387
|
+
)
|
388
|
+
|
382
389
|
total_noise_files = len(noise_files)
|
383
390
|
|
384
391
|
total_samples = mixdb.total_samples()
|
@@ -409,32 +416,23 @@ def genmixdb(
|
|
409
416
|
|
410
417
|
|
411
418
|
def _process_mixture(
|
412
|
-
|
419
|
+
mixture: Mixture,
|
413
420
|
location: str,
|
414
421
|
save_mix: bool,
|
415
|
-
save_ft: bool,
|
416
|
-
save_segsnr: bool,
|
417
422
|
test: bool,
|
418
|
-
) ->
|
423
|
+
) -> Mixture:
|
419
424
|
from functools import partial
|
420
425
|
|
421
|
-
from sonusai.mixture import
|
422
|
-
from sonusai.mixture import clear_cached_data
|
423
|
-
from sonusai.mixture import update_mixture_table
|
426
|
+
from sonusai.mixture import update_mixture
|
424
427
|
from sonusai.mixture import write_cached_data
|
425
428
|
from sonusai.mixture import write_mixture_metadata
|
426
429
|
|
427
|
-
|
428
|
-
|
429
|
-
genmix_data = update_mixture_table(location, m_id, with_data, test)
|
430
|
-
|
431
|
-
mixdb = MixtureDatabase(location, test)
|
432
|
-
mixture = mixdb.mixture(m_id)
|
430
|
+
mixdb = MixtureDatabase(location, test=test)
|
431
|
+
mixture, genmix_data = update_mixture(mixdb, mixture, save_mix)
|
433
432
|
|
434
433
|
write = partial(write_cached_data, location=location, name="mixture", index=mixture.name)
|
435
|
-
clear = partial(clear_cached_data, location=location, name="mixture", index=mixture.name)
|
436
434
|
|
437
|
-
if
|
435
|
+
if save_mix:
|
438
436
|
write(
|
439
437
|
items=[
|
440
438
|
("targets", genmix_data.targets),
|
@@ -444,25 +442,9 @@ def _process_mixture(
|
|
444
442
|
]
|
445
443
|
)
|
446
444
|
|
447
|
-
|
448
|
-
clear(items=["feature", "truth_f"])
|
449
|
-
feature, truth_f = mixdb.mixture_ft(m_id)
|
450
|
-
write(
|
451
|
-
items=[
|
452
|
-
("feature", feature),
|
453
|
-
("truth_f", truth_f),
|
454
|
-
]
|
455
|
-
)
|
456
|
-
|
457
|
-
if save_segsnr:
|
458
|
-
clear(items=["segsnr"])
|
459
|
-
segsnr = mixdb.mixture_segsnr(m_id)
|
460
|
-
write(items=[("segsnr", segsnr)])
|
461
|
-
|
462
|
-
if not save_mix:
|
463
|
-
clear(items=["targets", "target", "noise", "mixture"])
|
445
|
+
write_mixture_metadata(mixdb, mixture=mixture)
|
464
446
|
|
465
|
-
|
447
|
+
return mixture
|
466
448
|
|
467
449
|
|
468
450
|
def main() -> None:
|
@@ -491,8 +473,6 @@ def main() -> None:
|
|
491
473
|
|
492
474
|
verbose = args["--verbose"]
|
493
475
|
save_mix = args["--mix"]
|
494
|
-
save_ft = args["--ft"]
|
495
|
-
save_segsnr = args["--segsnr"]
|
496
476
|
dryrun = args["--dryrun"]
|
497
477
|
save_json = args["--json"]
|
498
478
|
no_par = args["--nopar"]
|
@@ -522,8 +502,6 @@ def main() -> None:
|
|
522
502
|
genmixdb(
|
523
503
|
location=location,
|
524
504
|
save_mix=save_mix,
|
525
|
-
save_ft=save_ft,
|
526
|
-
save_segsnr=save_segsnr,
|
527
505
|
show_progress=True,
|
528
506
|
save_json=save_json,
|
529
507
|
no_par=no_par,
|