sonusai 0.20.3__py3-none-any.whl → 1.0.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/__init__.py +16 -3
- sonusai/audiofe.py +241 -77
- sonusai/calc_metric_spenh.py +71 -73
- sonusai/config/__init__.py +3 -0
- sonusai/config/config.py +61 -0
- sonusai/config/config.yml +20 -0
- sonusai/config/constants.py +8 -0
- sonusai/constants.py +11 -0
- sonusai/data/genmixdb.yml +21 -36
- sonusai/{mixture/datatypes.py → datatypes.py} +91 -130
- sonusai/deprecated/plot.py +4 -5
- sonusai/doc/doc.py +4 -4
- sonusai/doc.py +11 -4
- sonusai/genft.py +43 -45
- sonusai/genmetrics.py +25 -19
- sonusai/genmix.py +54 -82
- sonusai/genmixdb.py +88 -264
- sonusai/ir_metric.py +30 -34
- sonusai/lsdb.py +41 -48
- sonusai/main.py +15 -22
- sonusai/metrics/calc_audio_stats.py +4 -293
- sonusai/metrics/calc_class_weights.py +4 -4
- sonusai/metrics/calc_optimal_thresholds.py +8 -5
- sonusai/metrics/calc_pesq.py +2 -2
- sonusai/metrics/calc_segsnr_f.py +4 -4
- sonusai/metrics/calc_speech.py +25 -13
- sonusai/metrics/class_summary.py +7 -7
- sonusai/metrics/confusion_matrix_summary.py +5 -5
- sonusai/metrics/one_hot.py +4 -4
- sonusai/metrics/snr_summary.py +7 -7
- sonusai/metrics_summary.py +38 -45
- sonusai/mixture/__init__.py +4 -104
- sonusai/mixture/audio.py +10 -39
- sonusai/mixture/class_balancing.py +103 -0
- sonusai/mixture/config.py +251 -271
- sonusai/mixture/constants.py +35 -39
- sonusai/mixture/data_io.py +25 -36
- sonusai/mixture/db_datatypes.py +58 -22
- sonusai/mixture/effects.py +386 -0
- sonusai/mixture/feature.py +7 -11
- sonusai/mixture/generation.py +478 -628
- sonusai/mixture/helpers.py +82 -184
- sonusai/mixture/ir_delay.py +3 -4
- sonusai/mixture/ir_effects.py +77 -0
- sonusai/mixture/log_duration_and_sizes.py +6 -12
- sonusai/mixture/mixdb.py +910 -729
- sonusai/mixture/pad_audio.py +35 -0
- sonusai/mixture/resample.py +7 -0
- sonusai/mixture/sox_effects.py +195 -0
- sonusai/mixture/sox_help.py +650 -0
- sonusai/mixture/spectral_mask.py +2 -2
- sonusai/mixture/truth.py +17 -15
- sonusai/mixture/truth_functions/crm.py +12 -12
- sonusai/mixture/truth_functions/energy.py +22 -22
- sonusai/mixture/truth_functions/file.py +5 -5
- sonusai/mixture/truth_functions/metadata.py +4 -4
- sonusai/mixture/truth_functions/metrics.py +4 -4
- sonusai/mixture/truth_functions/phoneme.py +3 -3
- sonusai/mixture/truth_functions/sed.py +11 -13
- sonusai/mixture/truth_functions/target.py +10 -10
- sonusai/mkwav.py +26 -29
- sonusai/onnx_predict.py +240 -88
- sonusai/queries/__init__.py +2 -2
- sonusai/queries/queries.py +38 -34
- sonusai/speech/librispeech.py +1 -1
- sonusai/speech/mcgill.py +1 -1
- sonusai/speech/timit.py +2 -2
- sonusai/summarize_metric_spenh.py +10 -17
- sonusai/utils/__init__.py +7 -1
- sonusai/utils/asl_p56.py +2 -2
- sonusai/utils/asr.py +2 -2
- sonusai/utils/asr_functions/aaware_whisper.py +4 -5
- sonusai/utils/choice.py +31 -0
- sonusai/utils/compress.py +1 -1
- sonusai/utils/dataclass_from_dict.py +19 -1
- sonusai/utils/energy_f.py +3 -3
- sonusai/utils/evaluate_random_rule.py +15 -0
- sonusai/utils/keyboard_interrupt.py +12 -0
- sonusai/utils/onnx_utils.py +3 -17
- sonusai/utils/print_mixture_details.py +21 -19
- sonusai/utils/{temp_seed.py → rand.py} +3 -3
- sonusai/utils/read_predict_data.py +2 -2
- sonusai/utils/reshape.py +3 -3
- sonusai/utils/stratified_shuffle_split.py +3 -3
- sonusai/{mixture → utils}/tokenized_shell_vars.py +1 -1
- sonusai/utils/write_audio.py +2 -2
- sonusai/vars.py +11 -4
- {sonusai-0.20.3.dist-info → sonusai-1.0.2.dist-info}/METADATA +4 -2
- sonusai-1.0.2.dist-info/RECORD +138 -0
- sonusai/mixture/augmentation.py +0 -444
- sonusai/mixture/class_count.py +0 -15
- sonusai/mixture/eq_rule_is_valid.py +0 -45
- sonusai/mixture/target_class_balancing.py +0 -107
- sonusai/mixture/targets.py +0 -175
- sonusai-0.20.3.dist-info/RECORD +0 -128
- {sonusai-0.20.3.dist-info → sonusai-1.0.2.dist-info}/WHEEL +0 -0
- {sonusai-0.20.3.dist-info → sonusai-1.0.2.dist-info}/entry_points.txt +0 -0
sonusai/genmix.py
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
"""sonusai genmix
|
2
2
|
|
3
|
-
usage: genmix [-
|
3
|
+
usage: genmix [-hvtsn] [-i MIXID] LOC
|
4
4
|
|
5
5
|
options:
|
6
6
|
-h, --help
|
7
7
|
-v, --verbose Be verbose.
|
8
8
|
-i MIXID, --mixid MIXID Mixture ID(s) to generate. [default: *].
|
9
|
-
-g, --target Save target. [default: False].
|
10
9
|
-t, --truth Save truth_t. [default: False].
|
11
10
|
-s, --segsnr Save segsnr_t. [default: False].
|
12
11
|
-n, --nopar Do not run in parallel. [default: False].
|
13
12
|
|
14
|
-
|
13
|
+
Create mixture data from a SonusAI mixture database.
|
15
14
|
|
16
15
|
Inputs:
|
17
16
|
LOC A SonusAI mixture database directory.
|
@@ -19,41 +18,26 @@ Inputs:
|
|
19
18
|
|
20
19
|
Outputs the following to the mixture database directory:
|
21
20
|
<id>
|
22
|
-
|
23
|
-
|
21
|
+
metadata.txt
|
22
|
+
sources.pkl
|
23
|
+
source.pkl
|
24
24
|
noise.pkl
|
25
|
-
|
25
|
+
mixture.pkl
|
26
26
|
truth_t.pkl (optional)
|
27
27
|
segsnr_t.pkl (optional)
|
28
|
-
metadata.txt
|
29
28
|
genmix.log
|
30
29
|
"""
|
31
30
|
|
32
|
-
import
|
33
|
-
|
34
|
-
from sonusai.mixture import GeneralizedIDs
|
35
|
-
from sonusai.mixture import GenMixData
|
36
|
-
|
37
|
-
|
38
|
-
def signal_handler(_sig, _frame):
|
39
|
-
import sys
|
40
|
-
|
41
|
-
from sonusai import logger
|
42
|
-
|
43
|
-
logger.info("Canceled due to keyboard interrupt")
|
44
|
-
sys.exit(1)
|
45
|
-
|
46
|
-
|
47
|
-
signal.signal(signal.SIGINT, signal_handler)
|
31
|
+
from sonusai.datatypes import GeneralizedIDs
|
32
|
+
from sonusai.datatypes import GenMixData
|
48
33
|
|
49
34
|
|
50
35
|
def genmix(
|
51
36
|
location: str,
|
52
37
|
mixids: GeneralizedIDs = "*",
|
53
|
-
save_target: bool = False,
|
54
38
|
compute_truth: bool = False,
|
55
39
|
compute_segsnr: bool = False,
|
56
|
-
|
40
|
+
cache: bool = False,
|
57
41
|
show_progress: bool = False,
|
58
42
|
force: bool = True,
|
59
43
|
no_par: bool = False,
|
@@ -71,11 +55,10 @@ def genmix(
|
|
71
55
|
partial(
|
72
56
|
_genmix_kernel,
|
73
57
|
location=location,
|
74
|
-
save_target=save_target,
|
75
58
|
compute_truth=compute_truth,
|
76
59
|
compute_segsnr=compute_segsnr,
|
60
|
+
cache=cache,
|
77
61
|
force=force,
|
78
|
-
write=write,
|
79
62
|
),
|
80
63
|
mixids,
|
81
64
|
progress=progress,
|
@@ -89,56 +72,43 @@ def genmix(
|
|
89
72
|
def _genmix_kernel(
|
90
73
|
m_id: int,
|
91
74
|
location: str,
|
92
|
-
save_target: bool,
|
93
75
|
compute_truth: bool,
|
94
76
|
compute_segsnr: bool,
|
77
|
+
cache: bool,
|
95
78
|
force: bool,
|
96
|
-
write: bool,
|
97
79
|
) -> GenMixData:
|
98
80
|
from sonusai.mixture import MixtureDatabase
|
99
|
-
from sonusai.mixture import write_cached_data
|
100
81
|
from sonusai.mixture import write_mixture_metadata
|
101
82
|
|
102
83
|
mixdb = MixtureDatabase(location)
|
103
84
|
|
104
85
|
result = GenMixData()
|
105
|
-
|
106
|
-
|
107
|
-
result.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
("targets", targets),
|
117
|
-
("noise", noise),
|
118
|
-
],
|
119
|
-
)
|
86
|
+
result.sources = mixdb.mixture_sources(m_id=m_id, force=force, cache=cache)
|
87
|
+
result.source = mixdb.mixture_source(m_id=m_id, sources=result.sources, force=force, cache=cache)
|
88
|
+
result.noise = mixdb.mixture_noise(m_id=m_id, sources=result.sources, force=force, cache=cache)
|
89
|
+
result.mixture = mixdb.mixture_mixture(
|
90
|
+
m_id=m_id,
|
91
|
+
sources=result.sources,
|
92
|
+
source=result.source,
|
93
|
+
noise=result.noise,
|
94
|
+
force=force,
|
95
|
+
cache=cache,
|
96
|
+
)
|
120
97
|
|
121
98
|
if compute_truth:
|
122
|
-
truth_t = mixdb.mixture_truth_t(m_id=m_id,
|
123
|
-
result.truth_t = truth_t
|
124
|
-
if write:
|
125
|
-
write_cached_data(mixdb.location, "mixture", mixdb.mixture(m_id).name, [("truth_t", truth_t)])
|
126
|
-
|
127
|
-
target = mixdb.mixture_target(m_id=m_id, targets=targets)
|
128
|
-
result.target = target
|
129
|
-
if save_target and write:
|
130
|
-
write_cached_data(mixdb.location, "mixture", mixdb.mixture(m_id).name, [("target", target)])
|
99
|
+
result.truth_t = mixdb.mixture_truth_t(m_id=m_id, force=force, cache=cache)
|
131
100
|
|
132
101
|
if compute_segsnr:
|
133
|
-
segsnr_t = mixdb.mixture_segsnr_t(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
102
|
+
result.segsnr_t = mixdb.mixture_segsnr_t(
|
103
|
+
m_id=m_id,
|
104
|
+
sources=result.sources,
|
105
|
+
source=result.source,
|
106
|
+
noise=result.noise,
|
107
|
+
force=force,
|
108
|
+
cache=cache,
|
109
|
+
)
|
110
|
+
|
111
|
+
if cache:
|
142
112
|
write_mixture_metadata(mixdb, m_id=m_id)
|
143
113
|
|
144
114
|
return result
|
@@ -147,10 +117,10 @@ def _genmix_kernel(
|
|
147
117
|
def main() -> None:
|
148
118
|
from docopt import docopt
|
149
119
|
|
150
|
-
import
|
120
|
+
from sonusai import __version__ as sai_version
|
151
121
|
from sonusai.utils import trim_docstring
|
152
122
|
|
153
|
-
args = docopt(trim_docstring(__doc__), version=
|
123
|
+
args = docopt(trim_docstring(__doc__), version=sai_version, options_first=True)
|
154
124
|
|
155
125
|
import time
|
156
126
|
from os.path import join
|
@@ -159,7 +129,7 @@ def main() -> None:
|
|
159
129
|
from sonusai import initial_log_messages
|
160
130
|
from sonusai import logger
|
161
131
|
from sonusai import update_console_handler
|
162
|
-
from sonusai.
|
132
|
+
from sonusai.constants import SAMPLE_RATE
|
163
133
|
from sonusai.mixture import MixtureDatabase
|
164
134
|
from sonusai.mixture import check_audio_files_exist
|
165
135
|
from sonusai.utils import human_readable_size
|
@@ -168,7 +138,6 @@ def main() -> None:
|
|
168
138
|
verbose = args["--verbose"]
|
169
139
|
location = args["LOC"]
|
170
140
|
mixids = args["--mixid"]
|
171
|
-
save_target = args["--target"]
|
172
141
|
compute_truth = args["--truth"]
|
173
142
|
compute_segsnr = args["--segsnr"]
|
174
143
|
no_par = args["--nopar"]
|
@@ -192,20 +161,16 @@ def main() -> None:
|
|
192
161
|
|
193
162
|
check_audio_files_exist(mixdb)
|
194
163
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
)
|
206
|
-
except Exception as e:
|
207
|
-
logger.debug(e)
|
208
|
-
raise
|
164
|
+
genmix(
|
165
|
+
location=location,
|
166
|
+
mixids=mixids,
|
167
|
+
compute_truth=compute_truth,
|
168
|
+
compute_segsnr=compute_segsnr,
|
169
|
+
cache=True,
|
170
|
+
show_progress=True,
|
171
|
+
force=True,
|
172
|
+
no_par=no_par,
|
173
|
+
)
|
209
174
|
|
210
175
|
logger.info(f"Wrote {len(mixids)} mixtures to {location}")
|
211
176
|
logger.info("")
|
@@ -224,4 +189,11 @@ def main() -> None:
|
|
224
189
|
|
225
190
|
|
226
191
|
if __name__ == "__main__":
|
227
|
-
|
192
|
+
from sonusai import exception_handler
|
193
|
+
from sonusai.utils import register_keyboard_interrupt
|
194
|
+
|
195
|
+
register_keyboard_interrupt()
|
196
|
+
try:
|
197
|
+
main()
|
198
|
+
except Exception as e:
|
199
|
+
exception_handler(e)
|