nkululeko 0.80.1__py3-none-any.whl → 0.80.3__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.
nkululeko/constants.py CHANGED
@@ -1,2 +1,2 @@
1
- VERSION="0.80.1"
1
+ VERSION="0.80.3"
2
2
  SAMPLING_RATE = 16000
@@ -1,6 +1,5 @@
1
1
  import pandas as pd
2
2
  import numpy as np
3
- import sounddevice as sd
4
3
  import audiofile
5
4
  import nkululeko.glob_conf as glob_conf
6
5
  from nkululeko.utils.util import Util
@@ -84,6 +83,8 @@ class Demo_predictor:
84
83
  return dict_2
85
84
 
86
85
  def record_audio(self, seconds):
86
+ import sounddevice as sd
87
+
87
88
  print("recording ...")
88
89
  y = sd.rec(int(seconds * self.sr), samplerate=self.sr, channels=1)
89
90
  sd.wait()
@@ -91,6 +92,8 @@ class Demo_predictor:
91
92
  return y
92
93
 
93
94
  def play_audio(self, signal):
95
+ import sounddevice as sd
96
+
94
97
  print("playback ...")
95
98
  sd.play(signal.T, self.sr)
96
99
  status = sd.wait()
@@ -18,6 +18,9 @@ class AudModelAgenderSet(Featureset):
18
18
 
19
19
  def __init__(self, name, data_df):
20
20
  super().__init__(name, data_df)
21
+ self.model_loaded = False
22
+
23
+ def _load_model(self):
21
24
  model_url = "https://zenodo.org/record/7761387/files/w2v2-L-robust-6-age-gender.25c844af-1.1.1.zip"
22
25
  model_root = self.util.config_val(
23
26
  "FEATS", "agender.model", "./audmodel_agender/"
@@ -25,12 +28,15 @@ class AudModelAgenderSet(Featureset):
25
28
  if not os.path.isdir(model_root):
26
29
  cache_root = audeer.mkdir("cache")
27
30
  model_root = audeer.mkdir(model_root)
28
- archive_path = audeer.download_url(
29
- model_url, cache_root, verbose=True
30
- )
31
+ archive_path = audeer.download_url(model_url, cache_root, verbose=True)
31
32
  audeer.extract_archive(archive_path, model_root)
32
33
  device = self.util.config_val("MODEL", "device", "cpu")
33
34
  self.model = audonnx.load(model_root, device=device)
35
+ pytorch_total_params = sum(p.numel() for p in self.model.parameters())
36
+ self.util.debug(
37
+ f"initialized agender model with {pytorch_total_params} parameters in total"
38
+ )
39
+ self.model_loaded = True
34
40
 
35
41
  def extract(self):
36
42
  """Extract the features based on the initialized dataset or re-open them when found on disk."""
@@ -43,9 +49,10 @@ class AudModelAgenderSet(Featureset):
43
49
  no_reuse = eval(self.util.config_val("FEATS", "no_reuse", "False"))
44
50
  if no_reuse or extract or not os.path.isfile(storage):
45
51
  self.util.debug(
46
- "extracting agender model embeddings, this might take a"
47
- " while..."
52
+ "extracting agender model embeddings, this might take a" " while..."
48
53
  )
54
+ if not self.model_loaded:
55
+ self._load_model()
49
56
  hidden_states = audinterface.Feature(
50
57
  self.model.labels("hidden_states"),
51
58
  process_func=self.model,
@@ -18,6 +18,9 @@ class AgenderAgenderSet(Featureset):
18
18
 
19
19
  def __init__(self, name, data_df):
20
20
  super().__init__(name, data_df)
21
+ self.model_loaded = False
22
+
23
+ def _load_model(self):
21
24
  model_url = "https://zenodo.org/record/7761387/files/w2v2-L-robust-6-age-gender.25c844af-1.1.1.zip"
22
25
  model_root = self.util.config_val(
23
26
  "FEATS", "agender.model", "./audmodel_agender/"
@@ -33,6 +36,7 @@ class AgenderAgenderSet(Featureset):
33
36
  self.util.debug(
34
37
  f"initialized agender model with {pytorch_total_params} parameters in total"
35
38
  )
39
+ self.model_loaded = True
36
40
 
37
41
  def extract(self):
38
42
  """Extract the features based on the initialized dataset or re-open them when found on disk."""
@@ -48,6 +52,8 @@ class AgenderAgenderSet(Featureset):
48
52
  self.util.debug(
49
53
  "extracting agender model age and gender, this might take a" " while..."
50
54
  )
55
+ if not self.model_loaded:
56
+ self._load_model()
51
57
  outputs = ["logits_age", "logits_gender"]
52
58
  logits = audinterface.Feature(
53
59
  self.model.labels(outputs),
@@ -20,6 +20,9 @@ class AudModelSet(Featureset):
20
20
 
21
21
  def __init__(self, name, data_df):
22
22
  super().__init__(name, data_df)
23
+ self.model_loaded = False
24
+
25
+ def _load_model(self):
23
26
  model_url = "https://zenodo.org/record/6221127/files/w2v2-L-robust-12.6bc4a7fd-1.1.0.zip"
24
27
  model_root = self.util.config_val("FEATS", "aud.model", "./audmodel/")
25
28
  if not os.path.isdir(model_root):
@@ -30,6 +33,7 @@ class AudModelSet(Featureset):
30
33
  cuda = "cuda" if torch.cuda.is_available() else "cpu"
31
34
  device = self.util.config_val("MODEL", "device", cuda)
32
35
  self.model = audonnx.load(model_root, device=device)
36
+ self.model_loaded = True
33
37
 
34
38
  def extract(self):
35
39
  """Extract the features based on the initialized dataset or re-open them when found on disk."""
@@ -44,6 +48,8 @@ class AudModelSet(Featureset):
44
48
  self.util.debug(
45
49
  "extracting audmodel embeddings, this might take a while..."
46
50
  )
51
+ if not self.model_loaded:
52
+ self._load_model()
47
53
  hidden_states = audinterface.Feature(
48
54
  self.model.labels("hidden_states"),
49
55
  process_func=self.model,
@@ -18,6 +18,9 @@ class AudModelDimSet(Featureset):
18
18
 
19
19
  def __init__(self, name, data_df):
20
20
  super().__init__(name, data_df)
21
+ self.model_loaded = False
22
+
23
+ def _load_model(self):
21
24
  model_url = "https://zenodo.org/record/6221127/files/w2v2-L-robust-12.6bc4a7fd-1.1.0.zip"
22
25
  model_root = self.util.config_val("FEATS", "aud.model", "./audmodel/")
23
26
  if not os.path.isdir(model_root):
@@ -25,8 +28,10 @@ class AudModelDimSet(Featureset):
25
28
  model_root = audeer.mkdir(model_root)
26
29
  archive_path = audeer.download_url(model_url, cache_root, verbose=True)
27
30
  audeer.extract_archive(archive_path, model_root)
28
- device = self.util.config_val("MODEL", "device", "cpu")
31
+ cuda = "cuda" if torch.cuda.is_available() else "cpu"
32
+ device = self.util.config_val("MODEL", "device", cuda)
29
33
  self.model = audonnx.load(model_root, device=device)
34
+ self.model_loaded = True
30
35
 
31
36
  def extract(self):
32
37
  """Extract the features based on the initialized dataset or re-open them when found on disk."""
@@ -41,6 +46,8 @@ class AudModelDimSet(Featureset):
41
46
  self.util.debug(
42
47
  "extracting audmodel dimensions, this might take a while..."
43
48
  )
49
+ if not self.model_loaded:
50
+ self._load_model()
44
51
  logits = audinterface.Feature(
45
52
  self.model.labels("logits"),
46
53
  process_func=self.model,
@@ -107,8 +107,8 @@ class MLP_model(Model):
107
107
  logits[start_index:end_index, :] = model(features.to(device))
108
108
  targets[start_index:end_index] = labels
109
109
  loss = self.criterion(
110
- logits[start_index:end_index, :],
111
- labels.to(self.device, dtype=torch.int64),
110
+ logits[start_index:end_index, :].to(device),
111
+ labels.to(device, dtype=torch.int64),
112
112
  )
113
113
  losses.append(loss.item())
114
114
 
@@ -185,7 +185,12 @@ class MLP_Reg_model(Model):
185
185
  end_index = len(loader.dataset)
186
186
  logits[start_index:end_index] = model(features.to(device)).reshape(-1)
187
187
  targets[start_index:end_index] = labels
188
- loss = self.criterion(logits[start_index:end_index], labels.to(device))
188
+ loss = self.criterion(
189
+ logits[start_index:end_index].to(
190
+ device,
191
+ ),
192
+ labels.to(device),
193
+ )
189
194
  losses.append(loss.item())
190
195
  self.loss_eval = (np.asarray(losses)).mean()
191
196
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nkululeko
3
- Version: 0.80.1
3
+ Version: 0.80.3
4
4
  Summary: Machine learning audio prediction experiments based on templates
5
5
  Home-page: https://github.com/felixbur/nkululeko
6
6
  Author: Felix Burkhardt
@@ -19,22 +19,18 @@ Requires-Dist: audinterface
19
19
  Requires-Dist: audiofile
20
20
  Requires-Dist: audiomentations
21
21
  Requires-Dist: audonnx
22
- Requires-Dist: cylimiter
23
22
  Requires-Dist: datasets
24
23
  Requires-Dist: imageio
25
- Requires-Dist: imbalanced-learn
26
24
  Requires-Dist: laion-clap
27
25
  Requires-Dist: matplotlib
28
26
  Requires-Dist: numpy
29
27
  Requires-Dist: opensmile
30
28
  Requires-Dist: pandas
31
29
  Requires-Dist: praat-parselmouth
32
- Requires-Dist: pylatex
33
30
  Requires-Dist: scikit-learn
34
31
  Requires-Dist: scipy
35
32
  Requires-Dist: seaborn
36
33
  Requires-Dist: sounddevice
37
- Requires-Dist: splitutils
38
34
  Requires-Dist: tensorflow
39
35
  Requires-Dist: tensorflow-hub
40
36
  Requires-Dist: torch
@@ -42,6 +38,7 @@ Requires-Dist: torchvision
42
38
  Requires-Dist: transformers
43
39
  Requires-Dist: umap-learn
44
40
  Requires-Dist: xgboost
41
+ Requires-Dist: pylatex
45
42
 
46
43
  - [Overview](#overview)
47
44
  - [Confusion matrix](#confusion-matrix)
@@ -322,6 +319,14 @@ F. Burkhardt, Johannes Wagner, Hagen Wierstorf, Florian Eyben and Björn Schulle
322
319
  Changelog
323
320
  =========
324
321
 
322
+ Version 0.80.3
323
+ --------------
324
+ * made sounddevice use optional as Portaudio library causes difficulties
325
+
326
+ Version 0.80.2
327
+ --------------
328
+ * fixed bug that caused clash with GPU/CPU use
329
+
325
330
  Version 0.80.1
326
331
  --------------
327
332
  * added support for string value in import_features
@@ -2,10 +2,10 @@ nkululeko/__init__.py,sha256=62f8HiEzJ8rG2QlTFJXUCMpvuH3fKI33DoJSj33mscc,63
2
2
  nkululeko/aug_train.py,sha256=YhuZnS_WVWnun9G-M6g5n6rbRxoVREz6Zh7k6qprFNQ,3194
3
3
  nkululeko/augment.py,sha256=4MG0apTAG5RgkuJrYEjGgDdbodZWi_HweSPNI1JJ5QA,3051
4
4
  nkululeko/cacheddataset.py,sha256=lIJ6hUo5LoxSrzXtWV8mzwO7wRtUETWnOQ4ws2XfL1E,969
5
- nkululeko/constants.py,sha256=PjrmxRyljCQ53PzG5WIALMzgVNR8dJ4k70ZhEHPpQ98,39
5
+ nkululeko/constants.py,sha256=IPY9v40lXzVxgs84Z7_8q0a634DMA9yJhmXrIkKG2m4,39
6
6
  nkululeko/demo.py,sha256=l_rxmDCaVO3hchWSQYzh3dJ5U-6CHE0umbfxIsES5s0,2196
7
7
  nkululeko/demo_feats.py,sha256=sAeGFojhEj9WEDFtG3SzPBmyYJWLF2rkbpp65m8Ujo4,2025
8
- nkululeko/demo_predictor.py,sha256=o8bXdH2r_7K-9N033iL9i7vYJXS2baPxi8rYqFlhodk,3751
8
+ nkululeko/demo_predictor.py,sha256=mmZ3fzaSmrc6GXfduWBon9ElpWo7mMBHyOmk-LVCbbE,3794
9
9
  nkululeko/experiment.py,sha256=972eUHFCF08J2HbtFtOzu7vRl2sU7x3fqjxTvY5htjQ,29542
10
10
  nkululeko/explore.py,sha256=5c89hGpjt5mRMN7w2Ajjnr2VjoFF0hOFs0O1BQruw80,2250
11
11
  nkululeko/export.py,sha256=mHeEAAmtZuxdyebLlbSzPrHSi9OMgJHbk35d3DTxRBc,4632
@@ -48,11 +48,11 @@ nkululeko/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  nkululeko/data/dataset.py,sha256=TVT_uF-pU14Nc3EQG5Fmi4dS4y38tgZu_ERaYhPXpdo,27080
49
49
  nkululeko/data/dataset_csv.py,sha256=v3lSjF23EVjoP460QOfhdcqbWAlBQWlBOuaYujZoS4s,3407
50
50
  nkululeko/feat_extract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
- nkululeko/feat_extract/feats_agender.py,sha256=sDfsvSC2zt1JLn5rmB7bdck1JmXIIol3oIwN90TossM,2867
52
- nkululeko/feat_extract/feats_agender_agender.py,sha256=Gih3Ufr8aLu3QfjTV1w7M_wkMU4a4MHG5B6mUkC99UI,3110
51
+ nkululeko/feat_extract/feats_agender.py,sha256=_lAL6IxJDJH2bhIvd7yarTqQryx7FjbQXAgY0mJP-KI,3192
52
+ nkululeko/feat_extract/feats_agender_agender.py,sha256=ckQN8K02vdPLUWIylxg5Z4X145gBlPbSDbyBRjabLD0,3278
53
53
  nkululeko/feat_extract/feats_analyser.py,sha256=_5oz4y-NZCEBgfNP2GZ9WNqQR50Hbykm0TvDVomWP0U,11399
54
- nkululeko/feat_extract/feats_audmodel.py,sha256=ifXo4ItOGiSD8QUA64Ha-lf_4-_0MQuJKQdx5x0E_VA,2940
55
- nkululeko/feat_extract/feats_audmodel_dim.py,sha256=HZtQc7_4lIbReUz41Ks-EewcKOmkMc0V98pHTCCIMto,2849
54
+ nkululeko/feat_extract/feats_audmodel.py,sha256=TRCkLqPgnyWN-OAcO69pPZF2FIbBy5ERb5ZY22qh6iA,3108
55
+ nkululeko/feat_extract/feats_audmodel_dim.py,sha256=yg39CSR0b54AJyOAlXO3M1ohyY9Rbrjf18pllsoQ03g,3078
56
56
  nkululeko/feat_extract/feats_clap.py,sha256=v82mbjdjGDSKUUBggttw7jW0oka22fWAmfUf-4VmaDU,3379
57
57
  nkululeko/feat_extract/feats_hubert.py,sha256=uL-9mgQHuGPQi1nuUaw6aNU9DscsO89uJAmBdmnCegM,5205
58
58
  nkululeko/feat_extract/feats_import.py,sha256=m7Yh1sj7C1yrDDbZAqS75oMMF5rAtO7XC_sdWdQN5Iw,1598
@@ -81,8 +81,8 @@ nkululeko/models/model_gmm.py,sha256=onovzGBeguwZ-upXtuDLaBw9sd6fDDQslVBOrz1Z8TE
81
81
  nkululeko/models/model_knn.py,sha256=5tGqiPo2JTw9VLmD-MXNZKFJ5RTLA6uv_blJDJ9lScA,573
82
82
  nkululeko/models/model_knn_reg.py,sha256=Fbuk6Ku6eyrbbMEk7rB5dwfhvQOMsdZk6HI_0T0gYPw,580
83
83
  nkululeko/models/model_lin_reg.py,sha256=NBTnY2ULuhUBt5ArYQwskZ2Vq4BBDGkqd9SYBFl7Ql4,392
84
- nkululeko/models/model_mlp.py,sha256=NzUPKAJDssPJ_YsdWPgbiikf6W7uhTYWjmIPiKyhYW4,9091
85
- nkululeko/models/model_mlp_regression.py,sha256=DSbXtmLiq7rMGkTMr7zbPVkpc5m42jwCkP1eDGf9jO0,9934
84
+ nkululeko/models/model_mlp.py,sha256=IjiiupLxm5ddb73-eU5Ad79Gb6enurR1fgGY-7NkbFc,9097
85
+ nkululeko/models/model_mlp_regression.py,sha256=OFsGQXS4EhRMq3exZAMLF-vJARxIWH6TZjMKoueUkLs,10051
86
86
  nkululeko/models/model_svm.py,sha256=-5DHtdm4q6JqbBY60a38sRUg6wSoPtm_TGnekGQlBTM,572
87
87
  nkululeko/models/model_svr.py,sha256=qPG54wqccIM-Yse-95wKGTQdTZDa1bUHpZky110KlSY,532
88
88
  nkululeko/models/model_tree.py,sha256=soXjV523eRvRZ-jbX7X_3S73Wto1B9bm7ZzzDmgYzTc,390
@@ -101,8 +101,8 @@ nkululeko/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
101
  nkululeko/utils/files.py,sha256=UiGAtZRWYjHSvlmPaTMtzyNNGE6qaLaxQkybctS7iRM,4021
102
102
  nkululeko/utils/stats.py,sha256=29otJpUp1VqbtDKmlLkPPzBmVfTFiHZ70rUdR4860rM,2788
103
103
  nkululeko/utils/util.py,sha256=Hn27x0f2rjSR-iae2h9_70J4SdXKJTduLFIH13w3db0,12363
104
- nkululeko-0.80.1.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
105
- nkululeko-0.80.1.dist-info/METADATA,sha256=_kjligQaChrCbn5le4rfDAJrRKOZcAGiPNwNjrbSqA0,33856
106
- nkululeko-0.80.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
107
- nkululeko-0.80.1.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
108
- nkululeko-0.80.1.dist-info/RECORD,,
104
+ nkululeko-0.80.3.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
105
+ nkululeko-0.80.3.dist-info/METADATA,sha256=opZJ9__Inp8pyRCkhuzil7h0WsywIwdq7GQtdn4nXTU,33955
106
+ nkululeko-0.80.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
107
+ nkululeko-0.80.3.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
108
+ nkululeko-0.80.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5