nkululeko 0.83.2__py3-none-any.whl → 0.83.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.83.2"
1
+ VERSION="0.83.3"
2
2
  SAMPLING_RATE = 16000
nkululeko/experiment.py CHANGED
@@ -692,22 +692,26 @@ class Experiment:
692
692
  if self.runmgr.modelrunner.model.is_ann():
693
693
  self.runmgr.modelrunner.model = None
694
694
  self.util.warn(
695
- f"Save experiment: Can't pickle the learning model so saving without it."
695
+ "Save experiment: Can't pickle the learning model so saving without it."
696
696
  )
697
697
  try:
698
698
  f = open(filename, "wb")
699
699
  pickle.dump(self.__dict__, f)
700
700
  f.close()
701
- except TypeError:
701
+ except (TypeError, AttributeError) as error:
702
702
  self.feature_extractor.feat_extractor.model = None
703
703
  f = open(filename, "wb")
704
704
  pickle.dump(self.__dict__, f)
705
705
  f.close()
706
706
  self.util.warn(
707
- f"Save experiment: Can't pickle the feature extraction model so saving without it."
707
+ "Save experiment: Can't pickle the feature extraction model so saving without it."
708
+ + f"{type(error).__name__} {error}"
709
+ )
710
+ except RuntimeError as error:
711
+ self.util.warn(
712
+ "Save experiment: Can't pickle local object, NOT saving: "
713
+ + f"{type(error).__name__} {error}"
708
714
  )
709
- except (AttributeError, RuntimeError) as error:
710
- self.util.warn(f"Save experiment: Can't pickle local object: {error}")
711
715
 
712
716
  def save_onnx(self, filename):
713
717
  # export the model to onnx
@@ -1,35 +1,39 @@
1
1
  # feats_trill.py
2
- import tensorflow_hub as hub
3
2
  import os
3
+
4
+ import pandas as pd
4
5
  import tensorflow as tf
5
- from numpy.core.numeric import tensordot
6
+ import tensorflow_hub as hub
6
7
  from tqdm import tqdm
7
- import pandas as pd
8
+
8
9
  import audiofile as af
9
- from nkululeko.utils.util import Util
10
- import nkululeko.glob_conf as glob_conf
10
+
11
11
  from nkululeko.feat_extract.featureset import Featureset
12
+ import nkululeko.glob_conf as glob_conf
13
+ from nkululeko.utils.util import Util
14
+
12
15
 
13
16
  # Import TF 2.X and make sure we're running eager.
14
17
  assert tf.executing_eagerly()
15
18
 
16
19
 
17
20
  class TRILLset(Featureset):
18
- """A feature extractor for the Google TRILL embeddings"""
21
+ """A feature extractor for the Google TRILL embeddings.
19
22
 
20
- """https://ai.googleblog.com/2020/06/improving-speech-representations-and.html"""
23
+ See https://ai.googleblog.com/2020/06/improving-speech-representations-and.html.
24
+ """
21
25
 
22
26
  # Initialization of the class
23
27
  def __init__(self, name, data_df, feats_type):
24
- """
25
- Initialize the class with name, data and Util instance
26
- Also loads the model from hub
28
+ """Initialize the class with name, data and Util instance.
27
29
 
28
- :param name: Name of the class
29
- :type name: str
30
- :param data_df: Data of the class
31
- :type data_df: DataFrame
32
- :return: None
30
+ Also loads the model from hub
31
+ Args:
32
+ :param name: Name of the class
33
+ :type name: str
34
+ :param data_df: Data of the class
35
+ :type data_df: DataFrame
36
+ :return: None
33
37
  """
34
38
  super().__init__(name, data_df, feats_type)
35
39
  # Load the model from the configured path
@@ -38,25 +42,21 @@ class TRILLset(Featureset):
38
42
  "trill.model",
39
43
  "https://tfhub.dev/google/nonsemantic-speech-benchmark/trill/3",
40
44
  )
41
- self.module = hub.load(model_path)
45
+ self.model = hub.load(model_path)
42
46
  self.feats_type = feats_type
43
47
 
44
48
  def extract(self):
45
49
  store = self.util.get_path("store")
46
50
  storage = f"{store}{self.name}.pkl"
47
- extract = self.util.config_val(
48
- "FEATS", "needs_feature_extraction", False)
51
+ extract = self.util.config_val("FEATS", "needs_feature_extraction", False)
49
52
  no_reuse = eval(self.util.config_val("FEATS", "no_reuse", "False"))
50
53
  if extract or no_reuse or not os.path.isfile(storage):
51
- self.util.debug(
52
- "extracting TRILL embeddings, this might take a while...")
54
+ self.util.debug("extracting TRILL embeddings, this might take a while...")
53
55
  emb_series = pd.Series(index=self.data_df.index, dtype=object)
54
- length = len(self.data_df.index)
55
56
  for idx, file in enumerate(tqdm(self.data_df.index.get_level_values(0))):
56
- emb = self.getEmbeddings(file)
57
- emb_series[idx] = emb
58
- self.df = pd.DataFrame(
59
- emb_series.values.tolist(), index=self.data_df.index)
57
+ emb = self.get_embeddings(file)
58
+ emb_series.iloc[idx] = emb
59
+ self.df = pd.DataFrame(emb_series.values.tolist(), index=self.data_df.index)
60
60
  self.df.to_pickle(storage)
61
61
  try:
62
62
  glob_conf.config["DATA"]["needs_feature_extraction"] = "false"
@@ -70,15 +70,15 @@ class TRILLset(Featureset):
70
70
  if len(wav.shape) > 1:
71
71
  wav = tf.reduce_mean(wav, axis=0)
72
72
 
73
- emb_dict = self.module(samples=wav, sample_rate=tf.constant(16000))
73
+ emb_dict = self.model(samples=wav, sample_rate=tf.constant(16000))
74
74
  return emb_dict["embedding"]
75
75
 
76
- def getEmbeddings(self, file):
76
+ def get_embeddings(self, file):
77
77
  wav = af.read(file)[0]
78
- emb_short = self.getEmbeddings_signal(wav, 16000)
78
+ emb_short = self.get_embeddings_signal(wav, 16000)
79
79
  return emb_short
80
80
 
81
- def getEmbeddings_signal(self, signal, sr):
81
+ def get_embeddings_signal(self, signal, sr):
82
82
  wav = tf.convert_to_tensor(signal)
83
83
  emb_short = self.embed_wav(wav)
84
84
  # you get one embedding per frame, we use the mean for all the frames
@@ -86,7 +86,7 @@ class TRILLset(Featureset):
86
86
  return emb_short
87
87
 
88
88
  def extract_sample(self, signal, sr):
89
- if self.module == None:
89
+ if self.model == None:
90
90
  self.__init__("na", None)
91
- feats = self.getEmbeddings_signal(signal, sr)
91
+ feats = self.get_embeddings_signal(signal, sr)
92
92
  return feats
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nkululeko
3
- Version: 0.83.2
3
+ Version: 0.83.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
@@ -333,6 +333,10 @@ F. Burkhardt, Johannes Wagner, Hagen Wierstorf, Florian Eyben and Björn Schulle
333
333
  Changelog
334
334
  =========
335
335
 
336
+ Version 0.83.3
337
+ --------------
338
+ * fixed a naming error in trill features that prevented storage of experiment
339
+
336
340
  Version 0.83.2
337
341
  --------------
338
342
  * added default cuda if present and not stated
@@ -2,11 +2,11 @@ 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=VE94aCLZ8N-hTKIgb4OLo1s9l_Fxncl9iTNis0eotFw,39
5
+ nkululeko/constants.py,sha256=zgeDgqWCuY5esPoOf_ve4SZAnwvJCy_A_qNl_zaWAHM,39
6
6
  nkululeko/demo.py,sha256=55kNFA2helMhOxD4yZuKg1JWDtlUUpxm-6uAnroIydI,3264
7
7
  nkululeko/demo_feats.py,sha256=sAeGFojhEj9WEDFtG3SzPBmyYJWLF2rkbpp65m8Ujo4,2025
8
8
  nkululeko/demo_predictor.py,sha256=-ggSHc3DXxRzjzcGB4qFBOMvKsfUdTkkde50BDrS9dA,4755
9
- nkululeko/experiment.py,sha256=WyLiOJ_VxlaXoS1cwXruzYV9OESMjjedcFNreKE1Z8I,29728
9
+ nkululeko/experiment.py,sha256=RZfVevt7bYX8SGJ8o9HWKoZ_OVec7K_9A0HkgJYt8dA,29873
10
10
  nkululeko/explore.py,sha256=2wdoGRqldvsN1zCiWk0quSDgHHHUoF2UZOWQ1r-2OLM,2310
11
11
  nkululeko/export.py,sha256=mHeEAAmtZuxdyebLlbSzPrHSi9OMgJHbk35d3DTxRBc,4632
12
12
  nkululeko/feature_extractor.py,sha256=8mssYKmo4LclVI-hiLmJEDZ0ZPyDavFG2YwtXcrGzwM,3976
@@ -64,7 +64,7 @@ nkululeko/feat_extract/feats_snr.py,sha256=9dqZ-4RpK98iJEssM3ttozNd18LWlZYM_QVXv
64
64
  nkululeko/feat_extract/feats_spectra.py,sha256=5Pex8awIQC3cjQRHSu4NQFmg4quamG0RL3V3Yd0pJHs,3670
65
65
  nkululeko/feat_extract/feats_spkrec.py,sha256=VK4ma3uWzM0YZStsgRTirfkbzjWIfRWSgsYI038QlRY,4803
66
66
  nkululeko/feat_extract/feats_squim.py,sha256=Y31YmDmscuG0YozvxyBZIutO3id8t7IZJWCfKucw-6M,4617
67
- nkululeko/feat_extract/feats_trill.py,sha256=HXQBaPWTX0iNEjBY7RD8uyFeYjDieHqv8ZilE0Jb-Pg,3319
67
+ nkululeko/feat_extract/feats_trill.py,sha256=K2ahhdpwpjgg3WZS1POg3UMP2U44i8cLZZvn5Rq7fUI,3228
68
68
  nkululeko/feat_extract/feats_wav2vec2.py,sha256=9WUMfyddB_3nx79g7mZoQrRynhM1uEBWuOotRq8bxoU,5268
69
69
  nkululeko/feat_extract/feats_wavlm.py,sha256=ulxpGjifUFx2ZgGmY32SmBJGIuvkYHoLb2n1LZ8KMwA,4703
70
70
  nkululeko/feat_extract/feats_whisper.py,sha256=BFspQBI53HAgw22vBEeFskGwFZA-94Rpl17xM458HRo,4576
@@ -103,8 +103,8 @@ nkululeko/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  nkululeko/utils/files.py,sha256=UiGAtZRWYjHSvlmPaTMtzyNNGE6qaLaxQkybctS7iRM,4021
104
104
  nkululeko/utils/stats.py,sha256=1yUq0FTOyqkU8TwUocJRYdJaqMU5SlOBBRUun9STo2M,2829
105
105
  nkululeko/utils/util.py,sha256=_Z6OMJ3f-8TdETW9eqJYY5hwNRS5XCt9azzRnqoTTZE,12330
106
- nkululeko-0.83.2.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
107
- nkululeko-0.83.2.dist-info/METADATA,sha256=DMkXO8jSm6iR4eETrG2aEK__7MfPhpAvOe6Tf99n_HE,36158
108
- nkululeko-0.83.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
- nkululeko-0.83.2.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
110
- nkululeko-0.83.2.dist-info/RECORD,,
106
+ nkululeko-0.83.3.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
107
+ nkululeko-0.83.3.dist-info/METADATA,sha256=rowQ7syG1q0BotCIiP9ZbiiMgNNvYxuRKYTvIztWMXs,36267
108
+ nkululeko-0.83.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
+ nkululeko-0.83.3.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
110
+ nkululeko-0.83.3.dist-info/RECORD,,