nkululeko 0.90.4__py3-none-any.whl → 0.91.1__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.90.4"
1
+ VERSION="0.91.1"
2
2
  SAMPLING_RATE = 16000
nkululeko/ensemble.py CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env python3
1
2
  """
2
3
  Ensemble predictions from multiple experiments.
3
4
 
@@ -16,9 +17,6 @@ Raises:
16
17
  AssertionError: If the number of config files is less than 2 for majority voting.
17
18
  """
18
19
 
19
- #!/usr/bin/env python
20
- # -*- coding: utf-8 -*-
21
-
22
20
 
23
21
  import configparser
24
22
  import time
@@ -300,10 +298,10 @@ def ensemble_predictions(
300
298
  return ensemble_preds
301
299
 
302
300
 
303
- def main(src_dir: Path) -> None:
301
+ def main():
304
302
  parser = ArgumentParser()
305
303
  parser.add_argument(
306
- "configs",
304
+ "--config",
307
305
  nargs="+",
308
306
  help="Paths to the configuration files of the experiments to ensemble. \
309
307
  Can be INI files for Nkululeko.nkululeko or CSV files from Nkululeko.demo.",
@@ -356,7 +354,7 @@ def main(src_dir: Path) -> None:
356
354
  start = time.time()
357
355
 
358
356
  ensemble_preds = ensemble_predictions(
359
- args.configs, args.method, args.threshold, args.weights, args.no_labels
357
+ args.config, args.method, args.threshold, args.weights, args.no_labels
360
358
  )
361
359
 
362
360
  # save to csv
@@ -368,5 +366,4 @@ def main(src_dir: Path) -> None:
368
366
 
369
367
 
370
368
  if __name__ == "__main__":
371
- cwd = Path(__file__).parent
372
- main(cwd)
369
+ main()
nkululeko/segment.py CHANGED
@@ -1,5 +1,22 @@
1
- # segment.py
2
- # segment data splits
1
+ """
2
+ Segments the samples in the dataset into chunks based on voice activity detection using SILERO VAD [1].
3
+
4
+ The segmentation results are saved to a file, and the distributions of the original and
5
+ segmented durations are plotted.
6
+
7
+ The module also handles configuration options, such as the segmentation method and sample
8
+ selection, and reports the segmentation results.
9
+
10
+ Usage:
11
+ python3 -m nkululeko.segment [--config CONFIG_FILE]
12
+
13
+ Example:
14
+ nkululeko.segment --config tests/exp_androids_segment.ini
15
+
16
+ References:
17
+ [1] https://github.com/snakers4/silero-vad
18
+
19
+ """
3
20
 
4
21
  import argparse
5
22
  import configparser
@@ -7,9 +24,9 @@ import os
7
24
 
8
25
  import pandas as pd
9
26
 
10
- import nkululeko.glob_conf as glob_conf
11
27
  from nkululeko.constants import VERSION
12
28
  from nkululeko.experiment import Experiment
29
+ import nkululeko.glob_conf as glob_conf
13
30
  from nkululeko.reporting.report_item import ReportItem
14
31
  from nkululeko.utils.util import Util
15
32
 
@@ -78,6 +95,7 @@ def main():
78
95
 
79
96
  if "duration" not in df.columns:
80
97
  df["duration"] = df.index.to_series().map(lambda x: calc_dur(x))
98
+ df_seg["duration"] = df_seg.index.to_series().map(lambda x: calc_dur(x))
81
99
  num_before = df.shape[0]
82
100
  num_after = df_seg.shape[0]
83
101
  # plot distributions
@@ -115,36 +133,5 @@ def main():
115
133
  print("DONE")
116
134
 
117
135
 
118
- def get_segmentation(file):
119
- # print(f'segmenting {file[0]}')
120
- print(".", end="")
121
- wav = read_audio(file[0], sampling_rate=SAMPLING_RATE)
122
- speech_timestamps = get_speech_timestamps(
123
- wav, vad_model, sampling_rate=SAMPLING_RATE
124
- )
125
- files, starts, ends = [], [], []
126
- for entry in speech_timestamps:
127
- start = float(entry["start"] / 1000.0)
128
- end = float(entry["end"] / 1000.0)
129
- files.append(file[0])
130
- starts.append(start)
131
- ends.append(end)
132
- seg_index = segmented_index(files, starts, ends)
133
- return seg_index
134
-
135
-
136
- def segment_dataframe(df):
137
- dfs = []
138
- for file, values in df.iterrows():
139
- index = get_segmentation(file)
140
- dfs.append(
141
- pd.DataFrame(
142
- values.to_dict(),
143
- index,
144
- )
145
- )
146
- return audformat.utils.concat(dfs)
147
-
148
-
149
136
  if __name__ == "__main__":
150
137
  main() # use this if you want to state the config file path on command line
@@ -32,8 +32,30 @@ class Silero_segmenter:
32
32
  self.no_testing = not_testing
33
33
  self.util = Util(has_config=not_testing)
34
34
 
35
- def get_segmentation(self, file):
36
- # print(f'segmenting {file[0]}')
35
+ def get_segmentation_simple(self, file):
36
+ (
37
+ get_speech_timestamps,
38
+ save_audio,
39
+ read_audio,
40
+ VADIterator,
41
+ collect_chunks,
42
+ ) = vad_utils
43
+ SAMPLING_RATE = 16000
44
+ wav = read_audio(file[0], sampling_rate=SAMPLING_RATE)
45
+ speech_timestamps = get_speech_timestamps(
46
+ wav, vad_model, sampling_rate=SAMPLING_RATE
47
+ )
48
+ files, starts, ends = [], [], []
49
+ for entry in speech_timestamps:
50
+ start = float(entry["start"] / SAMPLING_RATE)
51
+ end = float(entry["end"] / SAMPLING_RATE)
52
+ files.append(file[0])
53
+ starts.append(start)
54
+ ends.append(end)
55
+ seg_index = segmented_index(files, starts, ends)
56
+ return seg_index
57
+
58
+ def get_segmentation(self, file, min_length, max_length):
37
59
  (
38
60
  get_speech_timestamps,
39
61
  save_audio,
@@ -42,12 +64,6 @@ class Silero_segmenter:
42
64
  collect_chunks,
43
65
  ) = vad_utils
44
66
  SAMPLING_RATE = 16000
45
- if self.no_testing:
46
- min_length = float(self.util.config_val("SEGMENT", "min_length", 2))
47
- max_length = float(self.util.config_val("SEGMENT", "max_length", 10))
48
- else:
49
- min_length = 2
50
- max_length = 10
51
67
  wav = read_audio(file[0], sampling_rate=SAMPLING_RATE)
52
68
  speech_timestamps = get_speech_timestamps(
53
69
  wav, vad_model, sampling_rate=SAMPLING_RATE
@@ -76,8 +92,18 @@ class Silero_segmenter:
76
92
 
77
93
  def segment_dataframe(self, df):
78
94
  dfs = []
95
+ max_length = eval(self.util.config_val("SEGMENT", "max_length", "False"))
96
+ if max_length:
97
+ if self.no_testing:
98
+ min_length = float(self.util.config_val("SEGMENT", "min_length", 2))
99
+ else:
100
+ min_length = 2
101
+ self.util.debug(f"segmenting with max length: {max_length+min_length}")
79
102
  for file, values in tqdm(df.iterrows()):
80
- index = self.get_segmentation(file)
103
+ if max_length:
104
+ index = self.get_segmentation(file, min_length, max_length)
105
+ else:
106
+ index = self.get_segmentation_simple(file)
81
107
  dfs.append(
82
108
  pd.DataFrame(
83
109
  values.to_dict(),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nkululeko
3
- Version: 0.90.4
3
+ Version: 0.91.1
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
@@ -10,7 +10,7 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Development Status :: 3 - Alpha
12
12
  Classifier: Topic :: Scientific/Engineering
13
- Requires-Python: >=3.6
13
+ Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: audeer
@@ -23,7 +23,6 @@ Requires-Dist: audonnx
23
23
  Requires-Dist: confidence-intervals
24
24
  Requires-Dist: datasets
25
25
  Requires-Dist: imageio
26
- Requires-Dist: laion-clap
27
26
  Requires-Dist: matplotlib
28
27
  Requires-Dist: numpy
29
28
  Requires-Dist: opensmile
@@ -356,6 +355,14 @@ F. Burkhardt, Johannes Wagner, Hagen Wierstorf, Florian Eyben and Björn Schulle
356
355
  Changelog
357
356
  =========
358
357
 
358
+ --------------
359
+ * minor refactoring in ensemble module
360
+
361
+ Version 0.91.0
362
+ --------------
363
+ * fixed duration display in segmentation
364
+ * added possibility to use original segmentations (without max. duration)
365
+
359
366
  Version 0.90.4
360
367
  --------------
361
368
  * added plot format for multidb
@@ -2,12 +2,12 @@ nkululeko/__init__.py,sha256=62f8HiEzJ8rG2QlTFJXUCMpvuH3fKI33DoJSj33mscc,63
2
2
  nkululeko/aug_train.py,sha256=FoMbBrfyOZd4QAw7oIHl3X6-UpsqAKWVDIolCA7qOWs,3196
3
3
  nkululeko/augment.py,sha256=3RzaxB3gRxovgJVjHXi0glprW01J7RaHhUkqotW2T3U,2955
4
4
  nkululeko/cacheddataset.py,sha256=XFpWZmbJRg0pvhnIgYf0TkclxllD-Fctu-Ol0PF_00c,969
5
- nkululeko/constants.py,sha256=jZ8xPXzwC4olxRWBxh7QNAfDpWxH99Bim1eoRIcVwtY,39
5
+ nkululeko/constants.py,sha256=iYlIApfoK9ylYhWWe4mizk150FEYR7mV6iaGEZJ9NNU,39
6
6
  nkululeko/demo-ft.py,sha256=iD9Pzp9QjyAv31q1cDZ75vPez7Ve8A4Cfukv5yfZdrQ,770
7
7
  nkululeko/demo.py,sha256=4Yzhg6pCPBYPGJrP7JX2TysVosl_R1llpVDKc2P_gUA,4955
8
8
  nkululeko/demo_feats.py,sha256=BvZjeNFTlERIRlq34OHM4Z96jdDQAhB01BGQAUcX9dM,2026
9
9
  nkululeko/demo_predictor.py,sha256=lDF-xOxRdEAclOmbepAYg-BQXQdGkHfq2n74PTIoop8,4872
10
- nkululeko/ensemble.py,sha256=QONr-1VwMr2D0I7wjWxwGjtYzWf4v9DoI3C-fFnar7E,12862
10
+ nkululeko/ensemble.py,sha256=71V-rre61H3J4sh7lu-OTo4I2_g7mm_rQxwW1ARDHgY,12782
11
11
  nkululeko/experiment.py,sha256=octx5S4Y8-gAD0dXCRb6DFZwsXTYgzk06RBA3LX2SN0,31388
12
12
  nkululeko/explore.py,sha256=Y5lPPychnI-7fyP8zvwVb9P09fvprbUPOofOppuABYQ,3658
13
13
  nkululeko/export.py,sha256=U-V4acxtuL6qKt6oAsVcM5TTeWogYUJ3GU-lA6rq6d4,4336
@@ -25,7 +25,7 @@ nkululeko/predict.py,sha256=b35YOqovGb5PLDz0nDuhJGykEAPq2Y45R9lzxJZMuMU,2083
25
25
  nkululeko/resample.py,sha256=akSAjJ3qn-O5NAyLJHVHdsK7MUZPGaZUvM2TwMSmj2M,5194
26
26
  nkululeko/runmanager.py,sha256=AswmORVUkCIH0gTx6zEyufvFATQBS8C5TXo2erSNdVg,7611
27
27
  nkululeko/scaler.py,sha256=7VOZ4sREMoQtahfETt9RyuR29Fb7PCwxlYVjBbdCVFc,4101
28
- nkululeko/segment.py,sha256=lSeI1i96HZTloSqdH75FhD7VyDQ16Do99-5mhI30To8,4571
28
+ nkululeko/segment.py,sha256=S8TZt728CADXBEVw7GTWQq42vdXkRxmL738C8V_iy3k,4324
29
29
  nkululeko/syllable_nuclei.py,sha256=5w_naKxNxz66a_qLkraemi2fggM-gWesiiBPS47iFcE,9931
30
30
  nkululeko/test.py,sha256=1w624vo5KTzmFC8BUStGlLDmIEAFuJUz7J0W-gp7AxI,1677
31
31
  nkululeko/test_predictor.py,sha256=DEHE_D3A6m6KJTrpDKceA1n655t_UZV3WQd57K4a3Ho,2863
@@ -105,14 +105,14 @@ nkululeko/reporting/reporter.py,sha256=4OlYZAParkfJKO_aAyxqVpLc21zxZ-jDhtJKIMeUs
105
105
  nkululeko/reporting/result.py,sha256=G63a2tHCwHhM6NBJgYzsWKWJm4Yu3r4hsCHA2Km7eHU,1073
106
106
  nkululeko/segmenting/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
107
  nkululeko/segmenting/seg_inaspeechsegmenter.py,sha256=b3t0zdpJYofKWMyKRMtMMX91xeR-k8d5pbnNaQHcsOE,1902
108
- nkululeko/segmenting/seg_silero.py,sha256=CnhjKGTW5OXf-bmw4YsSJeN2yUwkY5m3xnulM_PYCW0,3256
108
+ nkululeko/segmenting/seg_silero.py,sha256=ulodnvtRq5MLHDxy_RmAK4tJg6h1d-mPq-uCPFkGVKg,4258
109
109
  nkululeko/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
110
  nkululeko/utils/files.py,sha256=UiGAtZRWYjHSvlmPaTMtzyNNGE6qaLaxQkybctS7iRM,4021
111
111
  nkululeko/utils/stats.py,sha256=vCRzhCR0Gx5SiJyAGbj1TIto8ocGz58CM5Pr3LltagA,2948
112
112
  nkululeko/utils/util.py,sha256=XFZdhCc_LM4EmoZ5tKKaBCQLXclcNmvHwhfT_CXB98c,16723
113
- nkululeko-0.90.4.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
114
- nkululeko-0.90.4.dist-info/METADATA,sha256=t64nFqxKkX3gaQ8J0PjpiRxc03LBS0yGO3i5wTR1bxc,41242
115
- nkululeko-0.90.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
116
- nkululeko-0.90.4.dist-info/entry_points.txt,sha256=KpQhz4HKBvYLrNooqLIc83hub76axRbYUgWzYkH3GnU,397
117
- nkululeko-0.90.4.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
118
- nkululeko-0.90.4.dist-info/RECORD,,
113
+ nkululeko-0.91.1.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
114
+ nkululeko-0.91.1.dist-info/METADATA,sha256=F-icPu_THEFHxMm-uAV5MALbVMLrXcO3ZuoPeo6bPwk,41417
115
+ nkululeko-0.91.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
116
+ nkululeko-0.91.1.dist-info/entry_points.txt,sha256=lNTkFEdh6Kjo5o95ZAWf_0Lq-4ztGoAoMVSDuPtuyS0,442
117
+ nkululeko-0.91.1.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
118
+ nkululeko-0.91.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +1,7 @@
1
1
  [console_scripts]
2
2
  nkululeko.augment = nkululeko.augment:main
3
3
  nkululeko.demo = nkululeko.demo:main
4
+ nkululeko.ensemble = nkululeko.ensemble:main
4
5
  nkululeko.explore = nkululeko.explore:main
5
6
  nkululeko.export = nkululeko.export:main
6
7
  nkululeko.nkululeko = nkululeko.nkululeko:main