FrederikRautenberg commited on
Commit
78ead36
·
1 Parent(s): 056ef7a

fix bug creapy config

Browse files
app.py CHANGED
@@ -10,6 +10,7 @@ import librosa
10
  from pvq_manipulation.helper.vad import EnergyVAD
11
  import gradio as gr
12
  from pvq_manipulation.helper.creapy_wrapper import process_file
 
13
 
14
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
15
  pvq_labels = ['Weight', 'Resonance', 'Breathiness', 'Roughness', 'Loudness', 'Strain', 'Pitch']
@@ -34,6 +35,11 @@ normalizing_flow = FFJORD.load_model(storage_dir_normalizing_flow, checkpoint="m
34
  storage_dir_tts = Path("./models/tts_model/")
35
  tts_model = Vits_NT.load_model(storage_dir_tts, "model.pt")
36
 
 
 
 
 
 
37
  # load hubert features model
38
  hubert_model = HubertExtractor(
39
  layer=SID_LARGE_LAYER,
 
10
  from pvq_manipulation.helper.vad import EnergyVAD
11
  import gradio as gr
12
  from pvq_manipulation.helper.creapy_wrapper import process_file
13
+ from creapy.utils import config
14
 
15
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
16
  pvq_labels = ['Weight', 'Resonance', 'Breathiness', 'Roughness', 'Loudness', 'Strain', 'Pitch']
 
35
  storage_dir_tts = Path("./models/tts_model/")
36
  tts_model = Vits_NT.load_model(storage_dir_tts, "model.pt")
37
 
38
+
39
+ config._CONFIG_DIR = "./pvq_manipulation/helper/creapy_config.yaml"
40
+ config._USER_CONFIG_DIR = "./pvq_manipulation/helper/user_config.yaml"
41
+ config.USER_CONFIG_DIR = "./pvq_manipulation/helper/user_config.yaml"
42
+
43
  # load hubert features model
44
  hubert_model = HubertExtractor(
45
  layer=SID_LARGE_LAYER,
pvq_manipulation/helper/creapy_wrapper.py CHANGED
@@ -7,47 +7,11 @@ import pandas as pd
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 = "./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:
23
- """
24
- returns the configuration file as a dictionary
25
-
26
- Returns:
27
- dict: the configuration
28
- """
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
 
52
  class Model:
53
  """The Model for creaky voice classification."""
@@ -164,7 +128,7 @@ def blockwise_feature_calculation(data: np.ndarray, sr, feature):
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
 
 
7
  from scipy.signal.windows import hann
8
  from pathlib import Path
9
  from sklearn.impute import SimpleImputer
 
 
10
  import creapy
11
  from creapy.feature_extraction.feature_extraction import _cpp, _h1_h2, _jitter, _shimmer, _f0mean, _zcr, _ste
12
  from sklearn.ensemble import RandomForestClassifier
13
  from sklearn.neural_network import MLPClassifier
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  class Model:
17
  """The Model for creaky voice classification."""
 
128
 
129
 
130
  def process_file(data, sample_rate: int = 16_000):
131
+ _config = creapy.utils.get_config()
132
  user_cfg = _config['USER']
133
  model_cfg = _config['MODEL']
134