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 key = `${cur.modelType},${cur.samplingRate},${cur.embChannels}`
|
||||||
const val = { type: cur.modelType, samplingRate: cur.samplingRate, embChannels: cur.embChannels }
|
const val = { type: cur.modelType, samplingRate: cur.samplingRate, embChannels: cur.embChannels }
|
||||||
const existKeys = Object.keys(prev)
|
const existKeys = Object.keys(prev)
|
||||||
console.log("modelFi;e:::::::::::::::::::", cur.modelFile)
|
|
||||||
if (!cur.modelFile || cur.modelFile.length == 0) {
|
if (!cur.modelFile || cur.modelFile.length == 0) {
|
||||||
return prev
|
return prev
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ class RVC:
|
|||||||
self.pitchExtractor = PitchExtractorManager.getPitchExtractor(self.settings.f0Detector)
|
self.pitchExtractor = PitchExtractorManager.getPitchExtractor(self.settings.f0Detector)
|
||||||
self.params = params
|
self.params = params
|
||||||
EmbedderManager.initialize(params)
|
EmbedderManager.initialize(params)
|
||||||
# self.loadSlots()
|
|
||||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
print("[Voice Changer] RVC initialization: ", params)
|
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)
|
os.makedirs(slotDir, exist_ok=True)
|
||||||
slotInfo.modelFile = self.moveToModelDir(slotInfo.modelFile, slotDir)
|
slotInfo.modelFile = self.moveToModelDir(slotInfo.modelFile, slotDir)
|
||||||
if slotInfo.indexFile is not None and len(slotInfo.indexFile) > 0:
|
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:
|
if slotInfo.iconFile is not None and len(slotInfo.iconFile) > 0:
|
||||||
slotInfo.iconFile = self.moveToModelDir(slotInfo.iconFile, slotDir)
|
slotInfo.iconFile = self.moveToModelDir(slotInfo.iconFile, slotDir)
|
||||||
json.dump(asdict(slotInfo), open(os.path.join(slotDir, "params.json"), "w"))
|
json.dump(asdict(slotInfo), open(os.path.join(slotDir, "params.json"), "w"))
|
||||||
# self.loadSlots()
|
|
||||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
|
|
||||||
# 初回のみロード(起動時にスロットにモデルがあった場合はinitialLoadはFalseになっている)
|
# 初回のみロード(起動時にスロットにモデルがあった場合はinitialLoadはFalseになっている)
|
||||||
@ -169,23 +167,6 @@ class RVC:
|
|||||||
|
|
||||||
return self.get_info()
|
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):
|
def update_settings(self, key: str, val: int | float | str):
|
||||||
if key in self.settings.intData:
|
if key in self.settings.intData:
|
||||||
# 設定前処理
|
# 設定前処理
|
||||||
@ -255,6 +236,7 @@ class RVC:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
data = asdict(self.settings)
|
data = asdict(self.settings)
|
||||||
if self.pipeline is not None:
|
if self.pipeline is not None:
|
||||||
pipelineInfo = self.pipeline.getPipelineInfo()
|
pipelineInfo = self.pipeline.getPipelineInfo()
|
||||||
@ -440,7 +422,6 @@ class RVC:
|
|||||||
params["defaultProtect"] = self.settings.protect
|
params["defaultProtect"] = self.settings.protect
|
||||||
|
|
||||||
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
||||||
# self.loadSlots()
|
|
||||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
|
|
||||||
def update_model_info(self, newData: str):
|
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 = json.load(open(os.path.join(slotDir, "params.json"), "r", encoding="utf-8"))
|
||||||
params[newDataDict["key"]] = newDataDict["val"]
|
params[newDataDict["key"]] = newDataDict["val"]
|
||||||
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
json.dump(params, open(os.path.join(slotDir, "params.json"), "w"))
|
||||||
# self.loadSlots()
|
|
||||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
|
|
||||||
def upload_model_assets(self, params: str):
|
def upload_model_assets(self, params: str):
|
||||||
@ -477,5 +457,4 @@ class RVC:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception::::", e)
|
print("Exception::::", e)
|
||||||
|
|
||||||
# self.loadSlots()
|
|
||||||
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
self.settings.modelSlots = loadAllSlotInfo(self.params.model_dir)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
from utils.downloader.SampleDownloader import downloadSample
|
||||||
from voice_changer.Local.ServerDevice import ServerDevice, ServerDeviceCallbacks
|
from voice_changer.Local.ServerDevice import ServerDevice, ServerDeviceCallbacks
|
||||||
from voice_changer.VoiceChanger import VoiceChanger
|
from voice_changer.VoiceChanger import VoiceChanger
|
||||||
from const import ModelType
|
from const import ModelType
|
||||||
@ -48,6 +49,7 @@ class VoiceChangerManager(ServerDeviceCallbacks):
|
|||||||
# VoiceChangerManager
|
# VoiceChangerManager
|
||||||
############################
|
############################
|
||||||
def __init__(self, params: VoiceChangerParams):
|
def __init__(self, params: VoiceChangerParams):
|
||||||
|
self.params = params
|
||||||
self.voiceChanger: VoiceChanger = None
|
self.voiceChanger: VoiceChanger = None
|
||||||
self.settings: VoiceChangerManagerSettings = VoiceChangerManagerSettings(dummy=0)
|
self.settings: VoiceChangerManagerSettings = VoiceChangerManagerSettings(dummy=0)
|
||||||
# スタティックな情報を収集
|
# スタティックな情報を収集
|
||||||
@ -76,12 +78,19 @@ class VoiceChangerManager(ServerDeviceCallbacks):
|
|||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
def loadModel(self, props: LoadModelParams):
|
def loadModel(self, props: LoadModelParams):
|
||||||
info = self.voiceChanger.loadModel(props)
|
paramDict = props.params
|
||||||
if hasattr(info, "status") and info["status"] == "NG":
|
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
|
return info
|
||||||
else:
|
else:
|
||||||
info["status"] = "OK"
|
print("[Voice Canger]: upload models........")
|
||||||
return info
|
info = self.voiceChanger.loadModel(props)
|
||||||
|
if hasattr(info, "status") and info["status"] == "NG":
|
||||||
|
return info
|
||||||
|
else:
|
||||||
|
info["status"] = "OK"
|
||||||
|
return info
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
data = asdict(self.settings)
|
data = asdict(self.settings)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user