FrederikRautenberg commited on
Commit
056ef7a
·
1 Parent(s): 143d75d

fix bug creapy config

Browse files
pvq_manipulation/helper/creapy_wrapper.py CHANGED
@@ -14,7 +14,9 @@ from creapy.feature_extraction.feature_extraction import _cpp, _h1_h2, _jitter,
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:
@@ -27,6 +29,23 @@ def get_config() -> dict:
27
 
28
  with open(_CONFIG_DIR) as config_file:
29
  config: dict = ruamel.yaml.safe_load(config_file.read())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  return config
31
 
32
 
@@ -145,7 +164,7 @@ def blockwise_feature_calculation(data: np.ndarray, sr, feature):
145
 
146
 
147
  def process_file(data, sample_rate: int = 16_000):
148
- _config = creapy.config.get_config()
149
  user_cfg = _config['USER']
150
  model_cfg = _config['MODEL']
151
 
 
14
  from sklearn.ensemble import RandomForestClassifier
15
  from sklearn.neural_network import MLPClassifier
16
 
17
+ _CONFIG_DIR = "./pvq_manipulation/helper/creapy_config.yaml"
18
+ _USER_CONFIG_DIR = "./pvq_manipulation/helper/user_config.yaml"
19
+ USER_CONFIG_DIR = "./pvq_manipulation/helper/user_config.yaml"
20
 
21
 
22
  def get_config() -> dict:
 
29
 
30
  with open(_CONFIG_DIR) as config_file:
31
  config: dict = ruamel.yaml.safe_load(config_file.read())
32
+
33
+ with open(_USER_CONFIG_DIR) as user_config_file:
34
+ _user_config: dict = ruamel.yaml.safe_load(user_config_file.read())
35
+
36
+ config['USER'] = _user_config
37
+
38
+ if not isfile(USER_CONFIG_DIR):
39
+ return config
40
+
41
+ with open(USER_CONFIG_DIR) as user_config_file:
42
+ user_config: dict = ruamel.yaml.safe_load(user_config_file.read())
43
+
44
+ for key in user_config.keys():
45
+ if key not in config['USER']:
46
+ raise ValueError(f'Invalid key found in user config: {key}')
47
+
48
+ config['USER'].update(user_config)
49
  return config
50
 
51
 
 
164
 
165
 
166
  def process_file(data, sample_rate: int = 16_000):
167
+ _config = get_config()
168
  user_cfg = _config['USER']
169
  model_cfg = _config['MODEL']
170
 
pvq_manipulation/helper/user_config.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ audio_directory: null
2
+ textgrid_directory: null
3
+ csv_directory: null
4
+ audio_start: 0
5
+ audio_end: -1
6
+ audio_suffix: .wav
7
+ filename_extension:
8
+ textgrid_suffix: .TextGrid
9
+ gender_model: all
10
+ tier_name: creapy
11
+ verbose: true
12
+ block_size: 0.040 # seconds
13
+ hop_size: 0.010 # in seconds
14
+ creak_threshold: 0.75
15
+ zcr_threshold: 0.10
16
+ ste_threshold: 0.00001