sonusai 0.12.5__py3-none-any.whl → 0.12.7__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 +2 -2
- sonusai/data_generator/keras_from_mixdb.py +3 -3
- sonusai/evaluate.py +1 -1
- sonusai/genft.py +2 -2
- sonusai/genmix.py +2 -2
- sonusai/genmixdb.py +18 -33
- sonusai/gentcst.py +1 -1
- sonusai/keras_onnx.py +1 -1
- sonusai/keras_predict.py +1 -1
- sonusai/keras_train.py +4 -4
- sonusai/lsdb.py +1 -1
- sonusai/main.py +8 -6
- sonusai/mixture/__init__.py +1 -1
- sonusai/mixture/audio.py +71 -3
- sonusai/mixture/augmentation.py +10 -13
- sonusai/mixture/config.py +2 -2
- sonusai/mixture/generate_mixtures.py +106 -140
- sonusai/mixture/mixdb.py +77 -8
- sonusai/mkmanifest.py +174 -0
- sonusai/mkwav.py +3 -3
- sonusai/onnx_predict.py +7 -5
- sonusai/plot.py +1 -1
- sonusai/post_spenh_targetf.py +2 -2
- sonusai/torchl_predict.py +1 -1
- sonusai/torchl_train.py +1 -1
- sonusai/tplot.py +1 -1
- sonusai/utils/__init__.py +1 -0
- sonusai/utils/asr.py +6 -5
- sonusai/utils/asr_functions/data.py +4 -3
- sonusai/utils/asr_manifest_functions/__init__.py +6 -0
- sonusai/utils/asr_manifest_functions/data.py +10 -0
- sonusai/utils/asr_manifest_functions/librispeech.py +49 -0
- sonusai/utils/asr_manifest_functions/vctk_noisy_speech.py +69 -0
- sonusai/utils/braced_glob.py +10 -3
- sonusai/utils/parallel_tqdm.py +5 -4
- sonusai/vars.py +9 -7
- {sonusai-0.12.5.dist-info → sonusai-0.12.7.dist-info}/METADATA +2 -2
- {sonusai-0.12.5.dist-info → sonusai-0.12.7.dist-info}/RECORD +40 -35
- {sonusai-0.12.5.dist-info → sonusai-0.12.7.dist-info}/WHEEL +0 -0
- {sonusai-0.12.5.dist-info → sonusai-0.12.7.dist-info}/entry_points.txt +0 -0
@@ -11,8 +11,7 @@ def generate_mixtures(mixdb: MixtureDatabase,
|
|
11
11
|
augmented_targets: AugmentedTargets,
|
12
12
|
noise_files: NoiseFiles,
|
13
13
|
noise_augmentations: Augmentations,
|
14
|
-
mixups: List[int],
|
15
|
-
show_progress: bool = False) -> Tuple[int, int]:
|
14
|
+
mixups: List[int]) -> Tuple[int, int]:
|
16
15
|
"""Generate mixtures and append to mixture database
|
17
16
|
|
18
17
|
:param mixdb: Mixture database
|
@@ -20,7 +19,6 @@ def generate_mixtures(mixdb: MixtureDatabase,
|
|
20
19
|
:param noise_files: List of noise files
|
21
20
|
:param noise_augmentations: List of noise augmentations
|
22
21
|
:param mixups: List of mixup values
|
23
|
-
:param show_progress: Show progress bar
|
24
22
|
:return: (Number of noise files used, number of noise samples used)
|
25
23
|
"""
|
26
24
|
from sonusai import SonusAIError
|
@@ -30,20 +28,17 @@ def generate_mixtures(mixdb: MixtureDatabase,
|
|
30
28
|
augmented_targets=augmented_targets,
|
31
29
|
noise_files=noise_files,
|
32
30
|
noise_augmentations=noise_augmentations,
|
33
|
-
mixups=mixups
|
34
|
-
show_progress=show_progress)
|
31
|
+
mixups=mixups)
|
35
32
|
|
36
33
|
if mixdb.noise_mix_mode == 'non-exhaustive':
|
37
34
|
return _non_exhaustive_noise_mix(mixdb=mixdb,
|
38
35
|
augmented_targets=augmented_targets,
|
39
|
-
mixups=mixups
|
40
|
-
show_progress=show_progress)
|
36
|
+
mixups=mixups)
|
41
37
|
|
42
38
|
if mixdb.noise_mix_mode == 'non-combinatorial':
|
43
39
|
return _non_combinatorial_noise_mix(mixdb=mixdb,
|
44
40
|
augmented_targets=augmented_targets,
|
45
|
-
mixups=mixups
|
46
|
-
show_progress=show_progress)
|
41
|
+
mixups=mixups)
|
47
42
|
|
48
43
|
raise SonusAIError(f'invalid noise_mix_mode: {mixdb.noise_mix_mode}')
|
49
44
|
|
@@ -52,8 +47,7 @@ def _exhaustive_noise_mix(mixdb: MixtureDatabase,
|
|
52
47
|
augmented_targets: AugmentedTargets,
|
53
48
|
noise_files: NoiseFiles,
|
54
49
|
noise_augmentations: Augmentations,
|
55
|
-
mixups: List[int],
|
56
|
-
show_progress: bool = False) -> Tuple[int, int]:
|
50
|
+
mixups: List[int]) -> Tuple[int, int]:
|
57
51
|
"""Exhaustive noise mix mode
|
58
52
|
Use every noise/augmentation with every target/augmentation.
|
59
53
|
|
@@ -62,13 +56,11 @@ def _exhaustive_noise_mix(mixdb: MixtureDatabase,
|
|
62
56
|
:param noise_files: List of noise files
|
63
57
|
:param noise_augmentations: List of noise augmentations
|
64
58
|
:param mixups: List of mixup values
|
65
|
-
:param show_progress: Show progress bar
|
66
59
|
:return: (Number of noise files used, number of noise samples used)
|
67
60
|
"""
|
68
61
|
from random import randint
|
69
62
|
|
70
63
|
import numpy as np
|
71
|
-
from tqdm import tqdm
|
72
64
|
|
73
65
|
from sonusai.mixture import MRecord
|
74
66
|
from sonusai.mixture import get_augmented_target_indices_for_mixup
|
@@ -79,52 +71,43 @@ def _exhaustive_noise_mix(mixdb: MixtureDatabase,
|
|
79
71
|
augmented_target_indices_for_mixups = [get_augmented_target_indices_for_mixup(mixdb=mixdb,
|
80
72
|
augmented_targets=augmented_targets,
|
81
73
|
mixup=mixup) for mixup in mixups]
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
for
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
snr=snr.value,
|
113
|
-
spectral_mask_index=spectral_mask_index,
|
114
|
-
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
115
|
-
random_snr=snr.is_random))
|
116
|
-
|
117
|
-
noise_offset = int((noise_offset + target_length) % noise_length)
|
118
|
-
used_noise_samples += target_length
|
119
|
-
progress.update()
|
74
|
+
for noise_file_index in range(len(noise_files)):
|
75
|
+
for noise_augmentation_index in range(len(noise_augmentations)):
|
76
|
+
noise_offset = 0
|
77
|
+
noise_length = mixdb.augmented_noise_length(noise_file_index, noise_augmentation_index)
|
78
|
+
|
79
|
+
for augmented_target_indices_for_mixup in augmented_target_indices_for_mixups:
|
80
|
+
for augmented_target_indices in augmented_target_indices_for_mixup:
|
81
|
+
(target_file_index,
|
82
|
+
target_augmentation_index,
|
83
|
+
target_length) = _get_target_info(mixdb=mixdb,
|
84
|
+
augmented_target_indices=augmented_target_indices,
|
85
|
+
augmented_targets=augmented_targets)
|
86
|
+
|
87
|
+
for spectral_mask_index in range(len(mixdb.spectral_masks)):
|
88
|
+
for snr in mixdb.all_snrs:
|
89
|
+
mixdb.mixtures.append(MRecord(
|
90
|
+
name=None,
|
91
|
+
target_file_index=target_file_index,
|
92
|
+
target_augmentation_index=target_augmentation_index,
|
93
|
+
noise_file_index=noise_file_index,
|
94
|
+
noise_offset=noise_offset,
|
95
|
+
noise_augmentation_index=noise_augmentation_index,
|
96
|
+
samples=target_length,
|
97
|
+
snr=snr.value,
|
98
|
+
spectral_mask_index=spectral_mask_index,
|
99
|
+
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
100
|
+
random_snr=snr.is_random))
|
101
|
+
|
102
|
+
noise_offset = int((noise_offset + target_length) % noise_length)
|
103
|
+
used_noise_samples += target_length
|
120
104
|
|
121
105
|
return used_noise_files, used_noise_samples
|
122
106
|
|
123
107
|
|
124
108
|
def _non_exhaustive_noise_mix(mixdb: MixtureDatabase,
|
125
109
|
augmented_targets: AugmentedTargets,
|
126
|
-
mixups: List[int],
|
127
|
-
show_progress: bool = False) -> Tuple[int, int]:
|
110
|
+
mixups: List[int]) -> Tuple[int, int]:
|
128
111
|
"""Non-exhaustive noise mix mode
|
129
112
|
Cycle through every target/augmentation without necessarily using all
|
130
113
|
noise/augmentation combinations (reduced data set).
|
@@ -132,13 +115,11 @@ def _non_exhaustive_noise_mix(mixdb: MixtureDatabase,
|
|
132
115
|
:param mixdb: Mixture database
|
133
116
|
:param augmented_targets: List of augmented targets
|
134
117
|
:param mixups: List of mixup values
|
135
|
-
:param show_progress: Show progress bar
|
136
118
|
:return: (Number of noise files used, number of noise samples used)
|
137
119
|
"""
|
138
120
|
from random import randint
|
139
121
|
|
140
122
|
import numpy as np
|
141
|
-
from tqdm import tqdm
|
142
123
|
|
143
124
|
from sonusai.mixture import MRecord
|
144
125
|
from sonusai.mixture import get_augmented_target_indices_for_mixup
|
@@ -152,54 +133,47 @@ def _non_exhaustive_noise_mix(mixdb: MixtureDatabase,
|
|
152
133
|
augmented_target_indices_for_mixups = [get_augmented_target_indices_for_mixup(mixdb=mixdb,
|
153
134
|
augmented_targets=augmented_targets,
|
154
135
|
mixup=mixup) for mixup in mixups]
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
190
|
-
random_snr=snr.is_random))
|
191
|
-
|
192
|
-
noise_offset += target_length
|
193
|
-
used_noise_samples += target_length
|
194
|
-
progress.update()
|
136
|
+
for mixup in augmented_target_indices_for_mixups:
|
137
|
+
for augmented_target_indices in mixup:
|
138
|
+
(target_file_index,
|
139
|
+
target_augmentation_index,
|
140
|
+
target_length) = _get_target_info(mixdb=mixdb,
|
141
|
+
augmented_target_indices=augmented_target_indices,
|
142
|
+
augmented_targets=augmented_targets)
|
143
|
+
|
144
|
+
for spectral_mask_index in range(len(mixdb.spectral_masks)):
|
145
|
+
for snr in mixdb.all_snrs:
|
146
|
+
used_noise_files.add(f'{noise_file_index}_{noise_augmentation_index}')
|
147
|
+
(noise_file_index,
|
148
|
+
noise_augmentation_index,
|
149
|
+
noise_offset) = _get_next_noise_offset(mixdb=mixdb,
|
150
|
+
target_length=target_length,
|
151
|
+
noise_file_index=noise_file_index,
|
152
|
+
noise_augmentation_index=noise_augmentation_index,
|
153
|
+
noise_offset=noise_offset)
|
154
|
+
|
155
|
+
mixdb.mixtures.append(MRecord(
|
156
|
+
name=None,
|
157
|
+
target_file_index=target_file_index,
|
158
|
+
target_augmentation_index=target_augmentation_index,
|
159
|
+
noise_file_index=noise_file_index,
|
160
|
+
noise_augmentation_index=noise_augmentation_index,
|
161
|
+
noise_offset=noise_offset,
|
162
|
+
samples=target_length,
|
163
|
+
snr=snr.value,
|
164
|
+
spectral_mask_index=spectral_mask_index,
|
165
|
+
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
166
|
+
random_snr=snr.is_random))
|
167
|
+
|
168
|
+
noise_offset += target_length
|
169
|
+
used_noise_samples += target_length
|
195
170
|
|
196
171
|
return len(used_noise_files), used_noise_samples
|
197
172
|
|
198
173
|
|
199
174
|
def _non_combinatorial_noise_mix(mixdb: MixtureDatabase,
|
200
175
|
augmented_targets: AugmentedTargets,
|
201
|
-
mixups: List[int],
|
202
|
-
show_progress: bool = False) -> Tuple[int, int]:
|
176
|
+
mixups: List[int]) -> Tuple[int, int]:
|
203
177
|
"""Non-combinatorial noise mix mode
|
204
178
|
Combine a target/augmentation with a single cut of a noise/augmentation
|
205
179
|
non-exhaustively (each target/augmentation does not use each noise/augmentation).
|
@@ -208,14 +182,12 @@ def _non_combinatorial_noise_mix(mixdb: MixtureDatabase,
|
|
208
182
|
:param mixdb: Mixture database
|
209
183
|
:param augmented_targets: List of augmented targets
|
210
184
|
:param mixups: List of mixup values
|
211
|
-
:param show_progress: Show progress bar
|
212
185
|
:return: (Number of noise files used, number of noise samples used)
|
213
186
|
"""
|
214
187
|
from random import choice
|
215
188
|
from random import randint
|
216
189
|
|
217
190
|
import numpy as np
|
218
|
-
from tqdm import tqdm
|
219
191
|
|
220
192
|
from sonusai.mixture import MRecord
|
221
193
|
from sonusai.mixture import get_augmented_target_indices_for_mixup
|
@@ -228,43 +200,37 @@ def _non_combinatorial_noise_mix(mixdb: MixtureDatabase,
|
|
228
200
|
augmented_target_indices_for_mixups = [get_augmented_target_indices_for_mixup(mixdb=mixdb,
|
229
201
|
augmented_targets=augmented_targets,
|
230
202
|
mixup=mixup) for mixup in mixups]
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
spectral_mask_index=spectral_mask_index,
|
263
|
-
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
264
|
-
random_snr=snr.is_random))
|
265
|
-
|
266
|
-
used_noise_samples += target_length
|
267
|
-
progress.update()
|
203
|
+
for mixup in augmented_target_indices_for_mixups:
|
204
|
+
for augmented_target_indices in mixup:
|
205
|
+
(target_file_index,
|
206
|
+
target_augmentation_index,
|
207
|
+
target_length) = _get_target_info(mixdb=mixdb,
|
208
|
+
augmented_target_indices=augmented_target_indices,
|
209
|
+
augmented_targets=augmented_targets)
|
210
|
+
|
211
|
+
for spectral_mask_index in range(len(mixdb.spectral_masks)):
|
212
|
+
for snr in mixdb.all_snrs:
|
213
|
+
used_noise_files.add(f'{noise_file_index}_{noise_augmentation_index}')
|
214
|
+
(noise_file_index,
|
215
|
+
noise_augmentation_index,
|
216
|
+
noise_length) = _get_next_noise_indices(mixdb=mixdb,
|
217
|
+
noise_file_index=noise_file_index,
|
218
|
+
noise_augmentation_index=noise_augmentation_index)
|
219
|
+
|
220
|
+
mixdb.mixtures.append(MRecord(
|
221
|
+
name=None,
|
222
|
+
target_file_index=target_file_index,
|
223
|
+
target_augmentation_index=target_augmentation_index,
|
224
|
+
noise_file_index=noise_file_index,
|
225
|
+
noise_augmentation_index=noise_augmentation_index,
|
226
|
+
noise_offset=choice(range(noise_length)),
|
227
|
+
samples=target_length,
|
228
|
+
snr=snr.value,
|
229
|
+
spectral_mask_index=spectral_mask_index,
|
230
|
+
spectral_mask_seed=randint(0, np.iinfo('i').max),
|
231
|
+
random_snr=snr.is_random))
|
232
|
+
|
233
|
+
used_noise_samples += target_length
|
268
234
|
|
269
235
|
return len(used_noise_files), used_noise_samples
|
270
236
|
|
@@ -309,7 +275,7 @@ def _get_next_noise_offset(mixdb: MixtureDatabase,
|
|
309
275
|
def _get_target_info(mixdb: MixtureDatabase,
|
310
276
|
augmented_target_indices: List[int],
|
311
277
|
augmented_targets: AugmentedTargets) -> Tuple[List[int], List[int], int]:
|
312
|
-
from sonusai.mixture import
|
278
|
+
from sonusai.mixture import estimate_augmented_length_from_length
|
313
279
|
|
314
280
|
target_file_index = []
|
315
281
|
target_augmentation_index = []
|
@@ -321,8 +287,8 @@ def _get_target_info(mixdb: MixtureDatabase,
|
|
321
287
|
target_file_index.append(tfi)
|
322
288
|
target_augmentation_index.append(tai)
|
323
289
|
|
324
|
-
target_length = max(
|
325
|
-
|
326
|
-
|
290
|
+
target_length = max(estimate_augmented_length_from_length(length=mixdb.targets[tfi].samples,
|
291
|
+
augmentation=mixdb.target_augmentations[tai],
|
292
|
+
length_common_denominator=mixdb.feature_step_samples),
|
327
293
|
target_length)
|
328
294
|
return target_file_index, target_augmentation_index, target_length
|
sonusai/mixture/mixdb.py
CHANGED
@@ -431,17 +431,20 @@ class MixtureDatabase:
|
|
431
431
|
def truth_settings(self, value: TruthSettings) -> None:
|
432
432
|
self._config.truth_settings = value
|
433
433
|
|
434
|
-
def augmented_target_length(self, file_index: int,
|
434
|
+
def augmented_target_length(self, file_index: int,
|
435
|
+
augmentation_index: int) -> int:
|
435
436
|
from sonusai.mixture import estimate_augmented_length_from_length
|
436
437
|
|
437
|
-
return estimate_augmented_length_from_length(self.targets[file_index].samples,
|
438
|
-
self.target_augmentations[augmentation_index]
|
438
|
+
return estimate_augmented_length_from_length(length=self.targets[file_index].samples,
|
439
|
+
augmentation=self.target_augmentations[augmentation_index],
|
440
|
+
length_common_denominator=self.feature_step_samples)
|
439
441
|
|
440
|
-
def augmented_noise_length(self, file_index: int,
|
442
|
+
def augmented_noise_length(self, file_index: int,
|
443
|
+
augmentation_index: int) -> int:
|
441
444
|
from sonusai.mixture import estimate_augmented_length_from_length
|
442
445
|
|
443
|
-
return estimate_augmented_length_from_length(self.noises[file_index].samples,
|
444
|
-
self.noise_augmentations[augmentation_index])
|
446
|
+
return estimate_augmented_length_from_length(length=self.noises[file_index].samples,
|
447
|
+
augmentation=self.noise_augmentations[augmentation_index])
|
445
448
|
|
446
449
|
def raw_target_audio(self, file_index: int) -> AudioT:
|
447
450
|
if self._use_cache:
|
@@ -472,7 +475,58 @@ class MixtureDatabase:
|
|
472
475
|
def raw_target_audio_cache_info(self) -> NamedTuple:
|
473
476
|
return self._cache_raw_target_audio.cache_info()
|
474
477
|
|
478
|
+
def augmented_target_audio(self, file_index: int, augmentation_index: int) -> AudioT:
|
479
|
+
"""Get augmented target audio
|
480
|
+
|
481
|
+
:param file_index: Target audio file index
|
482
|
+
:param augmentation_index: Target augmentation index
|
483
|
+
:return: Augmented target audio
|
484
|
+
"""
|
485
|
+
if self._use_cache:
|
486
|
+
return self._cache_augmented_target_audio(file_index, augmentation_index)
|
487
|
+
else:
|
488
|
+
return self._no_cache_augmented_target_audio(file_index, augmentation_index)
|
489
|
+
|
490
|
+
@lru_cache
|
491
|
+
def _cache_augmented_target_audio(self, file_index: int, augmentation_index: int) -> AudioT:
|
492
|
+
"""Get augmented target audio (using cache)
|
493
|
+
|
494
|
+
:param file_index: Target audio file name
|
495
|
+
:param augmentation_index: Target augmentation index
|
496
|
+
:return: Augmented target audio
|
497
|
+
"""
|
498
|
+
return self._no_cache_augmented_target_audio(file_index, augmentation_index)
|
499
|
+
|
500
|
+
def _no_cache_augmented_target_audio(self, file_index: int, augmentation_index: int) -> AudioT:
|
501
|
+
"""Get augmented target audio (without using cache)
|
502
|
+
|
503
|
+
:param file_index: Target audio file index
|
504
|
+
:param augmentation_index: Target augmentation index
|
505
|
+
:return: Augmented target audio
|
506
|
+
"""
|
507
|
+
from sonusai.mixture import apply_augmentation
|
508
|
+
from sonusai.mixture import apply_ir
|
509
|
+
from sonusai.mixture import read_audio
|
510
|
+
|
511
|
+
audio = read_audio(self.targets[file_index].name)
|
512
|
+
augmentation = self.target_augmentations[augmentation_index]
|
513
|
+
audio = apply_augmentation(audio, augmentation, self.feature_step_samples)
|
514
|
+
if augmentation.ir is not None:
|
515
|
+
audio = apply_ir(audio, self.ir_data[int(augmentation.ir)])
|
516
|
+
|
517
|
+
return audio
|
518
|
+
|
519
|
+
@property
|
520
|
+
def augmented_target_audio_cache_info(self) -> NamedTuple:
|
521
|
+
return self._cache_augmented_target_audio.cache_info()
|
522
|
+
|
475
523
|
def augmented_noise_audio(self, file_index: int, augmentation_index: int) -> AudioT:
|
524
|
+
"""Get augmented noise audio
|
525
|
+
|
526
|
+
:param file_index: Noise audio file index
|
527
|
+
:param augmentation_index: Noise augmentation index
|
528
|
+
:return: Augmented noise audio
|
529
|
+
"""
|
476
530
|
if self._use_cache:
|
477
531
|
return self._cache_augmented_noise_audio(file_index, augmentation_index)
|
478
532
|
else:
|
@@ -634,6 +688,20 @@ class MixtureDatabase:
|
|
634
688
|
|
635
689
|
line_num += 1
|
636
690
|
|
691
|
+
@property
|
692
|
+
def augmented_target_samples(self) -> int:
|
693
|
+
from itertools import product
|
694
|
+
|
695
|
+
it = list(product(*[range(len(self.targets)), range(len(self.target_augmentations))]))
|
696
|
+
return sum([self.augmented_target_length(fi, ai) for fi, ai in it])
|
697
|
+
|
698
|
+
@property
|
699
|
+
def augmented_noise_samples(self) -> int:
|
700
|
+
from itertools import product
|
701
|
+
|
702
|
+
it = list(product(*[range(len(self.noises)), range(len(self.noise_augmentations))]))
|
703
|
+
return sum([self.augmented_noise_length(fi, ai) for fi, ai in it])
|
704
|
+
|
637
705
|
def total_samples(self, mixids: GeneralizedIDs = '*') -> int:
|
638
706
|
return sum([self.mixture_samples(mixid) for mixid in self.mixids_to_list(mixids)])
|
639
707
|
|
@@ -817,7 +885,8 @@ class MixtureDatabase:
|
|
817
885
|
mrecord = self.mixtures[mixid]
|
818
886
|
targets = []
|
819
887
|
for idx in range(len(mrecord.target_file_index)):
|
820
|
-
target =
|
888
|
+
target = self.raw_target_audio(mrecord.target_file_index[idx])
|
889
|
+
target = apply_augmentation(audio=target,
|
821
890
|
augmentation=self.target_augmentations[mrecord.target_augmentation_index[idx]],
|
822
891
|
length_common_denominator=self.feature_step_samples)
|
823
892
|
target = apply_gain(audio=target, gain=mrecord.target_snr_gain)
|
@@ -996,7 +1065,7 @@ class MixtureDatabase:
|
|
996
1065
|
:param mixid: Mixture ID
|
997
1066
|
:param targets: List of augmented target audio data (one per target in the mixup) for the given mixid
|
998
1067
|
:param noise: Augmented noise audio data for the given mixid
|
999
|
-
:param force: Force computing data from original sources regardless of whether
|
1068
|
+
:param force: Force computing data from original sources regardless of whether cached data exists
|
1000
1069
|
:return: truth_t data
|
1001
1070
|
"""
|
1002
1071
|
import numpy as np
|