From e7583b1601d1d1034a0b667735fbeea6f000f390 Mon Sep 17 00:00:00 2001 From: SayanoAI <28544690+SayanoAI@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:39:39 -0400 Subject: [PATCH] fixed rvc caching --- custom_nodes/rvc_nodes.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/custom_nodes/rvc_nodes.py b/custom_nodes/rvc_nodes.py index 5773d3c..920acb0 100644 --- a/custom_nodes/rvc_nodes.py +++ b/custom_nodes/rvc_nodes.py @@ -1,11 +1,12 @@ import json import multiprocessing import os -import shutil import numpy as np import torch +from .audio_nodes import to_audio_dict + from . import BASE_DIR from ..lib.train.utils import HParams, DEFAULT_TRAINING_PARAMS @@ -178,7 +179,7 @@ class RVCNode: OUTPUT_NODE = True - RETURN_TYPES = ("VHS_AUDIO",) + RETURN_TYPES = ("VHS_AUDIO", "AUDIO") FUNCTION = "convert" @@ -189,23 +190,20 @@ class RVCNode: input_audio = get_audio(audio) voice_model = model() feature_model = hubert_model() - widgetId = get_hash(feature_model, f0_up_key, audio_to_bytes(*input_audio), *voice_model.items(), *pitch_extraction_params.items()) + widgetId = get_hash(feature_model.__class__.__name__, voice_model.get("model_name"), str(voice_model.get("file_index")), f0_up_key, audio_to_bytes(*input_audio), *pitch_extraction_params.items()) cache_name = os.path.join(BASE_CACHE_DIR,"rvc",f"{widgetId}.{format}") + audio_name = os.path.basename(cache_name) + tempdir = os.path.join(temp_path,"preview") + os.makedirs(tempdir, exist_ok=True) + preview_file = os.path.join(tempdir,audio_name) if use_cache and os.path.isfile(cache_name): output_audio = load_input_audio(cache_name) else: output_audio = vc_single(hubert_model=feature_model,input_audio=input_audio,f0_up_key=f0_up_key,**voice_model,**pitch_extraction_params) - - if use_cache: - print(save_input_audio(cache_name, output_audio)) - if os.path.isfile(cache_name): output_audio = load_input_audio(cache_name) + print(save_input_audio(preview_file, output_audio)) + if use_cache: print(save_input_audio(cache_name, output_audio)) - tempdir = os.path.join(temp_path,"preview") - os.makedirs(tempdir, exist_ok=True) - audio_name = os.path.basename(cache_name) - preview_file = os.path.join(tempdir,audio_name) - if not os.path.isfile(preview_file): shutil.copyfile(cache_name,preview_file) - return {"ui": {"preview": [{"filename": audio_name, "type": "temp", "subfolder": "preview", "widgetId": widgetId}]}, "result": (lambda:audio_to_bytes(*output_audio),)} + return {"ui": {"preview": [{"filename": audio_name, "type": "temp", "subfolder": "preview", "widgetId": widgetId}]}, "result": (lambda:audio_to_bytes(*output_audio), to_audio_dict(*output_audio))} class RVCProcessDatasetNode: