ultimatevocalremovergui/lib_v5/vr_network/model_param_init.py

32 lines
951 B
Python
Raw Normal View History

2022-12-19 04:18:56 +01:00
import json
default_param = {}
2023-09-26 00:18:58 +02:00
default_param['bins'] = -1
default_param['unstable_bins'] = -1 # training only
default_param['stable_bins'] = -1 # training only
2022-12-19 04:18:56 +01:00
default_param['sr'] = 44100
2023-09-26 00:18:58 +02:00
default_param['pre_filter_start'] = -1
default_param['pre_filter_stop'] = -1
2022-12-19 04:18:56 +01:00
default_param['band'] = {}
2023-09-26 00:18:58 +02:00
N_BINS = 'n_bins'
2022-12-19 04:18:56 +01:00
def int_keys(d):
r = {}
for k, v in d:
if k.isdigit():
k = int(k)
r[k] = v
return r
class ModelParameters(object):
def __init__(self, config_path=''):
2023-09-26 00:18:58 +02:00
with open(config_path, 'r') as f:
2022-12-19 04:18:56 +01:00
self.param = json.loads(f.read(), object_pairs_hook=int_keys)
2023-09-26 00:18:58 +02:00
2022-12-19 04:18:56 +01:00
for k in ['mid_side', 'mid_side_b', 'mid_side_b2', 'stereo_w', 'stereo_n', 'reverse']:
if not k in self.param:
2023-09-26 00:18:58 +02:00
self.param[k] = False
if N_BINS in self.param:
self.param['bins'] = self.param[N_BINS]