From f1788a5639f749d05f3f63eba673a7d428cba170 Mon Sep 17 00:00:00 2001 From: mrq Date: Wed, 8 Mar 2023 04:12:22 +0000 Subject: [PATCH] lazy wrap around the voicefixer block because sometimes it just an heros itself despite having a specific block to load it beforehand --- src/utils.py | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/utils.py b/src/utils.py index 22ca7b4..7cfc505 100755 --- a/src/utils.py +++ b/src/utils.py @@ -410,29 +410,33 @@ def generate( progress(0, "Loading voicefix...") load_voicefixer() - fixed_cache = {} - for name in progress.tqdm(audio_cache, desc="Running voicefix..."): - del audio_cache[name]['audio'] - if 'output' not in audio_cache[name] or not audio_cache[name]['output']: - continue + try: + fixed_cache = {} + for name in progress.tqdm(audio_cache, desc="Running voicefix..."): + del audio_cache[name]['audio'] + if 'output' not in audio_cache[name] or not audio_cache[name]['output']: + continue - path = f'{outdir}/{voice}_{name}.wav' - fixed = f'{outdir}/{voice}_{name}_fixed.wav' - voicefixer.restore( - input=path, - output=fixed, - cuda=get_device_name() == "cuda" and args.voice_fixer_use_cuda, - #mode=mode, - ) + path = f'{outdir}/{voice}_{name}.wav' + fixed = f'{outdir}/{voice}_{name}_fixed.wav' + voicefixer.restore( + input=path, + output=fixed, + cuda=get_device_name() == "cuda" and args.voice_fixer_use_cuda, + #mode=mode, + ) + + fixed_cache[f'{name}_fixed'] = { + 'settings': audio_cache[name]['settings'], + 'output': True + } + audio_cache[name]['output'] = False - fixed_cache[f'{name}_fixed'] = { - 'settings': audio_cache[name]['settings'], - 'output': True - } - audio_cache[name]['output'] = False - - for name in fixed_cache: - audio_cache[name] = fixed_cache[name] + for name in fixed_cache: + audio_cache[name] = fixed_cache[name] + except Exception as e: + print(e) + print("\nFailed to run Voicefixer") for name in audio_cache: if 'output' not in audio_cache[name] or not audio_cache[name]['output']: