mirror of
https://github.com/Anjok07/ultimatevocalremovergui.git
synced 2024-12-01 02:27:21 +01:00
Update spec_utils.py
This commit is contained in:
parent
88d48c3d0e
commit
2fd50e11f8
@ -346,7 +346,7 @@ def mirroring(a, spec_m, input_high_end, mp):
|
||||
def ensembling(a, specs):
|
||||
for i in range(1, len(specs)):
|
||||
if i == 1:
|
||||
spec = specs[i-1]
|
||||
spec = specs[0]
|
||||
|
||||
ln = min([spec.shape[2], specs[i].shape[2]])
|
||||
spec = spec[:,:,:ln]
|
||||
@ -368,7 +368,7 @@ if __name__ == "__main__":
|
||||
from model_param_init import ModelParameters
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--algorithm', '-a', type=str, choices=['invert', 'min_mag', 'max_mag', 'deep'], default='min_mag')
|
||||
p.add_argument('--algorithm', '-a', type=str, choices=['invert', 'invert_p', 'min_mag', 'max_mag', 'deep'], default='min_mag')
|
||||
p.add_argument('--model_params', '-m', type=str, default=os.path.join('modelparams', '1band_sr44100_hl512.json'))
|
||||
p.add_argument('--output_name', '-o', type=str, default='output')
|
||||
p.add_argument('--vocals_only', '-v', action='store_true')
|
||||
@ -377,19 +377,20 @@ if __name__ == "__main__":
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
if args.algorithm == 'invert' and len(args.input) != 2:
|
||||
if args.algorithm.startswith('invert') and len(args.input) != 2:
|
||||
raise ValueError('There should be two input files.')
|
||||
|
||||
if args.algorithm != 'invert' and len(args.input) < 2:
|
||||
if not args.algorithm.startswith('invert') and len(args.input) < 2:
|
||||
raise ValueError('There must be at least two input files.')
|
||||
|
||||
wave, specs = {}, {}
|
||||
mp = ModelParameters(args.model_params)
|
||||
|
||||
for i in range(len(args.input)):
|
||||
spec = {}
|
||||
|
||||
for d in range(len(mp.param['band']), 0, -1):
|
||||
bp = mp.param['band'][d]
|
||||
spec = {}
|
||||
|
||||
if d == len(mp.param['band']): # high-end band
|
||||
wave[d], _ = librosa.load(
|
||||
@ -411,7 +412,17 @@ if __name__ == "__main__":
|
||||
v_spec = d_spec - specs[1]
|
||||
sf.write(os.path.join('{}.wav'.format(args.output_name)), cmb_spectrogram_to_wave(v_spec, mp), mp.param['sr'])
|
||||
|
||||
if args.algorithm == 'invert':
|
||||
if args.algorithm.startswith('invert'):
|
||||
ln = min([specs[0].shape[2], specs[1].shape[2]])
|
||||
specs[0] = specs[0][:,:,:ln]
|
||||
specs[1] = specs[1][:,:,:ln]
|
||||
|
||||
if 'invert_p' == args.algorithm:
|
||||
X_mag = np.abs(specs[0])
|
||||
y_mag = np.abs(specs[1])
|
||||
max_mag = np.where(X_mag >= y_mag, X_mag, y_mag)
|
||||
v_spec = specs[1] - max_mag * np.exp(1.j * np.angle(specs[0]))
|
||||
else:
|
||||
specs[1] = reduce_vocal_aggressively(specs[0], specs[1], 0.2)
|
||||
v_spec = specs[0] - specs[1]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user