WIP:common sample
This commit is contained in:
parent
b84ae93511
commit
24b55116f2
@ -26,7 +26,6 @@ export const MergeLabDialog = () => {
|
||||
const key = `${cur.modelType},${cur.samplingRate},${cur.embChannels}`
|
||||
const val = { type: cur.modelType, samplingRate: cur.samplingRate, embChannels: cur.embChannels }
|
||||
const existKeys = Object.keys(prev)
|
||||
console.log("modelFi;e:::::::::::::::::::", cur.modelFile)
|
||||
if (!cur.modelFile || cur.modelFile.length == 0) {
|
||||
return prev
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ class RVC:
|
||||
self.pitchExtractor = PitchExtractorManager.getPitchExtractor(self.settings.f0Detector)
|
||||
self.params = params
|
||||
EmbedderManager.initialize(params)
|
||||
# self.loadSlots()
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
print("[Voice Changer] RVC initialization: ", params)
|
||||
|
||||
@ -147,7 +146,7 @@ class RVC:
|
||||
|
||||
# メタデータを見て、永続化モデルフォルダに移動させる
|
||||
# その際に、メタデータのファイル格納場所も書き換える
|
||||
slotDir = os.path.join(self.params.model_dir, RVC_MODEL_DIRNAME, str(target_slot_idx))
|
||||
slotDir = os.path.join(self.params.model_dir, str(target_slot_idx))
|
||||
os.makedirs(slotDir, exist_ok=True)
|
||||
slotInfo.modelFile = self.moveToModelDir(slotInfo.modelFile, slotDir)
|
||||
if slotInfo.indexFile is not None and len(slotInfo.indexFile) > 0:
|
||||
@ -155,7 +154,6 @@ class RVC:
|
||||
if slotInfo.iconFile is not None and len(slotInfo.iconFile) > 0:
|
||||
slotInfo.iconFile = self.moveToModelDir(slotInfo.iconFile, slotDir)
|
||||
json.dump(asdict(slotInfo), open(os.path.join(slotDir, "params.json"), "w"))
|
||||
# self.loadSlots()
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
|
||||
# 初回のみロード(起動時にスロットにモデルがあった場合はinitialLoadはFalseになっている)
|
||||
@ -169,23 +167,6 @@ class RVC:
|
||||
|
||||
return self.get_info()
|
||||
|
||||
def loadSlots(self):
|
||||
dirname = os.path.join(self.params.model_dir, RVC_MODEL_DIRNAME)
|
||||
if not os.path.exists(dirname):
|
||||
return
|
||||
|
||||
modelSlots: list[ModelSlot] = []
|
||||
for slot_idx in range(len(self.settings.modelSlots)):
|
||||
slotDir = os.path.join(self.params.model_dir, RVC_MODEL_DIRNAME, str(slot_idx))
|
||||
jsonDict = os.path.join(slotDir, "params.json")
|
||||
if os.path.exists(jsonDict):
|
||||
jsonDict = json.load(open(os.path.join(slotDir, "params.json")))
|
||||
slotInfo = ModelSlot(**jsonDict)
|
||||
else:
|
||||
slotInfo = ModelSlot()
|
||||
modelSlots.append(slotInfo)
|
||||
self.settings.modelSlots = modelSlots
|
||||
|
||||
def update_settings(self, key: str, val: int | float | str):
|
||||
if key in self.settings.intData:
|
||||
# 設定前処理
|
||||
@ -255,6 +236,7 @@ class RVC:
|
||||
)
|
||||
|
||||
def get_info(self):
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
data = asdict(self.settings)
|
||||
if self.pipeline is not None:
|
||||
pipelineInfo = self.pipeline.getPipelineInfo()
|
||||
@ -440,7 +422,6 @@ class RVC:
|
||||
params["defaultProtect"] = self.settings.protect
|
||||
|
||||
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
||||
# self.loadSlots()
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
|
||||
def update_model_info(self, newData: str):
|
||||
@ -453,7 +434,6 @@ class RVC:
|
||||
params = json.load(open(os.path.join(slotDir, "params.json"), "r", encoding="utf-8"))
|
||||
params[newDataDict["key"]] = newDataDict["val"]
|
||||
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
||||
# self.loadSlots()
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
|
||||
def upload_model_assets(self, params: str):
|
||||
@ -477,5 +457,4 @@ class RVC:
|
||||
except Exception as e:
|
||||
print("Exception::::", e)
|
||||
|
||||
# self.loadSlots()
|
||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
from utils.downloader.SampleDownloader import downloadSample
|
||||
from voice_changer.Local.ServerDevice import ServerDevice, ServerDeviceCallbacks
|
||||
from voice_changer.VoiceChanger import VoiceChanger
|
||||
from const import ModelType
|
||||
@ -48,6 +49,7 @@ class VoiceChangerManager(ServerDeviceCallbacks):
|
||||
# VoiceChangerManager
|
||||
############################
|
||||
def __init__(self, params: VoiceChangerParams):
|
||||
self.params = params
|
||||
self.voiceChanger: VoiceChanger = None
|
||||
self.settings: VoiceChangerManagerSettings = VoiceChangerManagerSettings(dummy=0)
|
||||
# スタティックな情報を収集
|
||||
@ -76,6 +78,13 @@ class VoiceChangerManager(ServerDeviceCallbacks):
|
||||
return cls._instance
|
||||
|
||||
def loadModel(self, props: LoadModelParams):
|
||||
paramDict = props.params
|
||||
if "sampleId" in paramDict and len(paramDict["sampleId"]) > 0:
|
||||
downloadSample(self.params.sample_mode, paramDict["sampleId"], self.params.model_dir, props.slot, {"useIndex": paramDict["rvcIndexDownload"]})
|
||||
info = {"status": "OK"}
|
||||
return info
|
||||
else:
|
||||
print("[Voice Canger]: upload models........")
|
||||
info = self.voiceChanger.loadModel(props)
|
||||
if hasattr(info, "status") and info["status"] == "NG":
|
||||
return info
|
||||
|
Loading…
x
Reference in New Issue
Block a user