FrederikRautenberg commited on
Commit
3e757c4
·
1 Parent(s): 4732065

fix bug creapy config

Browse files
pvq_manipulation/helper/creapy_config.yaml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # USER:
2
+ # audio_directory: null
3
+ # textgrid_directory: null
4
+ # csv_directory: null
5
+ # audio_start: 0
6
+ # audio_end: -1
7
+ # audio_suffix: .wav
8
+ # textgrid_suffix: .TextGrid
9
+ # gender_model: all
10
+ # tier_name: creapy
11
+ # block_size: 0.040 # seconds
12
+ # hop_size: 0.010 # in seconds
13
+ # creak_threshold: 0.75
14
+ # zcr_threshold: 0.08
15
+ # ste_threshold: 0.00001
16
+
17
+ DEFAULT:
18
+ sample_dir: audio/samples
19
+ audio_suffix: .wav # file name extension of audio file(s)
20
+ audio_re: (?P<speakers>[a-zA-Z\d]+)_(?P<single_speaker>\d{3}[a-zA-Z])_.+\.wav # [optional] define regex to match your files
21
+ re_speaker_group: single_speaker # ??
22
+
23
+ FEATURE_EXTRACTION: # choose which features should be extracted
24
+ cpp: false
25
+ hnr: true
26
+ jitter: true
27
+ h1h2: true
28
+ shimmer: true
29
+ f0mean: true
30
+ zcr: true
31
+ ste: true
32
+ VALUES: # set parameters/thresholds for the features
33
+ HNR: 1
34
+ JITTER: 1
35
+ H1H2: 1
36
+ SHIMMER: 1
37
+ F0MEAN: # fundamental frequency
38
+ fmin: 60 # pitch range
39
+ fmax: 500 # pitch range
40
+ ZCR:
41
+ window: hamming
42
+ STE:
43
+ window: hamming
44
+
45
+ CLASSIFICATION: # set parameters for the (random forest) classification
46
+ impute_strategy: median # mean, most_frequent, null
47
+ random_state: 42 # int, null
48
+ test_size: 0.33 # float
49
+
50
+ MODEL:
51
+ PREPROCESSING:
52
+ impute_strategy: median # mean, most_frequent, null
53
+ impute_at_fit: true
54
+ test_size: 0.33 # int, Pfloat
55
+ block_size: 0.040 # in seconds
56
+ hop_size: 0.010 # in seconds
57
+ random_state: 42
58
+ UNVOICED_EXCLUSION:
59
+ zcr: true
60
+ ste: true
61
+ VALUES:
62
+ ZCR:
63
+ threshold: 0.10
64
+ replace_value: 0.0
65
+ operator: ">="
66
+ normalize: true
67
+ STE:
68
+ threshold: 0.00001
69
+ replace_value: 0.0
70
+ operator: "<="
71
+ normalize: false
72
+
73
+ POSTPROCESSING:
74
+ MAVG:
75
+ mavg: false
76
+ VALUES:
77
+ length: 3
78
+ mode: same
79
+ INTERVALS:
80
+ creak_threshold: 0.75
81
+ min_creak_length: 0.03
82
+ max_gap: 0.015
83
+
84
+ CLASSIFIER:
85
+ clf: rfc # rfc, mlp
86
+ VALUES:
87
+ RFC:
88
+ kwargs:
89
+ n_estimators: 99
90
+ random_state: 42 # int, null
91
+ MLP:
92
+ kwargs:
93
+ solver: lbfgs
94
+ hidden_layer_sizes: [5, 5, 5, 2]
95
+ random_state: 42
96
+ max_iter: 500
97
+ predict_proba: true # true, false
98
+ target_name: "c"
99
+ FEATURES:
100
+ for_classification: ['hnr', 'jitter', 'h1h2', 'shimmer', 'f0mean']
101
+ model_location: model/training_models/model
102
+ save_pickle: false
103
+ target_label: class
104
+
105
+
106
+ PRAAT:
107
+ creak_tier_name: creapy
108
+ interval_text: c
109
+ creak_re: (?P<speaker>[a-zA-Z\d]+)-creak
110
+ creak_fstr: '{}-creak'
pvq_manipulation/helper/creapy_wrapper.py CHANGED
@@ -7,12 +7,28 @@ import pandas as pd
7
  from scipy.signal.windows import hann
8
  from pathlib import Path
9
  from sklearn.impute import SimpleImputer
10
-
 
11
  import creapy
12
  from creapy.feature_extraction.feature_extraction import _cpp, _h1_h2, _jitter, _shimmer, _f0mean, _zcr, _ste
13
  from sklearn.ensemble import RandomForestClassifier
14
  from sklearn.neural_network import MLPClassifier
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  class Model:
18
  """The Model for creaky voice classification."""
@@ -129,6 +145,7 @@ def blockwise_feature_calculation(data: np.ndarray, sr, feature):
129
 
130
 
131
  def process_file(data, sample_rate: int = 16_000):
 
132
  _config = creapy.config.get_config()
133
  user_cfg = _config['USER']
134
  model_cfg = _config['MODEL']
 
7
  from scipy.signal.windows import hann
8
  from pathlib import Path
9
  from sklearn.impute import SimpleImputer
10
+ import ruamel.yaml
11
+ from os.path import isfile
12
  import creapy
13
  from creapy.feature_extraction.feature_extraction import _cpp, _h1_h2, _jitter, _shimmer, _f0mean, _zcr, _ste
14
  from sklearn.ensemble import RandomForestClassifier
15
  from sklearn.neural_network import MLPClassifier
16
 
17
+ _CONFIG_DIR = "./creapy_config.yaml"
18
+
19
+
20
+ def get_config() -> dict:
21
+ """
22
+ returns the configuration file as a dictionary
23
+
24
+ Returns:
25
+ dict: the configuration
26
+ """
27
+
28
+ with open(_CONFIG_DIR) as config_file:
29
+ config: dict = ruamel.yaml.safe_load(config_file.read())
30
+ return config
31
+
32
 
33
  class Model:
34
  """The Model for creaky voice classification."""
 
145
 
146
 
147
  def process_file(data, sample_rate: int = 16_000):
148
+ import ipdb; ipdb.set_trace()
149
  _config = creapy.config.get_config()
150
  user_cfg = _config['USER']
151
  model_cfg = _config['MODEL']