lazy wrap around the voicefixer block because sometimes it just an heros itself despite having a specific block to load it beforehand

This commit is contained in:
mrq 2023-03-08 04:12:22 +00:00
parent 83b5125854
commit f1788a5639

View File

@ -410,29 +410,33 @@ def generate(
progress(0, "Loading voicefix...") progress(0, "Loading voicefix...")
load_voicefixer() load_voicefixer()
fixed_cache = {} try:
for name in progress.tqdm(audio_cache, desc="Running voicefix..."): fixed_cache = {}
del audio_cache[name]['audio'] for name in progress.tqdm(audio_cache, desc="Running voicefix..."):
if 'output' not in audio_cache[name] or not audio_cache[name]['output']: del audio_cache[name]['audio']
continue if 'output' not in audio_cache[name] or not audio_cache[name]['output']:
continue
path = f'{outdir}/{voice}_{name}.wav' path = f'{outdir}/{voice}_{name}.wav'
fixed = f'{outdir}/{voice}_{name}_fixed.wav' fixed = f'{outdir}/{voice}_{name}_fixed.wav'
voicefixer.restore( voicefixer.restore(
input=path, input=path,
output=fixed, output=fixed,
cuda=get_device_name() == "cuda" and args.voice_fixer_use_cuda, cuda=get_device_name() == "cuda" and args.voice_fixer_use_cuda,
#mode=mode, #mode=mode,
) )
fixed_cache[f'{name}_fixed'] = {
'settings': audio_cache[name]['settings'],
'output': True
}
audio_cache[name]['output'] = False
fixed_cache[f'{name}_fixed'] = { for name in fixed_cache:
'settings': audio_cache[name]['settings'], audio_cache[name] = fixed_cache[name]
'output': True except Exception as e:
} print(e)
audio_cache[name]['output'] = False print("\nFailed to run Voicefixer")
for name in fixed_cache:
audio_cache[name] = fixed_cache[name]
for name in audio_cache: for name in audio_cache:
if 'output' not in audio_cache[name] or not audio_cache[name]['output']: if 'output' not in audio_cache[name] or not audio_cache[name]['output']: