WIP: v.1.5.2.9

This commit is contained in:
wataru 2023-05-09 22:40:21 +09:00
parent 75b575d81d
commit f9dcb5d7a6
2 changed files with 104 additions and 27 deletions

View File

@ -92,6 +92,75 @@ def printMessage(message, level=0):
print(f"\033[47m {message}\033[0m")
def downloadWeight():
voiceChangerParams = VoiceChangerParams(
content_vec_500=args.content_vec_500,
content_vec_500_onnx=args.content_vec_500_onnx,
content_vec_500_onnx_on=args.content_vec_500_onnx_on,
hubert_base=args.hubert_base,
hubert_base_jp=args.hubert_base_jp,
hubert_soft=args.hubert_soft,
nsf_hifigan=args.nsf_hifigan,
)
# file exists check (currently only for rvc)
downloadParams = []
if os.path.exists(voiceChangerParams.hubert_base) is False:
downloadParams.append(
{
"url": "https://huggingface.co/ddPn08/rvc-webui-models/resolve/main/embeddings/hubert_base.pt",
"saveTo": voiceChangerParams.hubert_base,
"position": 0,
}
)
if os.path.exists(voiceChangerParams.hubert_base_jp) is False:
downloadParams.append(
{
"url": "https://huggingface.co/rinna/japanese-hubert-base/resolve/main/fairseq/model.pt",
"saveTo": voiceChangerParams.hubert_base_jp,
"position": 1,
}
)
if os.path.exists(voiceChangerParams.hubert_soft) is False:
downloadParams.append(
{
"url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/embedder/hubert-soft-0d54a1f4.pt",
"saveTo": voiceChangerParams.hubert_soft,
"position": 2,
}
)
if os.path.exists(voiceChangerParams.nsf_hifigan) is False:
downloadParams.append(
{
"url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/nsf_hifigan_20221211/model.bin",
"saveTo": voiceChangerParams.nsf_hifigan,
"position": 3,
}
)
nsf_hifigan_config = os.path.join(
os.path.dirname(voiceChangerParams.nsf_hifigan), "config.json"
)
if os.path.exists(nsf_hifigan_config) is False:
downloadParams.append(
{
"url": "https://huggingface.co/wok000/weights/raw/main/ddsp-svc30/nsf_hifigan_20221211/config.json",
"saveTo": nsf_hifigan_config,
"position": 4,
}
)
with ThreadPoolExecutor() as pool:
pool.map(download, downloadParams)
if (
os.path.exists(voiceChangerParams.hubert_base) is False
or os.path.exists(voiceChangerParams.hubert_base_jp) is False
):
printMessage("RVC用のモデルファイルのダウンロードに失敗しました。", level=2)
printMessage("failed to download weight for rvc", level=2)
parser = setupArgParser()
args, unknown = parser.parse_known_args()
@ -221,6 +290,9 @@ if __name__ == "__main__":
mp.freeze_support()
printMessage("Voice Changerを起動しています。", level=2)
downloadWeight()
PORT = args.p
if os.getenv("EX_PORT"):

View File

@ -209,6 +209,8 @@ class VoiceChanger:
)
def switchModelType(self, modelType: ModelType):
try:
print("switch model type", 1)
if hasattr(self, "voiceChanger") and self.voiceChanger is not None:
# return {"status": "ERROR", "msg": "vc is already selected. currently re-select is not implemented"}
del self.voiceChanger
@ -232,6 +234,7 @@ class VoiceChanger:
self.voiceChanger = SoVitsSvc40(self.params)
elif self.modelType == "DDSP-SVC":
print("switch model type", 2)
from voice_changer.DDSP_SVC.DDSP_SVC import DDSP_SVC
self.voiceChanger = DDSP_SVC(self.params)
@ -243,7 +246,9 @@ class VoiceChanger:
from voice_changer.MMVCv13.MMVCv13 import MMVCv13
self.voiceChanger = MMVCv13()
except Exception as e:
print(e)
print(traceback.format_exc())
return {"status": "OK", "msg": "vc is switched."}
def getModelType(self):