bugfix: tqdm freeze, add server device mode to sovitssvc

This commit is contained in:
wataru 2023-05-12 07:47:57 +09:00
parent 92caf3d5fc
commit 61564c2edf
6 changed files with 75 additions and 110 deletions

View File

@ -67,6 +67,10 @@
"lab": [], "lab": [],
"deviceSetting": [ "deviceSetting": [
{
"name": "audioDeviceMode",
"options": {}
},
{ {
"name": "audioInput", "name": "audioInput",
"options": {} "options": {}

View File

@ -67,6 +67,10 @@
"lab": [], "lab": [],
"deviceSetting": [ "deviceSetting": [
{
"name": "audioDeviceMode",
"options": {}
},
{ {
"name": "audioInput", "name": "audioInput",
"options": {} "options": {}

View File

@ -67,6 +67,10 @@
"lab": [], "lab": [],
"deviceSetting": [ "deviceSetting": [
{
"name": "audioDeviceMode",
"options": {}
},
{ {
"name": "audioInput", "name": "audioInput",
"options": {} "options": {}

View File

@ -67,6 +67,10 @@
"lab": [], "lab": [],
"deviceSetting": [ "deviceSetting": [
{
"name": "audioDeviceMode",
"options": {}
},
{ {
"name": "audioInput", "name": "audioInput",
"options": {} "options": {}

View File

@ -92,93 +92,6 @@ def printMessage(message, level=0):
print(f"\033[47m {message}\033[0m") 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()
printMessage(f"Booting PHASE :{__name__}", level=2)
PORT = args.p
def localServer():
uvicorn.run(
f"{os.path.basename(__file__)[:-3]}:app_socketio",
host="0.0.0.0",
port=int(PORT),
reload=False if hasattr(sys, "_MEIPASS") else True,
log_level="warning",
)
def download(params): def download(params):
url = params["url"] url = params["url"]
saveTo = params["saveTo"] saveTo = params["saveTo"]
@ -210,54 +123,50 @@ def download(params):
print(e) print(e)
if __name__ == "MMVCServerSIO": def downloadWeight():
voiceChangerParams = VoiceChangerParams( # content_vec_500 = (args.content_vec_500,)
content_vec_500=args.content_vec_500, # content_vec_500_onnx = (args.content_vec_500_onnx,)
content_vec_500_onnx=args.content_vec_500_onnx, # content_vec_500_onnx_on = (args.content_vec_500_onnx_on,)
content_vec_500_onnx_on=args.content_vec_500_onnx_on, hubert_base = args.hubert_base
hubert_base=args.hubert_base, hubert_base_jp = args.hubert_base_jp
hubert_base_jp=args.hubert_base_jp, hubert_soft = args.hubert_soft
hubert_soft=args.hubert_soft, nsf_hifigan = args.nsf_hifigan
nsf_hifigan=args.nsf_hifigan,
)
# file exists check (currently only for rvc) # file exists check (currently only for rvc)
downloadParams = [] downloadParams = []
if os.path.exists(voiceChangerParams.hubert_base) is False: if os.path.exists(hubert_base) is False:
downloadParams.append( downloadParams.append(
{ {
"url": "https://huggingface.co/ddPn08/rvc-webui-models/resolve/main/embeddings/hubert_base.pt", "url": "https://huggingface.co/ddPn08/rvc-webui-models/resolve/main/embeddings/hubert_base.pt",
"saveTo": voiceChangerParams.hubert_base, "saveTo": hubert_base,
"position": 0, "position": 0,
} }
) )
if os.path.exists(voiceChangerParams.hubert_base_jp) is False: if os.path.exists(hubert_base_jp) is False:
downloadParams.append( downloadParams.append(
{ {
"url": "https://huggingface.co/rinna/japanese-hubert-base/resolve/main/fairseq/model.pt", "url": "https://huggingface.co/rinna/japanese-hubert-base/resolve/main/fairseq/model.pt",
"saveTo": voiceChangerParams.hubert_base_jp, "saveTo": hubert_base_jp,
"position": 1, "position": 1,
} }
) )
if os.path.exists(voiceChangerParams.hubert_soft) is False: if os.path.exists(hubert_soft) is False:
downloadParams.append( downloadParams.append(
{ {
"url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/embedder/hubert-soft-0d54a1f4.pt", "url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/embedder/hubert-soft-0d54a1f4.pt",
"saveTo": voiceChangerParams.hubert_soft, "saveTo": hubert_soft,
"position": 2, "position": 2,
} }
) )
if os.path.exists(voiceChangerParams.nsf_hifigan) is False: if os.path.exists(nsf_hifigan) is False:
downloadParams.append( downloadParams.append(
{ {
"url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/nsf_hifigan_20221211/model.bin", "url": "https://huggingface.co/wok000/weights/resolve/main/ddsp-svc30/nsf_hifigan_20221211/model.bin",
"saveTo": voiceChangerParams.nsf_hifigan, "saveTo": nsf_hifigan,
"position": 3, "position": 3,
} }
) )
nsf_hifigan_config = os.path.join( nsf_hifigan_config = os.path.join(os.path.dirname(nsf_hifigan), "config.json")
os.path.dirname(voiceChangerParams.nsf_hifigan), "config.json"
)
if os.path.exists(nsf_hifigan_config) is False: if os.path.exists(nsf_hifigan_config) is False:
downloadParams.append( downloadParams.append(
@ -271,6 +180,47 @@ if __name__ == "MMVCServerSIO":
with ThreadPoolExecutor() as pool: with ThreadPoolExecutor() as pool:
pool.map(download, downloadParams) pool.map(download, downloadParams)
if (
os.path.exists(hubert_base) is False
or os.path.exists(hubert_base_jp) is False
or os.path.exists(hubert_soft) is False
or os.path.exists(nsf_hifigan) is False
or os.path.exists(nsf_hifigan_config) is False
):
printMessage("RVC用のモデルファイルのダウンロードに失敗しました。", level=2)
printMessage("failed to download weight for rvc", level=2)
parser = setupArgParser()
args, unknown = parser.parse_known_args()
printMessage(f"Booting PHASE :{__name__}", level=2)
PORT = args.p
def localServer():
uvicorn.run(
f"{os.path.basename(__file__)[:-3]}:app_socketio",
host="0.0.0.0",
port=int(PORT),
reload=False if hasattr(sys, "_MEIPASS") else True,
log_level="warning",
)
if __name__ == "MMVCServerSIO":
mp.freeze_support()
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,
)
if ( if (
os.path.exists(voiceChangerParams.hubert_base) is False os.path.exists(voiceChangerParams.hubert_base) is False
or os.path.exists(voiceChangerParams.hubert_base_jp) is False or os.path.exists(voiceChangerParams.hubert_base_jp) is False

View File

@ -2,7 +2,6 @@ from typing import Dict, Any
from voice_changer.RVC.modelMerger.MergeModelRequest import MergeModelRequest from voice_changer.RVC.modelMerger.MergeModelRequest import MergeModelRequest
from collections import OrderedDict from collections import OrderedDict
import torch import torch
import tqdm
def merge_model(request: MergeModelRequest): def merge_model(request: MergeModelRequest):
@ -50,7 +49,7 @@ def merge_model(request: MergeModelRequest):
merged: Dict[str, Any] = OrderedDict() merged: Dict[str, Any] = OrderedDict()
merged["weight"] = {} merged["weight"] = {}
print("merge start.") print("merge start.")
for key in tqdm.tqdm(weights[0].keys()): for key in weights[0].keys():
merged["weight"][key] = 0 merged["weight"][key] = 0
for i, weight in enumerate(weights): for i, weight in enumerate(weights):
merged["weight"][key] += weight[key] * alphas[i] merged["weight"][key] += weight[key] * alphas[i]