sonusai 0.18.0__py3-none-any.whl → 0.18.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/mixture/db_datatypes.py +72 -0
- sonusai/mixture/generation.py +3 -0
- sonusai/mixture/helpers.py +17 -15
- sonusai/mixture/mixdb.py +101 -107
- {sonusai-0.18.0.dist-info → sonusai-0.18.2.dist-info}/METADATA +1 -1
- {sonusai-0.18.0.dist-info → sonusai-0.18.2.dist-info}/RECORD +8 -7
- {sonusai-0.18.0.dist-info → sonusai-0.18.2.dist-info}/WHEEL +0 -0
- {sonusai-0.18.0.dist-info → sonusai-0.18.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
from collections import namedtuple
|
2
|
+
|
3
|
+
TruthSettingRecord = namedtuple('TruthSettingRecord', [
|
4
|
+
'id',
|
5
|
+
'setting'])
|
6
|
+
|
7
|
+
TargetFileRecord = namedtuple('TargetFileRecord', [
|
8
|
+
'id',
|
9
|
+
'name',
|
10
|
+
'samples',
|
11
|
+
'level_type',
|
12
|
+
'speaker_id'])
|
13
|
+
|
14
|
+
NoiseFileRecord = namedtuple('NoiseFileRecord', [
|
15
|
+
'id',
|
16
|
+
'name',
|
17
|
+
'samples'])
|
18
|
+
|
19
|
+
TopRecord = namedtuple('TopRecord', [
|
20
|
+
'id',
|
21
|
+
'version',
|
22
|
+
'class_balancing',
|
23
|
+
'feature',
|
24
|
+
'noise_mix_mode',
|
25
|
+
'num_classes',
|
26
|
+
'seed',
|
27
|
+
'truth_mutex',
|
28
|
+
'truth_reduction_function',
|
29
|
+
'mixid_width',
|
30
|
+
'speaker_metadata_tiers',
|
31
|
+
'textgrid_metadata_tiers'])
|
32
|
+
|
33
|
+
ClassLabelRecord = namedtuple('ClassLabelRecord', [
|
34
|
+
'id',
|
35
|
+
'label'])
|
36
|
+
|
37
|
+
ClassWeightsThresholdRecord = namedtuple('ClassWeightsThresholdRecord', [
|
38
|
+
'id',
|
39
|
+
'threshold'])
|
40
|
+
|
41
|
+
ImpulseResponseFileRecord = namedtuple('ImpulseResponseFileRecord', [
|
42
|
+
'id',
|
43
|
+
'file'])
|
44
|
+
|
45
|
+
SpectralMaskRecord = namedtuple('SpectralMaskRecord', [
|
46
|
+
'id',
|
47
|
+
'f_max_width',
|
48
|
+
'f_num',
|
49
|
+
't_max_width',
|
50
|
+
't_num',
|
51
|
+
't_max_percent'])
|
52
|
+
|
53
|
+
TargetRecord = namedtuple('TargetRecord', [
|
54
|
+
'id',
|
55
|
+
'file_id',
|
56
|
+
'augmentation',
|
57
|
+
'gain'])
|
58
|
+
|
59
|
+
MixtureRecord = namedtuple('MixtureRecord', [
|
60
|
+
'id',
|
61
|
+
'name',
|
62
|
+
'noise_file_id',
|
63
|
+
'noise_augmentation',
|
64
|
+
'noise_offset',
|
65
|
+
'noise_snr_gain',
|
66
|
+
'random_snr',
|
67
|
+
'snr',
|
68
|
+
'samples',
|
69
|
+
'spectral_mask_id',
|
70
|
+
'spectral_mask_seed',
|
71
|
+
'target_snr_gain'
|
72
|
+
])
|
sonusai/mixture/generation.py
CHANGED
@@ -992,6 +992,9 @@ def _populate_speaker_table(location: str, target_files: TargetFiles, test: bool
|
|
992
992
|
description[0] not in ('id', 'parent')]
|
993
993
|
con.execute("UPDATE top SET speaker_metadata_tiers=? WHERE top.id = ?", (json.dumps(tiers), 1))
|
994
994
|
|
995
|
+
if 'speaker_id' in tiers:
|
996
|
+
con.execute("CREATE INDEX speaker_speaker_id_idx ON speaker (speaker_id)")
|
997
|
+
|
995
998
|
con.commit()
|
996
999
|
con.close()
|
997
1000
|
|
sonusai/mixture/helpers.py
CHANGED
@@ -26,6 +26,8 @@ from sonusai.mixture.datatypes import TargetFiles
|
|
26
26
|
from sonusai.mixture.datatypes import Targets
|
27
27
|
from sonusai.mixture.datatypes import TransformConfig
|
28
28
|
from sonusai.mixture.datatypes import Truth
|
29
|
+
from sonusai.mixture.db_datatypes import MixtureRecord
|
30
|
+
from sonusai.mixture.db_datatypes import TargetRecord
|
29
31
|
from sonusai.mixture.mixdb import MixtureDatabase
|
30
32
|
|
31
33
|
|
@@ -228,7 +230,7 @@ def from_mixture(mixture: Mixture) -> tuple[str, int, str, int, float, bool, flo
|
|
228
230
|
mixture.target_snr_gain)
|
229
231
|
|
230
232
|
|
231
|
-
def to_mixture(entry:
|
233
|
+
def to_mixture(entry: MixtureRecord, targets: Targets) -> Mixture:
|
232
234
|
import json
|
233
235
|
|
234
236
|
from sonusai.utils import dataclass_from_dict
|
@@ -238,32 +240,32 @@ def to_mixture(entry: tuple[str, int, str, int, float, bool, float, int, int, in
|
|
238
240
|
from .datatypes import UniversalSNR
|
239
241
|
|
240
242
|
return Mixture(targets=targets,
|
241
|
-
name=entry
|
242
|
-
noise=Noise(file_id=entry
|
243
|
-
augmentation=dataclass_from_dict(Augmentation, json.loads(entry
|
244
|
-
offset=entry
|
245
|
-
noise_snr_gain=entry
|
246
|
-
snr=UniversalSNR(is_random=entry
|
247
|
-
samples=entry
|
248
|
-
spectral_mask_id=entry
|
249
|
-
spectral_mask_seed=entry
|
250
|
-
target_snr_gain=entry
|
243
|
+
name=entry.name,
|
244
|
+
noise=Noise(file_id=entry.noise_file_id,
|
245
|
+
augmentation=dataclass_from_dict(Augmentation, json.loads(entry.noise_augmentation)),
|
246
|
+
offset=entry.noise_offset),
|
247
|
+
noise_snr_gain=entry.noise_snr_gain,
|
248
|
+
snr=UniversalSNR(is_random=entry.random_snr, value=entry.snr),
|
249
|
+
samples=entry.samples,
|
250
|
+
spectral_mask_id=entry.spectral_mask_id,
|
251
|
+
spectral_mask_seed=entry.spectral_mask_seed,
|
252
|
+
target_snr_gain=entry.target_snr_gain)
|
251
253
|
|
252
254
|
|
253
255
|
def from_target(target: Target) -> tuple[int, str, float]:
|
254
256
|
return target.file_id, target.augmentation.to_json(), target.gain
|
255
257
|
|
256
258
|
|
257
|
-
def to_target(entry:
|
259
|
+
def to_target(entry: TargetRecord) -> Target:
|
258
260
|
import json
|
259
261
|
|
260
262
|
from sonusai.utils import dataclass_from_dict
|
261
263
|
from .datatypes import Augmentation
|
262
264
|
from .datatypes import Target
|
263
265
|
|
264
|
-
return Target(file_id=entry
|
265
|
-
augmentation=dataclass_from_dict(Augmentation, json.loads(entry
|
266
|
-
gain=entry
|
266
|
+
return Target(file_id=entry.file_id,
|
267
|
+
augmentation=dataclass_from_dict(Augmentation, json.loads(entry.augmentation)),
|
268
|
+
gain=entry.gain)
|
267
269
|
|
268
270
|
|
269
271
|
def read_mixture_data(name: str, items: list[str] | str) -> Any:
|
sonusai/mixture/mixdb.py
CHANGED
@@ -4,7 +4,6 @@ from functools import partial
|
|
4
4
|
from sqlite3 import Connection
|
5
5
|
from sqlite3 import Cursor
|
6
6
|
from typing import Any
|
7
|
-
from typing import Callable
|
8
7
|
from typing import Optional
|
9
8
|
|
10
9
|
from sonusai.mixture.datatypes import AudioF
|
@@ -129,32 +128,32 @@ class MixtureDatabase:
|
|
129
128
|
@cached_property
|
130
129
|
def num_classes(self) -> int:
|
131
130
|
with self.db() as c:
|
132
|
-
return int(c.execute("SELECT top.num_classes
|
131
|
+
return int(c.execute("SELECT top.num_classes FROM top").fetchone()[0])
|
133
132
|
|
134
133
|
@cached_property
|
135
134
|
def truth_mutex(self) -> bool:
|
136
135
|
with self.db() as c:
|
137
|
-
return bool(c.execute("SELECT top.truth_mutex
|
136
|
+
return bool(c.execute("SELECT top.truth_mutex FROM top").fetchone()[0])
|
138
137
|
|
139
138
|
@cached_property
|
140
139
|
def truth_reduction_function(self) -> str:
|
141
140
|
with self.db() as c:
|
142
|
-
return str(c.execute("SELECT top.truth_reduction_function
|
141
|
+
return str(c.execute("SELECT top.truth_reduction_function FROM top").fetchone()[0])
|
143
142
|
|
144
143
|
@cached_property
|
145
144
|
def noise_mix_mode(self) -> str:
|
146
145
|
with self.db() as c:
|
147
|
-
return str(c.execute("SELECT top.noise_mix_mode
|
146
|
+
return str(c.execute("SELECT top.noise_mix_mode FROM top").fetchone()[0])
|
148
147
|
|
149
148
|
@cached_property
|
150
149
|
def class_balancing(self) -> bool:
|
151
150
|
with self.db() as c:
|
152
|
-
return bool(c.execute("SELECT top.class_balancing
|
151
|
+
return bool(c.execute("SELECT top.class_balancing FROM top").fetchone()[0])
|
153
152
|
|
154
153
|
@cached_property
|
155
154
|
def feature(self) -> str:
|
156
155
|
with self.db() as c:
|
157
|
-
return str(c.execute("SELECT top.feature
|
156
|
+
return str(c.execute("SELECT top.feature FROM top").fetchone()[0])
|
158
157
|
|
159
158
|
@cached_property
|
160
159
|
def fg_decimation(self) -> int:
|
@@ -282,14 +281,16 @@ class MixtureDatabase:
|
|
282
281
|
|
283
282
|
:return: Spectral masks
|
284
283
|
"""
|
284
|
+
from .db_datatypes import SpectralMaskRecord
|
285
|
+
|
285
286
|
with self.db() as c:
|
286
|
-
|
287
|
-
|
288
|
-
return [SpectralMask(f_max_width=spectral_mask
|
289
|
-
f_num=spectral_mask
|
290
|
-
t_max_width=spectral_mask
|
291
|
-
t_num=spectral_mask
|
292
|
-
t_max_percent=spectral_mask
|
287
|
+
spectral_masks = [SpectralMaskRecord(*result) for result in
|
288
|
+
c.execute("SELECT * FROM spectral_mask").fetchall()]
|
289
|
+
return [SpectralMask(f_max_width=spectral_mask.f_max_width,
|
290
|
+
f_num=spectral_mask.f_num,
|
291
|
+
t_max_width=spectral_mask.t_max_width,
|
292
|
+
t_num=spectral_mask.t_num,
|
293
|
+
t_max_percent=spectral_mask.t_max_percent) for spectral_mask in spectral_masks]
|
293
294
|
|
294
295
|
def spectral_mask(self, sm_id: int) -> SpectralMask:
|
295
296
|
"""Get spectral mask with ID from db
|
@@ -309,27 +310,29 @@ class MixtureDatabase:
|
|
309
310
|
|
310
311
|
from .datatypes import TruthSetting
|
311
312
|
from .datatypes import TruthSettings
|
313
|
+
from .db_datatypes import TargetFileRecord
|
312
314
|
|
313
315
|
with self.db() as c:
|
314
316
|
target_files: TargetFiles = []
|
315
|
-
for
|
316
|
-
|
317
|
+
target_file_records = [TargetFileRecord(*result) for result in
|
318
|
+
c.execute("SELECT * FROM target_file").fetchall()]
|
319
|
+
for target_file_record in target_file_records:
|
317
320
|
truth_settings: TruthSettings = []
|
318
|
-
for
|
321
|
+
for truth_setting_records in c.execute(
|
319
322
|
"SELECT truth_setting.setting " +
|
320
323
|
"FROM truth_setting, target_file_truth_setting " +
|
321
324
|
"WHERE ? = target_file_truth_setting.target_file_id " +
|
322
325
|
"AND truth_setting.id = target_file_truth_setting.truth_setting_id",
|
323
|
-
(
|
324
|
-
|
325
|
-
truth_settings.append(TruthSetting(config=
|
326
|
-
function=
|
327
|
-
index=
|
328
|
-
target_files.append(TargetFile(name=
|
329
|
-
samples=
|
330
|
-
level_type=
|
326
|
+
(target_file_record.id,)).fetchall():
|
327
|
+
truth_setting = json.loads(truth_setting_records[0])
|
328
|
+
truth_settings.append(TruthSetting(config=truth_setting.get('config', None),
|
329
|
+
function=truth_setting.get('function', None),
|
330
|
+
index=truth_setting.get('index', None)))
|
331
|
+
target_files.append(TargetFile(name=target_file_record.name,
|
332
|
+
samples=target_file_record.samples,
|
333
|
+
level_type=target_file_record.level_type,
|
331
334
|
truth_settings=truth_settings,
|
332
|
-
speaker_id=
|
335
|
+
speaker_id=target_file_record.speaker_id))
|
333
336
|
return target_files
|
334
337
|
|
335
338
|
@cached_property
|
@@ -439,18 +442,16 @@ class MixtureDatabase:
|
|
439
442
|
"""
|
440
443
|
from .helpers import to_mixture
|
441
444
|
from .helpers import to_target
|
445
|
+
from .db_datatypes import MixtureRecord
|
446
|
+
from .db_datatypes import TargetRecord
|
442
447
|
|
443
448
|
with self.db() as c:
|
444
449
|
mixtures: Mixtures = []
|
445
|
-
for mixture in c.execute(
|
446
|
-
|
447
|
-
"
|
448
|
-
"FROM mixture").fetchall():
|
449
|
-
targets = [to_target(target) for target in c.execute(
|
450
|
-
"SELECT target.file_id, augmentation, gain " +
|
451
|
-
"FROM target, mixture_target " +
|
450
|
+
for mixture in [MixtureRecord(*record) for record in c.execute("SELECT * FROM mixture").fetchall()]:
|
451
|
+
targets = [to_target(TargetRecord(*target)) for target in c.execute(
|
452
|
+
"SELECT target.* FROM target, mixture_target " +
|
452
453
|
"WHERE ? = mixture_target.mixture_id AND target.id = mixture_target.target_id",
|
453
|
-
(mixture
|
454
|
+
(mixture.id,)).fetchall()]
|
454
455
|
mixtures.append(to_mixture(mixture, targets))
|
455
456
|
return mixtures
|
456
457
|
|
@@ -474,7 +475,7 @@ class MixtureDatabase:
|
|
474
475
|
@cached_property
|
475
476
|
def mixid_width(self) -> int:
|
476
477
|
with self.db() as c:
|
477
|
-
return int(c.execute("SELECT top.mixid_width
|
478
|
+
return int(c.execute("SELECT top.mixid_width FROM top").fetchone()[0])
|
478
479
|
|
479
480
|
def location_filename(self, name: str) -> str:
|
480
481
|
"""Add the location to the given file name
|
@@ -1001,17 +1002,8 @@ class MixtureDatabase:
|
|
1001
1002
|
def speech_metadata_tiers(self) -> list[str]:
|
1002
1003
|
return sorted(set(self.speaker_metadata_tiers + self.textgrid_metadata_tiers))
|
1003
1004
|
|
1004
|
-
def speaker(self,
|
1005
|
-
|
1006
|
-
return None
|
1007
|
-
|
1008
|
-
with self.db() as c:
|
1009
|
-
data = c.execute(f'SELECT {tier} FROM speaker WHERE ? = id', (speaker_id,)).fetchone()
|
1010
|
-
if data is None:
|
1011
|
-
return None
|
1012
|
-
if data[0] is None:
|
1013
|
-
return None
|
1014
|
-
return data[0]
|
1005
|
+
def speaker(self, s_id: int | None, tier: str) -> Optional[str]:
|
1006
|
+
return _speaker(self.db, s_id, tier)
|
1015
1007
|
|
1016
1008
|
def speech_metadata(self, tier: str) -> list[str]:
|
1017
1009
|
from .helpers import get_textgrid_tier_from_target_file
|
@@ -1069,13 +1061,13 @@ class MixtureDatabase:
|
|
1069
1061
|
|
1070
1062
|
def mixids_for_speech_metadata(self,
|
1071
1063
|
tier: str,
|
1072
|
-
value: str
|
1073
|
-
|
1064
|
+
value: str = None,
|
1065
|
+
where: str = None) -> list[int]:
|
1074
1066
|
"""Get a list of mixture IDs for the given speech metadata tier.
|
1075
1067
|
|
1076
|
-
If '
|
1077
|
-
If '
|
1078
|
-
to include.
|
1068
|
+
If 'where' is None, then include mixture IDs whose tier values are equal to the given 'value'.
|
1069
|
+
If 'where' is not None, then ignore 'value' and use the given SQL where clause to determine
|
1070
|
+
which entries to include.
|
1079
1071
|
|
1080
1072
|
Examples:
|
1081
1073
|
>>> mixdb = MixtureDatabase('/mixdb_location')
|
@@ -1083,40 +1075,33 @@ class MixtureDatabase:
|
|
1083
1075
|
>>> mixids = mixdb.mixids_for_speech_metadata('speaker_id', 'TIMIT_ARC0')
|
1084
1076
|
Get mixutre IDs for mixtures with speakers whose speaker_ids are 'TIMIT_ARC0'.
|
1085
1077
|
|
1086
|
-
>>> mixids = mixdb.mixids_for_speech_metadata('age', '
|
1078
|
+
>>> mixids = mixdb.mixids_for_speech_metadata('age', where='age < 25')
|
1087
1079
|
Get mixture IDs for mixtures with speakers whose ages are less than 25.
|
1088
1080
|
|
1089
|
-
>>> mixids = mixdb.mixids_for_speech_metadata('dialect',
|
1081
|
+
>>> mixids = mixdb.mixids_for_speech_metadata('dialect', where="dialect in ('New York City', 'Northern')")
|
1090
1082
|
Get mixture IDs for mixtures with speakers whose dialects are either 'New York City' or 'Northern'.
|
1091
1083
|
"""
|
1092
|
-
from
|
1084
|
+
from sonusai import SonusAIError
|
1093
1085
|
|
1094
|
-
if
|
1095
|
-
|
1096
|
-
return x == value
|
1086
|
+
if value is None and where is None:
|
1087
|
+
raise SonusAIError('Must provide either value or where')
|
1097
1088
|
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
for mixid_target_file in mixid_target_files:
|
1115
|
-
if mixid_target_file in target_files:
|
1116
|
-
m_ids.append(m_id)
|
1117
|
-
|
1118
|
-
# Return sorted, unique list of mixture IDs
|
1119
|
-
return sorted(list(set(m_ids)))
|
1089
|
+
if where is None:
|
1090
|
+
where = f"{tier} = '{value}'"
|
1091
|
+
|
1092
|
+
if tier in self.textgrid_metadata_tiers:
|
1093
|
+
raise SonusAIError(f'TextGrid tier data, "{tier}", is not supported in mixids_for_speech_metadata().')
|
1094
|
+
|
1095
|
+
with self.db() as c:
|
1096
|
+
speaker_ids = [speaker_id[0] for speaker_id in
|
1097
|
+
c.execute(f"SELECT id FROM speaker WHERE {where}").fetchall()]
|
1098
|
+
results = c.execute(f"SELECT id FROM target_file " +
|
1099
|
+
f"WHERE speaker_id IN ({','.join(map(str, speaker_ids))})").fetchall()
|
1100
|
+
target_file_ids = [target_file_id[0] for target_file_id in results]
|
1101
|
+
results = c.execute("SELECT mixture_id FROM mixture_target " +
|
1102
|
+
f"WHERE mixture_target.target_id IN ({','.join(map(str, target_file_ids))})").fetchall()
|
1103
|
+
|
1104
|
+
return [mixture_id[0] - 1 for mixture_id in results]
|
1120
1105
|
|
1121
1106
|
def mixture_all_speech_metadata(self, m_id: int) -> list[dict[str, SpeechMetadata]]:
|
1122
1107
|
from .helpers import mixture_all_speech_metadata
|
@@ -1172,7 +1157,7 @@ class MixtureDatabase:
|
|
1172
1157
|
)
|
1173
1158
|
|
1174
1159
|
if not (metric in supported_metrics or metric.startswith('MXWER')):
|
1175
|
-
raise
|
1160
|
+
raise SonusAIError(f'Unsupported metric: {metric}')
|
1176
1161
|
|
1177
1162
|
if not force:
|
1178
1163
|
result = self.read_mixture_data(m_id, metric)
|
@@ -1300,17 +1285,16 @@ def _spectral_mask(db: partial, sm_id: int) -> SpectralMask:
|
|
1300
1285
|
:param sm_id: Spectral mask ID
|
1301
1286
|
:return: Spectral mask
|
1302
1287
|
"""
|
1288
|
+
from .db_datatypes import SpectralMaskRecord
|
1289
|
+
|
1303
1290
|
with db() as c:
|
1304
|
-
spectral_mask = c.execute(
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
t_max_width=spectral_mask[2],
|
1312
|
-
t_num=spectral_mask[3],
|
1313
|
-
t_max_percent=spectral_mask[4])
|
1291
|
+
spectral_mask = SpectralMaskRecord(*c.execute("SELECT * FROM spectral_mask WHERE ? = spectral_mask.id",
|
1292
|
+
(sm_id,)).fetchone())
|
1293
|
+
return SpectralMask(f_max_width=spectral_mask.f_max_width,
|
1294
|
+
f_num=spectral_mask.f_num,
|
1295
|
+
t_max_width=spectral_mask.t_max_width,
|
1296
|
+
t_num=spectral_mask.t_num,
|
1297
|
+
t_max_percent=spectral_mask.t_max_percent)
|
1314
1298
|
|
1315
1299
|
|
1316
1300
|
@lru_cache
|
@@ -1325,11 +1309,11 @@ def _target_file(db: partial, t_id: int) -> TargetFile:
|
|
1325
1309
|
|
1326
1310
|
from .datatypes import TruthSetting
|
1327
1311
|
from .datatypes import TruthSettings
|
1312
|
+
from .db_datatypes import TargetFileRecord
|
1328
1313
|
|
1329
1314
|
with db() as c:
|
1330
|
-
|
1331
|
-
"SELECT
|
1332
|
-
(t_id,)).fetchone()
|
1315
|
+
target_file = TargetFileRecord(
|
1316
|
+
*c.execute("SELECT * FROM target_file WHERE ? = target_file.id", (t_id,)).fetchone())
|
1333
1317
|
|
1334
1318
|
truth_settings: TruthSettings = []
|
1335
1319
|
for ts in c.execute(
|
@@ -1342,11 +1326,11 @@ def _target_file(db: partial, t_id: int) -> TargetFile:
|
|
1342
1326
|
truth_settings.append(TruthSetting(config=entry.get('config', None),
|
1343
1327
|
function=entry.get('function', None),
|
1344
1328
|
index=entry.get('index', None)))
|
1345
|
-
return TargetFile(name=
|
1346
|
-
samples=
|
1347
|
-
level_type=
|
1329
|
+
return TargetFile(name=target_file.name,
|
1330
|
+
samples=target_file.samples,
|
1331
|
+
level_type=target_file.level_type,
|
1348
1332
|
truth_settings=truth_settings,
|
1349
|
-
speaker_id=
|
1333
|
+
speaker_id=target_file.speaker_id)
|
1350
1334
|
|
1351
1335
|
|
1352
1336
|
@lru_cache
|
@@ -1387,19 +1371,29 @@ def _mixture(db: partial, m_id: int) -> Mixture:
|
|
1387
1371
|
"""
|
1388
1372
|
from .helpers import to_mixture
|
1389
1373
|
from .helpers import to_target
|
1374
|
+
from .db_datatypes import MixtureRecord
|
1375
|
+
from .db_datatypes import TargetRecord
|
1390
1376
|
|
1391
1377
|
with db() as c:
|
1392
|
-
mixture = c.execute(
|
1393
|
-
|
1394
|
-
"
|
1395
|
-
"FROM mixture " +
|
1396
|
-
"WHERE ? = mixture.id",
|
1397
|
-
(m_id + 1,)).fetchone()
|
1398
|
-
|
1399
|
-
targets = [to_target(target) for target in c.execute(
|
1400
|
-
"SELECT target.file_id, augmentation, gain " +
|
1378
|
+
mixture = MixtureRecord(*c.execute("SELECT * FROM mixture WHERE ? = mixture.id", (m_id + 1,)).fetchone())
|
1379
|
+
targets = [to_target(TargetRecord(*target)) for target in c.execute(
|
1380
|
+
"SELECT target.* " +
|
1401
1381
|
"FROM target, mixture_target " +
|
1402
1382
|
"WHERE ? = mixture_target.mixture_id AND target.id = mixture_target.target_id",
|
1403
|
-
(mixture
|
1383
|
+
(mixture.id,)).fetchall()]
|
1404
1384
|
|
1405
1385
|
return to_mixture(mixture, targets)
|
1386
|
+
|
1387
|
+
|
1388
|
+
@lru_cache
|
1389
|
+
def _speaker(db: partial, s_id: int | None, tier: str) -> Optional[str]:
|
1390
|
+
if s_id is None:
|
1391
|
+
return None
|
1392
|
+
|
1393
|
+
with db() as c:
|
1394
|
+
data = c.execute(f'SELECT {tier} FROM speaker WHERE ? = id', (s_id,)).fetchone()
|
1395
|
+
if data is None:
|
1396
|
+
return None
|
1397
|
+
if data[0] is None:
|
1398
|
+
return None
|
1399
|
+
return data[0]
|
@@ -36,13 +36,14 @@ sonusai/mixture/class_count.py,sha256=_wFnVl2yEOnbor7pLg7cYOUeX6nioov-03Cv3SEbh2
|
|
36
36
|
sonusai/mixture/config.py,sha256=d2IzZ1samHWGMpoKzSmUwMyAWWhgmyNoxyO8oiUwbsg,22193
|
37
37
|
sonusai/mixture/constants.py,sha256=ZRM7Z8e6EwnL9RwaMVxks-QokN9KMWxnQzAf9VNxa9M,1408
|
38
38
|
sonusai/mixture/datatypes.py,sha256=uVJtT2sVGS531pSglhaLLF5hZcI3_0oKQOWmMkrCwqo,8253
|
39
|
+
sonusai/mixture/db_datatypes.py,sha256=GDYbcSrlgUJsesiUUNnR4s5aBkMgviiNSQDaBcgYX7I,1428
|
39
40
|
sonusai/mixture/eq_rule_is_valid.py,sha256=MpQwRA5M76wSiQWEI1lW2cLFdPaMttBLcQp3tWD8efM,1243
|
40
41
|
sonusai/mixture/feature.py,sha256=Rwuf82IoXzhHPGbKYVGcatImF_ssBf_FfvbqghVPXtg,4116
|
41
|
-
sonusai/mixture/generation.py,sha256=
|
42
|
-
sonusai/mixture/helpers.py,sha256=
|
42
|
+
sonusai/mixture/generation.py,sha256=ohZnhtHIrdQDql2OF703NnhK07Ys-1qAjiwrIql-oMw,42694
|
43
|
+
sonusai/mixture/helpers.py,sha256=eC9ZysEa-83VLKen_9PKWzr8w9dkHj4lp6rMB2fNLbg,24759
|
43
44
|
sonusai/mixture/log_duration_and_sizes.py,sha256=baTUpqyM15wA125jo9E3posmVJUe3WlpksyO6v9Jul0,1347
|
44
45
|
sonusai/mixture/mapped_snr_f.py,sha256=Fdf2uw62FvyKvVy5VywaUtPZGO1zCWQsHlte0bwkKPQ,3121
|
45
|
-
sonusai/mixture/mixdb.py,sha256=
|
46
|
+
sonusai/mixture/mixdb.py,sha256=s40-NToxNXz3UtiVZW9chHIV-tpqT6u-GbFPg8LfQoc,51644
|
46
47
|
sonusai/mixture/soundfile_audio.py,sha256=mHa5SIXsu_uE0j3DO52GydRJrvWSzU_nII-7YJfQ6Qo,4154
|
47
48
|
sonusai/mixture/sox_audio.py,sha256=HT3kYA9TP5QPCuoOJdUMnGVN-qY6q96DGL8zxuog76o,12277
|
48
49
|
sonusai/mixture/sox_augmentation.py,sha256=kBWPrsFk0EBi71nLcKt5v0GA34bY7g9D9x0cEamNWbU,4564
|
@@ -115,7 +116,7 @@ sonusai/utils/stratified_shuffle_split.py,sha256=rJNXvBp-GxoKzH3OpL7k0ANSu5xMP2z
|
|
115
116
|
sonusai/utils/write_audio.py,sha256=ZsPGExwM86QHLLN2LOWekK2uAqf5pV_1oRW811p0QAI,840
|
116
117
|
sonusai/utils/yes_or_no.py,sha256=eMLXBVH0cEahiXY4W2KNORmwNQ-ba10eRtldh0y4NYg,263
|
117
118
|
sonusai/vars.py,sha256=m2AefF0m5bXWGXpJj8Pi42zWL2ydeEj7bkak3GrtMyM,940
|
118
|
-
sonusai-0.18.
|
119
|
-
sonusai-0.18.
|
120
|
-
sonusai-0.18.
|
121
|
-
sonusai-0.18.
|
119
|
+
sonusai-0.18.2.dist-info/METADATA,sha256=PNDYtM4HDRWpp3GBcuos7jymdaKRoXOT7DlLn-fs8XE,2591
|
120
|
+
sonusai-0.18.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
121
|
+
sonusai-0.18.2.dist-info/entry_points.txt,sha256=zMNjEphEPO6B3cD1GNpit7z-yA9tUU5-j3W2v-UWstU,92
|
122
|
+
sonusai-0.18.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|