sonusai 1.0.16__cp311-abi3-macosx_10_12_x86_64.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 +170 -0
- sonusai/aawscd_probwrite.py +148 -0
- sonusai/audiofe.py +481 -0
- sonusai/calc_metric_spenh.py +1136 -0
- sonusai/config/__init__.py +0 -0
- sonusai/config/asr.py +21 -0
- sonusai/config/config.py +65 -0
- sonusai/config/config.yml +49 -0
- sonusai/config/constants.py +53 -0
- sonusai/config/ir.py +124 -0
- sonusai/config/ir_delay.py +62 -0
- sonusai/config/source.py +275 -0
- sonusai/config/spectral_masks.py +15 -0
- sonusai/config/truth.py +64 -0
- sonusai/constants.py +14 -0
- sonusai/data/__init__.py +0 -0
- sonusai/data/silero_vad_v5.1.jit +0 -0
- sonusai/data/silero_vad_v5.1.onnx +0 -0
- sonusai/data/speech_ma01_01.wav +0 -0
- sonusai/data/whitenoise.wav +0 -0
- sonusai/datatypes.py +383 -0
- sonusai/deprecated/gentcst.py +632 -0
- sonusai/deprecated/plot.py +519 -0
- sonusai/deprecated/tplot.py +365 -0
- sonusai/doc.py +52 -0
- sonusai/doc_strings/__init__.py +1 -0
- sonusai/doc_strings/doc_strings.py +531 -0
- sonusai/genft.py +196 -0
- sonusai/genmetrics.py +183 -0
- sonusai/genmix.py +199 -0
- sonusai/genmixdb.py +235 -0
- sonusai/ir_metric.py +551 -0
- sonusai/lsdb.py +141 -0
- sonusai/main.py +134 -0
- sonusai/metrics/__init__.py +43 -0
- sonusai/metrics/calc_audio_stats.py +42 -0
- sonusai/metrics/calc_class_weights.py +90 -0
- sonusai/metrics/calc_optimal_thresholds.py +73 -0
- sonusai/metrics/calc_pcm.py +45 -0
- sonusai/metrics/calc_pesq.py +36 -0
- sonusai/metrics/calc_phase_distance.py +43 -0
- sonusai/metrics/calc_sa_sdr.py +64 -0
- sonusai/metrics/calc_sample_weights.py +25 -0
- sonusai/metrics/calc_segsnr_f.py +82 -0
- sonusai/metrics/calc_speech.py +382 -0
- sonusai/metrics/calc_wer.py +71 -0
- sonusai/metrics/calc_wsdr.py +57 -0
- sonusai/metrics/calculate_metrics.py +395 -0
- sonusai/metrics/class_summary.py +74 -0
- sonusai/metrics/confusion_matrix_summary.py +75 -0
- sonusai/metrics/one_hot.py +283 -0
- sonusai/metrics/snr_summary.py +128 -0
- sonusai/metrics_summary.py +314 -0
- sonusai/mixture/__init__.py +15 -0
- sonusai/mixture/audio.py +187 -0
- sonusai/mixture/class_balancing.py +103 -0
- sonusai/mixture/constants.py +3 -0
- sonusai/mixture/data_io.py +173 -0
- sonusai/mixture/db.py +169 -0
- sonusai/mixture/db_datatypes.py +92 -0
- sonusai/mixture/effects.py +344 -0
- sonusai/mixture/feature.py +78 -0
- sonusai/mixture/generation.py +1116 -0
- sonusai/mixture/helpers.py +351 -0
- sonusai/mixture/ir_effects.py +77 -0
- sonusai/mixture/log_duration_and_sizes.py +23 -0
- sonusai/mixture/mixdb.py +1857 -0
- 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 +51 -0
- sonusai/mixture/truth.py +61 -0
- sonusai/mixture/truth_functions/__init__.py +45 -0
- sonusai/mixture/truth_functions/crm.py +105 -0
- sonusai/mixture/truth_functions/energy.py +222 -0
- sonusai/mixture/truth_functions/file.py +48 -0
- sonusai/mixture/truth_functions/metadata.py +24 -0
- sonusai/mixture/truth_functions/metrics.py +28 -0
- sonusai/mixture/truth_functions/phoneme.py +18 -0
- sonusai/mixture/truth_functions/sed.py +98 -0
- sonusai/mixture/truth_functions/target.py +142 -0
- sonusai/mkwav.py +135 -0
- sonusai/onnx_predict.py +363 -0
- sonusai/parse/__init__.py +0 -0
- sonusai/parse/expand.py +156 -0
- sonusai/parse/parse_source_directive.py +129 -0
- sonusai/parse/rand.py +214 -0
- sonusai/py.typed +0 -0
- sonusai/queries/__init__.py +0 -0
- sonusai/queries/queries.py +239 -0
- sonusai/rs.abi3.so +0 -0
- sonusai/rs.pyi +1 -0
- sonusai/rust/__init__.py +0 -0
- sonusai/speech/__init__.py +0 -0
- sonusai/speech/l2arctic.py +121 -0
- sonusai/speech/librispeech.py +102 -0
- sonusai/speech/mcgill.py +71 -0
- sonusai/speech/textgrid.py +89 -0
- sonusai/speech/timit.py +138 -0
- sonusai/speech/types.py +12 -0
- sonusai/speech/vctk.py +53 -0
- sonusai/speech/voxceleb.py +108 -0
- sonusai/utils/__init__.py +3 -0
- sonusai/utils/asl_p56.py +130 -0
- sonusai/utils/asr.py +91 -0
- sonusai/utils/asr_functions/__init__.py +3 -0
- sonusai/utils/asr_functions/aaware_whisper.py +69 -0
- sonusai/utils/audio_devices.py +50 -0
- sonusai/utils/braced_glob.py +50 -0
- sonusai/utils/calculate_input_shape.py +26 -0
- sonusai/utils/choice.py +51 -0
- sonusai/utils/compress.py +25 -0
- sonusai/utils/convert_string_to_number.py +6 -0
- sonusai/utils/create_timestamp.py +5 -0
- sonusai/utils/create_ts_name.py +14 -0
- sonusai/utils/dataclass_from_dict.py +27 -0
- sonusai/utils/db.py +16 -0
- sonusai/utils/docstring.py +53 -0
- sonusai/utils/energy_f.py +44 -0
- sonusai/utils/engineering_number.py +166 -0
- sonusai/utils/evaluate_random_rule.py +15 -0
- sonusai/utils/get_frames_per_batch.py +2 -0
- sonusai/utils/get_label_names.py +20 -0
- sonusai/utils/grouper.py +6 -0
- sonusai/utils/human_readable_size.py +7 -0
- sonusai/utils/keyboard_interrupt.py +12 -0
- sonusai/utils/load_object.py +21 -0
- sonusai/utils/max_text_width.py +9 -0
- sonusai/utils/model_utils.py +28 -0
- sonusai/utils/numeric_conversion.py +11 -0
- sonusai/utils/onnx_utils.py +155 -0
- sonusai/utils/parallel.py +162 -0
- sonusai/utils/path_info.py +7 -0
- sonusai/utils/print_mixture_details.py +60 -0
- sonusai/utils/rand.py +13 -0
- sonusai/utils/ranges.py +43 -0
- sonusai/utils/read_predict_data.py +32 -0
- sonusai/utils/reshape.py +154 -0
- sonusai/utils/seconds_to_hms.py +7 -0
- sonusai/utils/stacked_complex.py +82 -0
- sonusai/utils/stratified_shuffle_split.py +170 -0
- sonusai/utils/tokenized_shell_vars.py +143 -0
- sonusai/utils/write_audio.py +26 -0
- sonusai/utils/yes_or_no.py +8 -0
- sonusai/vars.py +47 -0
- sonusai-1.0.16.dist-info/METADATA +56 -0
- sonusai-1.0.16.dist-info/RECORD +150 -0
- sonusai-1.0.16.dist-info/WHEEL +4 -0
- sonusai-1.0.16.dist-info/entry_points.txt +3 -0
sonusai/genmixdb.py
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
"""sonusai genmixdb
|
2
|
+
|
3
|
+
usage: genmixdb [-hvmdjn] LOC
|
4
|
+
|
5
|
+
options:
|
6
|
+
-h, --help
|
7
|
+
-v, --verbose Be verbose.
|
8
|
+
-m, --mix Save mixture data. [default: False].
|
9
|
+
-d, --dryrun Perform a dry run showing the processed config. [default: False].
|
10
|
+
-j, --json Save JSON version of database. [default: False].
|
11
|
+
-n, --nopar Do not run in parallel. [default: False].
|
12
|
+
|
13
|
+
Create mixture database data for training and evaluation. Optionally, also create mixture audio and feature/truth data.
|
14
|
+
|
15
|
+
genmixdb creates a database of training and evaluation feature and truth data generation information. It allows the
|
16
|
+
choice of audio neural-network feature types that are supported by the Aaware real-time front-end and truth data that is
|
17
|
+
synchronized frame-by-frame with the feature data.
|
18
|
+
|
19
|
+
For details, see sonusai doc.
|
20
|
+
|
21
|
+
"""
|
22
|
+
|
23
|
+
from functools import partial
|
24
|
+
from random import seed
|
25
|
+
|
26
|
+
import yaml
|
27
|
+
|
28
|
+
from sonusai import logger
|
29
|
+
from sonusai.constants import SAMPLE_RATE
|
30
|
+
from sonusai.datatypes import Mixture
|
31
|
+
from sonusai.mixture import MixtureDatabase
|
32
|
+
from sonusai.mixture.data_io import write_cached_data
|
33
|
+
from sonusai.mixture.generation import DatabaseManager
|
34
|
+
from sonusai.mixture.generation import update_mixture
|
35
|
+
from sonusai.mixture.helpers import write_mixture_metadata
|
36
|
+
from sonusai.mixture.log_duration_and_sizes import log_duration_and_sizes
|
37
|
+
from sonusai.utils.parallel import par_track
|
38
|
+
from sonusai.utils.parallel import track
|
39
|
+
|
40
|
+
|
41
|
+
def genmixdb(
|
42
|
+
location: str,
|
43
|
+
save_mix: bool = False,
|
44
|
+
logging: bool = True,
|
45
|
+
show_progress: bool = False,
|
46
|
+
test: bool = False,
|
47
|
+
verbose: bool = False,
|
48
|
+
save_json: bool = False,
|
49
|
+
no_par: bool = False,
|
50
|
+
) -> None:
|
51
|
+
dbm = DatabaseManager(location, test, verbose, logging)
|
52
|
+
mixdb = MixtureDatabase(location, test)
|
53
|
+
|
54
|
+
dbm.populate_top_table()
|
55
|
+
dbm.populate_class_label_table()
|
56
|
+
dbm.populate_class_weights_threshold_table()
|
57
|
+
dbm.populate_spectral_mask_table()
|
58
|
+
dbm.populate_truth_parameters_table()
|
59
|
+
|
60
|
+
seed(dbm.config["seed"])
|
61
|
+
|
62
|
+
if logging:
|
63
|
+
logger.debug(f"Seed: {dbm.config['seed']}")
|
64
|
+
logger.debug("Configuration:")
|
65
|
+
logger.debug(yaml.dump(dbm.config))
|
66
|
+
|
67
|
+
dbm.populate_source_file_table(show_progress)
|
68
|
+
dbm.populate_impulse_response_file_table(show_progress)
|
69
|
+
|
70
|
+
mixtures = dbm.generate_mixtures()
|
71
|
+
num_mixtures = len(mixtures)
|
72
|
+
|
73
|
+
if logging:
|
74
|
+
logger.info(f"Found {num_mixtures:,} mixtures to process")
|
75
|
+
|
76
|
+
total_duration = float(sum([mixture.samples for mixture in mixtures])) / SAMPLE_RATE
|
77
|
+
|
78
|
+
if logging:
|
79
|
+
log_duration_and_sizes(
|
80
|
+
total_duration=total_duration,
|
81
|
+
feature_step_samples=mixdb.feature_step_samples,
|
82
|
+
feature_parameters=mixdb.feature_parameters,
|
83
|
+
stride=mixdb.fg_stride,
|
84
|
+
desc="Estimated",
|
85
|
+
)
|
86
|
+
logger.info(
|
87
|
+
f"Feature shape: "
|
88
|
+
f"{mixdb.fg_stride} x {mixdb.feature_parameters} "
|
89
|
+
f"({mixdb.fg_stride * mixdb.feature_parameters} total parameters)"
|
90
|
+
)
|
91
|
+
logger.info(f"Feature samples: {mixdb.feature_samples} samples ({mixdb.feature_ms} ms)")
|
92
|
+
logger.info(f"Feature step samples: {mixdb.feature_step_samples} samples ({mixdb.feature_step_ms} ms)")
|
93
|
+
logger.info("")
|
94
|
+
|
95
|
+
# Fill in the details
|
96
|
+
if logging:
|
97
|
+
logger.info("Processing mixtures")
|
98
|
+
progress = track(total=num_mixtures, disable=not show_progress)
|
99
|
+
mixtures = par_track(
|
100
|
+
partial(
|
101
|
+
_process_mixture,
|
102
|
+
location=location,
|
103
|
+
save_mix=save_mix,
|
104
|
+
test=test,
|
105
|
+
),
|
106
|
+
mixtures,
|
107
|
+
progress=progress,
|
108
|
+
no_par=no_par,
|
109
|
+
pass_index=True,
|
110
|
+
)
|
111
|
+
progress.close()
|
112
|
+
|
113
|
+
dbm.populate_mixture_table(mixtures=mixtures, show_progress=show_progress)
|
114
|
+
|
115
|
+
total_duration = float(mixdb.total_samples() / SAMPLE_RATE)
|
116
|
+
|
117
|
+
if logging:
|
118
|
+
log_duration_and_sizes(
|
119
|
+
total_duration=total_duration,
|
120
|
+
feature_step_samples=mixdb.feature_step_samples,
|
121
|
+
feature_parameters=mixdb.feature_parameters,
|
122
|
+
stride=mixdb.fg_stride,
|
123
|
+
desc="Actual",
|
124
|
+
)
|
125
|
+
logger.info("")
|
126
|
+
|
127
|
+
if not test and save_json:
|
128
|
+
if logging:
|
129
|
+
logger.info(f"Writing JSON version of database to {location}")
|
130
|
+
mixdb = MixtureDatabase(location)
|
131
|
+
mixdb.save()
|
132
|
+
|
133
|
+
|
134
|
+
def _process_mixture(
|
135
|
+
index: int,
|
136
|
+
mixture: Mixture,
|
137
|
+
location: str,
|
138
|
+
save_mix: bool,
|
139
|
+
test: bool,
|
140
|
+
) -> Mixture:
|
141
|
+
mixdb = MixtureDatabase(location, test=test)
|
142
|
+
mixture.name = f"{index:0{mixdb.mixid_width}}"
|
143
|
+
mixture, genmix_data = update_mixture(mixdb, mixture, save_mix)
|
144
|
+
|
145
|
+
write = partial(write_cached_data, location=location, name="mixture", index=mixture.name)
|
146
|
+
|
147
|
+
if save_mix:
|
148
|
+
write(
|
149
|
+
items={
|
150
|
+
"sources": genmix_data.sources,
|
151
|
+
"source": genmix_data.source,
|
152
|
+
"noise": genmix_data.noise,
|
153
|
+
"mixture": genmix_data.mixture,
|
154
|
+
}
|
155
|
+
)
|
156
|
+
|
157
|
+
write_mixture_metadata(mixdb, mixture=mixture)
|
158
|
+
|
159
|
+
return mixture
|
160
|
+
|
161
|
+
|
162
|
+
def main() -> None:
|
163
|
+
from docopt import docopt
|
164
|
+
|
165
|
+
from sonusai import __version__ as sai_version
|
166
|
+
from sonusai.utils.docstring import trim_docstring
|
167
|
+
|
168
|
+
args = docopt(trim_docstring(__doc__), version=sai_version, options_first=True)
|
169
|
+
|
170
|
+
import time
|
171
|
+
from os import makedirs
|
172
|
+
from os import remove
|
173
|
+
from os.path import exists
|
174
|
+
from os.path import isdir
|
175
|
+
from os.path import join
|
176
|
+
|
177
|
+
import yaml
|
178
|
+
|
179
|
+
from sonusai import create_file_handler
|
180
|
+
from sonusai import initial_log_messages
|
181
|
+
from sonusai import logger
|
182
|
+
from sonusai import update_console_handler
|
183
|
+
from sonusai.config.config import load_config
|
184
|
+
from sonusai.utils.seconds_to_hms import seconds_to_hms
|
185
|
+
|
186
|
+
verbose = args["--verbose"]
|
187
|
+
save_mix = args["--mix"]
|
188
|
+
dryrun = args["--dryrun"]
|
189
|
+
save_json = args["--json"]
|
190
|
+
no_par = args["--nopar"]
|
191
|
+
location = args["LOC"]
|
192
|
+
|
193
|
+
start_time = time.monotonic()
|
194
|
+
|
195
|
+
if exists(location) and not isdir(location):
|
196
|
+
remove(location)
|
197
|
+
|
198
|
+
makedirs(location, exist_ok=True)
|
199
|
+
|
200
|
+
create_file_handler(join(location, "genmixdb.log"), verbose)
|
201
|
+
update_console_handler(verbose)
|
202
|
+
initial_log_messages("genmixdb")
|
203
|
+
|
204
|
+
if dryrun:
|
205
|
+
config = load_config(location)
|
206
|
+
logger.info("Dryrun configuration:")
|
207
|
+
logger.info(yaml.dump(config))
|
208
|
+
return
|
209
|
+
|
210
|
+
logger.info(f"Creating mixture database for {location}")
|
211
|
+
logger.info("")
|
212
|
+
|
213
|
+
genmixdb(
|
214
|
+
location=location,
|
215
|
+
save_mix=save_mix,
|
216
|
+
show_progress=True,
|
217
|
+
save_json=save_json,
|
218
|
+
verbose=verbose,
|
219
|
+
no_par=no_par,
|
220
|
+
)
|
221
|
+
|
222
|
+
end_time = time.monotonic()
|
223
|
+
logger.info(f"Completed in {seconds_to_hms(seconds=end_time - start_time)}")
|
224
|
+
logger.info("")
|
225
|
+
|
226
|
+
|
227
|
+
if __name__ == "__main__":
|
228
|
+
from sonusai import exception_handler
|
229
|
+
from sonusai.utils.keyboard_interrupt import register_keyboard_interrupt
|
230
|
+
|
231
|
+
register_keyboard_interrupt()
|
232
|
+
try:
|
233
|
+
main()
|
234
|
+
except Exception as e:
|
235
|
+
exception_handler(e)
|