nkululeko 0.59.1__py3-none-any.whl → 0.61.0__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.
Files changed (64) hide show
  1. nkululeko/constants.py +1 -1
  2. nkululeko/experiment.py +43 -43
  3. nkululeko/feature_extractor.py +101 -58
  4. nkululeko/modelrunner.py +14 -14
  5. nkululeko/plots.py +11 -0
  6. nkululeko/segment.py +23 -27
  7. nkululeko/test_predictor.py +1 -1
  8. {nkululeko-0.59.1.dist-info → nkululeko-0.61.0.dist-info}/METADATA +13 -1
  9. nkululeko-0.61.0.dist-info/RECORD +31 -0
  10. {nkululeko-0.59.1.dist-info → nkululeko-0.61.0.dist-info}/WHEEL +1 -1
  11. nkululeko/ap_age.py +0 -31
  12. nkululeko/ap_arousal.py +0 -30
  13. nkululeko/ap_dominance.py +0 -29
  14. nkululeko/ap_gender.py +0 -29
  15. nkululeko/ap_mos.py +0 -35
  16. nkululeko/ap_pesq.py +0 -35
  17. nkululeko/ap_sdr.py +0 -36
  18. nkululeko/ap_snr.py +0 -35
  19. nkululeko/ap_stoi.py +0 -34
  20. nkululeko/ap_valence.py +0 -30
  21. nkululeko/augmenter.py +0 -64
  22. nkululeko/dataset.py +0 -415
  23. nkululeko/dataset_csv.py +0 -49
  24. nkululeko/dataset_ravdess.py +0 -19
  25. nkululeko/estimate_snr.py +0 -89
  26. nkululeko/feats_agender.py +0 -63
  27. nkululeko/feats_agender_agender.py +0 -65
  28. nkululeko/feats_analyser.py +0 -87
  29. nkululeko/feats_audmodel.py +0 -63
  30. nkululeko/feats_audmodel_dim.py +0 -63
  31. nkululeko/feats_clap.py +0 -74
  32. nkululeko/feats_import.py +0 -44
  33. nkululeko/feats_mld.py +0 -47
  34. nkululeko/feats_mos.py +0 -92
  35. nkululeko/feats_opensmile.py +0 -84
  36. nkululeko/feats_oxbow.py +0 -87
  37. nkululeko/feats_praat.py +0 -72
  38. nkululeko/feats_snr.py +0 -63
  39. nkululeko/feats_squim.py +0 -99
  40. nkululeko/feats_trill.py +0 -74
  41. nkululeko/feats_wav2vec2.py +0 -94
  42. nkululeko/featureset.py +0 -41
  43. nkululeko/feinberg_praat.py +0 -430
  44. nkululeko/loss_ccc.py +0 -28
  45. nkululeko/loss_softf1loss.py +0 -40
  46. nkululeko/model.py +0 -256
  47. nkululeko/model_bayes.py +0 -14
  48. nkululeko/model_cnn.py +0 -118
  49. nkululeko/model_gmm.py +0 -16
  50. nkululeko/model_knn.py +0 -16
  51. nkululeko/model_knn_reg.py +0 -16
  52. nkululeko/model_mlp.py +0 -175
  53. nkululeko/model_mlp_regression.py +0 -197
  54. nkululeko/model_svm.py +0 -18
  55. nkululeko/model_svr.py +0 -18
  56. nkululeko/model_tree.py +0 -14
  57. nkululeko/model_tree_reg.py +0 -14
  58. nkululeko/model_xgb.py +0 -12
  59. nkululeko/model_xgr.py +0 -12
  60. nkululeko/randomsplicer.py +0 -76
  61. nkululeko/randomsplicing.py +0 -74
  62. nkululeko-0.59.1.dist-info/RECORD +0 -82
  63. {nkululeko-0.59.1.dist-info → nkululeko-0.61.0.dist-info}/LICENSE +0 -0
  64. {nkululeko-0.59.1.dist-info → nkululeko-0.61.0.dist-info}/top_level.txt +0 -0
nkululeko/ap_arousal.py DELETED
@@ -1,30 +0,0 @@
1
- """"
2
- A predictor for emotional arousal.
3
- Currently based on audEERING's emotional dimension model.
4
- """
5
- from nkululeko.util import Util
6
- from nkululeko.feature_extractor import FeatureExtractor
7
- import ast
8
- import nkululeko.glob_conf as glob_conf
9
- class ArousalPredictor:
10
- """
11
- ArousalPredictor
12
- predicting arousal with the audEERING emotional dimension model
13
-
14
- """
15
- def __init__(self, df):
16
- self.df = df
17
- self.util = Util('arousalPredictor')
18
-
19
-
20
- def predict(self, split_selection):
21
- self.util.debug(f'predicting arousal for {split_selection} samples')
22
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
23
- self.feature_extractor = FeatureExtractor(self.df, ['auddim'], feats_name, split_selection)
24
- pred_df = self.feature_extractor.extract()
25
- pred_vals = pred_df.arousal * 1000
26
- return_df = self.df.copy()
27
- return_df['arousal_pred'] = pred_vals.astype('int')/1000
28
-
29
- return return_df
30
-
nkululeko/ap_dominance.py DELETED
@@ -1,29 +0,0 @@
1
- """
2
- A predictor for emotional dominance.
3
- Currently based on audEERING's emotional dimension model.
4
- """
5
-
6
- from nkululeko.util import Util
7
- from nkululeko.feature_extractor import FeatureExtractor
8
- import ast
9
- import nkululeko.glob_conf as glob_conf
10
- class DominancePredictor:
11
- """
12
- DominancePredictor
13
- predicting dominance with the audEERING emotional dimension model
14
- """
15
-
16
- def __init__(self, df):
17
- self.df = df
18
- self.util = Util('dominancePredictor')
19
-
20
- def predict(self, split_selection):
21
- self.util.debug(f'predicting dominance for {split_selection} samples')
22
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
23
- self.feature_extractor = FeatureExtractor(self.df, ['auddim'], feats_name, split_selection)
24
- pred_df = self.feature_extractor.extract()
25
- pred_vals = pred_df.dominance * 1000
26
- return_df = self.df.copy()
27
- return_df['dominance_pred'] = pred_vals.astype('int')/1000
28
-
29
- return return_df
nkululeko/ap_gender.py DELETED
@@ -1,29 +0,0 @@
1
- """"
2
- A predictor for biological sex.
3
- Currently based on audEERING's agender model.
4
- """
5
- from nkululeko.util import Util
6
- from nkululeko.feature_extractor import FeatureExtractor
7
- import ast
8
- import nkululeko.glob_conf as glob_conf
9
- class GenderPredictor:
10
- """
11
- GenderPredictor
12
- predicting gender with the audEERING agender model
13
-
14
- """
15
- def __init__(self, df):
16
- self.df = df
17
- self.util = Util('genderPredictor')
18
-
19
-
20
- def predict(self, split_selection):
21
- self.util.debug(f'predicting gender for {split_selection} samples')
22
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
23
- self.feature_extractor = FeatureExtractor(self.df, ['agender_agender'], feats_name, split_selection)
24
- agender_df = self.feature_extractor.extract()
25
- pred_gender = agender_df.drop('age', axis=1).idxmax(axis=1)
26
- return_df = self.df.copy()
27
- return_df['gender_pred'] = pred_gender
28
- return return_df
29
-
nkululeko/ap_mos.py DELETED
@@ -1,35 +0,0 @@
1
- """"
2
- A predictor for MOS - mean opinion score.
3
- """
4
- from nkululeko.util import Util
5
- import ast
6
- import nkululeko.glob_conf as glob_conf
7
- from nkululeko.feature_extractor import FeatureExtractor
8
- import numpy as np
9
-
10
-
11
- class MOSPredictor:
12
- """
13
- MOSPredictor
14
- predicting MOS
15
-
16
- """
17
- def __init__(self, df):
18
- self.df = df
19
- self.util = Util('mosPredictor')
20
-
21
-
22
- def predict(self, split_selection):
23
- self.util.debug(f'estimating MOS for {split_selection} samples')
24
- return_df = self.df.copy()
25
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
26
- self.feature_extractor = FeatureExtractor(self.df, ['mos'], feats_name, split_selection)
27
- result_df = self.feature_extractor.extract()
28
- # replace missing values by 0
29
- result_df = result_df.fillna(0)
30
- result_df = result_df.replace(np.nan, 0)
31
- result_df.replace([np.inf, -np.inf], 0, inplace=True)
32
- pred_snr = result_df.mos * 100
33
- return_df['mos_pred'] = pred_snr.astype('int')/100
34
- return return_df
35
-
nkululeko/ap_pesq.py DELETED
@@ -1,35 +0,0 @@
1
- """"
2
- A predictor for PESQ - Perceptual Evaluation of Speech Quality.
3
- """
4
- from nkululeko.util import Util
5
- import ast
6
- import nkululeko.glob_conf as glob_conf
7
- from nkululeko.feature_extractor import FeatureExtractor
8
- import numpy as np
9
-
10
-
11
- class PESQPredictor:
12
- """
13
- PESQPredictor
14
- predicting PESQ
15
-
16
- """
17
- def __init__(self, df):
18
- self.df = df
19
- self.util = Util('pesqPredictor')
20
-
21
-
22
- def predict(self, split_selection):
23
- self.util.debug(f'estimating PESQ for {split_selection} samples')
24
- return_df = self.df.copy()
25
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
26
- self.feature_extractor = FeatureExtractor(self.df, ['squim'], feats_name, split_selection)
27
- result_df = self.feature_extractor.extract()
28
- # replace missing values by 0
29
- result_df = result_df.fillna(0)
30
- result_df = result_df.replace(np.nan, 0)
31
- result_df.replace([np.inf, -np.inf], 0, inplace=True)
32
- pred_vals = result_df.pesq * 100
33
- return_df['pesq_pred'] = pred_vals.astype('int')/100
34
- return return_df
35
-
nkululeko/ap_sdr.py DELETED
@@ -1,36 +0,0 @@
1
- """"
2
- A predictor for SDR - Signal to Distortion Ratio.
3
- as estimated by Scale-Invariant Signal-to-Distortion Ratio (SI-SDR)
4
- """
5
- from nkululeko.util import Util
6
- import ast
7
- import nkululeko.glob_conf as glob_conf
8
- from nkululeko.feature_extractor import FeatureExtractor
9
- import numpy as np
10
-
11
-
12
- class SDRPredictor:
13
- """
14
- SDRPredictor
15
- predicting SDR
16
-
17
- """
18
- def __init__(self, df):
19
- self.df = df
20
- self.util = Util('snrPredictor')
21
-
22
-
23
- def predict(self, split_selection):
24
- self.util.debug(f'estimating SDR for {split_selection} samples')
25
- return_df = self.df.copy()
26
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
27
- self.feature_extractor = FeatureExtractor(self.df, ['squim'], feats_name, split_selection)
28
- result_df = self.feature_extractor.extract()
29
- # replace missing values by 0
30
- result_df = result_df.fillna(0)
31
- result_df = result_df.replace(np.nan, 0)
32
- result_df.replace([np.inf, -np.inf], 0, inplace=True)
33
- pred_vals = result_df.sdr * 100
34
- return_df['sdr_pred'] = pred_vals.astype('int')/100
35
- return return_df
36
-
nkululeko/ap_snr.py DELETED
@@ -1,35 +0,0 @@
1
- """"
2
- A predictor for SNR - signal-to-noise ratio.
3
- """
4
- from nkululeko.util import Util
5
- import ast
6
- import nkululeko.glob_conf as glob_conf
7
- from nkululeko.feature_extractor import FeatureExtractor
8
- import numpy as np
9
-
10
-
11
- class SNRPredictor:
12
- """
13
- SNRPredictor
14
- predicting snr
15
-
16
- """
17
- def __init__(self, df):
18
- self.df = df
19
- self.util = Util('snrPredictor')
20
-
21
-
22
- def predict(self, split_selection):
23
- self.util.debug(f'estimating SNR for {split_selection} samples')
24
- return_df = self.df.copy()
25
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
26
- self.feature_extractor = FeatureExtractor(self.df, ['snr'], feats_name, split_selection)
27
- result_df = self.feature_extractor.extract()
28
- # replace missing values by 0
29
- result_df = result_df.fillna(0)
30
- result_df = result_df.replace(np.nan, 0)
31
- result_df.replace([np.inf, -np.inf], 0, inplace=True)
32
- pred_snr = result_df.snr * 100
33
- return_df['snr_pred'] = pred_snr.astype('int')/100
34
- return return_df
35
-
nkululeko/ap_stoi.py DELETED
@@ -1,34 +0,0 @@
1
- """"
2
- A predictor for STOI - Short-Time Objective Intelligibility (STOI)
3
- """
4
- from nkululeko.util import Util
5
- import ast
6
- import nkululeko.glob_conf as glob_conf
7
- from nkululeko.feature_extractor import FeatureExtractor
8
- import numpy as np
9
-
10
-
11
- class STOIPredictor:
12
- """
13
- STOIPredictor
14
- predicting STOI Short-Time Objective Intelligibility (STOI)
15
-
16
- """
17
- def __init__(self, df):
18
- self.df = df
19
- self.util = Util('stoiPredictor')
20
-
21
-
22
- def predict(self, split_selection):
23
- self.util.debug(f'estimating STOI for {split_selection} samples')
24
- return_df = self.df.copy()
25
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
26
- self.feature_extractor = FeatureExtractor(self.df, ['squim'], feats_name, split_selection)
27
- result_df = self.feature_extractor.extract()
28
- # replace missing values by 0
29
- result_df = result_df.fillna(0)
30
- result_df = result_df.replace(np.nan, 0)
31
- result_df.replace([np.inf, -np.inf], 0, inplace=True)
32
- pred_vals = result_df.stoi * 100
33
- return_df['stoi_pred'] = pred_vals.astype('int')/100
34
- return return_df
nkululeko/ap_valence.py DELETED
@@ -1,30 +0,0 @@
1
- """"
2
- A predictor for emotional valence.
3
- Currently based on audEERING's emotional dimension model.
4
- """
5
- from nkululeko.util import Util
6
- from nkululeko.feature_extractor import FeatureExtractor
7
- import ast
8
- import nkululeko.glob_conf as glob_conf
9
- class ValencePredictor:
10
- """
11
- ValencePredictor
12
- predicting valence with the audEERING emotional dimension model
13
-
14
- """
15
- def __init__(self, df):
16
- self.df = df
17
- self.util = Util('valencePredictor')
18
-
19
-
20
- def predict(self, split_selection):
21
- self.util.debug(f'predicting valence for {split_selection} samples')
22
- feats_name = "_".join(ast.literal_eval(glob_conf.config['DATA']['databases']))
23
- self.feature_extractor = FeatureExtractor(self.df, ['auddim'], feats_name, split_selection)
24
- pred_df = self.feature_extractor.extract()
25
- pred_vals = pred_df.valence * 1000
26
- return_df = self.df.copy()
27
- return_df['valence_pred'] = pred_vals.astype('int')/1000
28
-
29
- return return_df
30
-
nkululeko/augmenter.py DELETED
@@ -1,64 +0,0 @@
1
- # augmenter.py
2
- import pandas as pd
3
- from nkululeko.util import Util
4
- from audiomentations import Compose, AddGaussianNoise, AddGaussianSNR, TimeStretch, PitchShift, Shift
5
- import numpy as np
6
- import audiofile
7
- import os
8
- from audformat.utils import map_file_path
9
- import audeer
10
-
11
- class Augmenter:
12
- """
13
- augmenting the train split
14
- """
15
- def __init__(self, df):
16
- self.df = df
17
- self.util = Util('augmenter')
18
- # Define a standard transformation that randomly add augmentations to files
19
- self.audioment = Compose([
20
- AddGaussianNoise(min_amplitude=0.001, max_amplitude=0.015, p=0.5),
21
- AddGaussianSNR(min_snr_db=10, max_snr_db=40, p=0.5),
22
- TimeStretch(min_rate=0.8, max_rate=1.25, p=0.5),
23
- PitchShift(min_semitones=-4, max_semitones=4, p=0.5),
24
- Shift(min_fraction=-0.5, max_fraction=0.5, p=0.5),
25
- ])
26
-
27
- def changepath(self, fp, np):
28
- # parent = os.path.dirname(fp).split('/')[-1]
29
- fullpath = os.path.dirname(fp)
30
- # newpath = f'{np}{parent}'
31
- # audeer.mkdir(newpath)
32
- return fp.replace(fullpath, np)
33
-
34
- def augment(self, sample_selection):
35
- """
36
- augment the training files and return a dataframe with new files index.
37
- """
38
- files = self.df.index.get_level_values(0).values
39
- store = self.util.get_path('store')
40
- filepath = f'{store}augmentations/'
41
- audeer.mkdir(filepath)
42
- self.util.debug(f'augmenting {sample_selection} samples to {filepath}')
43
- newpath = ''
44
- for i, f in enumerate(files):
45
- signal, sr = audiofile.read(f)
46
- filename = os.path.basename(f)
47
- parent = os.path.dirname(f).split('/')[-1]
48
- sig_aug = self.audioment(samples=signal, sample_rate=sr)
49
- newpath = f'{filepath}/{parent}/'
50
- audeer.mkdir(newpath)
51
- audiofile.write(f'{newpath}{filename}', signal=sig_aug,
52
- sampling_rate=sr)
53
- if i%10 == 0:
54
- print(f'augmented {i} of {len(files)}')
55
- df_ret = self.df.copy()
56
- df_ret = df_ret.set_index(map_file_path(df_ret.index,
57
- lambda x: self.changepath(x, newpath)))
58
- aug_db_filename = self.util.config_val('DATA',
59
- 'augment_result', 'augment.csv')
60
- target = self.util.config_val('DATA', 'target', 'emotion')
61
- df_ret[target] = df_ret['class_label']
62
- df_ret = df_ret.drop(columns=['class_label'])
63
- df_ret.to_csv(aug_db_filename)
64
- return df_ret