diff --git a/server/MMVCServerSIO.py b/server/MMVCServerSIO.py index 5a3f1927..bbf3ac99 100755 --- a/server/MMVCServerSIO.py +++ b/server/MMVCServerSIO.py @@ -23,8 +23,8 @@ from restapi.MMVC_Rest import MMVC_Rest from const import ( NATIVE_CLIENT_FILE_MAC, NATIVE_CLIENT_FILE_WIN, - SAMPLES_JSONS, SSL_KEY_DIR, + getRVCSampleJsonAndModelIds, ) import subprocess import multiprocessing as mp @@ -57,6 +57,9 @@ def setupArgParser(): ) parser.add_argument("--model_dir", type=str, help="path to model files") + parser.add_argument( + "--rvc_sample_mode", type=str, default="production", help="rvc_sample_mode" + ) parser.add_argument( "--content_vec_500", type=str, help="path to content_vec_500 model(pytorch)" @@ -205,6 +208,7 @@ if __name__ == "MMVCServerSIO": hubert_base_jp=args.hubert_base_jp, hubert_soft=args.hubert_soft, nsf_hifigan=args.nsf_hifigan, + rvc_sample_mode=args.rvc_sample_mode, ) if ( @@ -233,12 +237,13 @@ if __name__ == "__main__": try: sampleJsons = [] - for url in SAMPLES_JSONS: + sampleJsonUrls, sampleModels = getRVCSampleJsonAndModelIds(args.rvc_sample_mode) + for url in sampleJsonUrls: filename = os.path.basename(url) download_no_tqdm({"url": url, "saveTo": filename, "position": 0}) sampleJsons.append(filename) if checkRvcModelExist(args.model_dir) is False: - downloadInitialSampleModels(sampleJsons, args.model_dir) + downloadInitialSampleModels(sampleJsons, sampleModels, args.model_dir) except Exception as e: print("[Voice Changer] loading sample failed", e) diff --git a/server/const.py b/server/const.py index 22a6c558..63d3bc69 100644 --- a/server/const.py +++ b/server/const.py @@ -100,55 +100,83 @@ class ServerAudioDeviceTypes(Enum): audiooutput = "audiooutput" -SAMPLES_JSONS = [ - # "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0001.json", - # "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0002.json", - "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_t.json", - "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_o.json", - # "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json", - # "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json", -] +class RVCSampleMode(Enum): + production = "production" + testOfficial = "testOfficial" + testDDPNTorch = "testDDPNTorch" + testDDPNONNX = "testDDPNONNX" + testONNXFull = "testONNXFull" -SAMPLE_MODEL_IDS = [ - ("TokinaShigure_o", True), - ("KikotoMahiro_o", False), - ("Amitaro_o", False), - ("Tsukuyomi-chan_o", False), - # オフィシャルモデルテスト - # ("test-official-v1-f0-48k-l9-hubert_t", True), - # ("test-official-v1-nof0-48k-l9-hubert_t", False), - # ("test-official-v2-f0-40k-l12-hubert_t", False), - # ("test-official-v2-nof0-40k-l12-hubert_t", False), - # ("test-official-v1-f0-48k-l9-hubert_o", True), - # ("test-official-v1-nof0-48k-l9-hubert_o", False), - # ("test-official-v2-f0-40k-l12-hubert_o", False), - # ("test-official-v2-nof0-40k-l12-hubert_o", False), - # DDPNモデルテスト(torch) - # ("test-ddpn-v1-f0-48k-l9-hubert_t", False), - # ("test-ddpn-v1-nof0-48k-l9-hubert_t", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_t", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_t", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_jp_t", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_jp_t", False), - # DDPNモデルテスト(onnx) - # ("test-ddpn-v1-f0-48k-l9-hubert_o", False), - # ("test-ddpn-v1-nof0-48k-l9-hubert_o", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_o", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_o", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_jp_o", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_jp_o", False), - # ONNX FULLテスト(onnx) - # ("test-official-v1-f0-48k-l9-hubert_o_full", False), - # ("test-official-v1-nof0-48k-l9-hubert_o_full", False), - # ("test-official-v2-f0-40k-l12-hubert_o_full", False), - # ("test-official-v2-nof0-40k-l12-hubert_o_full", False), - # ("test-ddpn-v1-f0-48k-l9-hubert_o_full", False), - # ("test-ddpn-v1-nof0-48k-l9-hubert_o_full", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_o_full", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_o_full", False), - # ("test-ddpn-v2-f0-40k-l12-hubert_jp_o_full", False), - # ("test-ddpn-v2-nof0-40k-l12-hubert_jp_o_full", False), -] + +def getRVCSampleJsonAndModelIds(mode: RVCSampleMode): + if mode == RVCSampleMode.production.value: + return [ + # "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0001.json", + # "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0002.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_t.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_o.json", + ], [ + ("TokinaShigure_o", True), + ("KikotoMahiro_o", False), + ("Amitaro_o", False), + ("Tsukuyomi-chan_o", False), + ] + elif mode == RVCSampleMode.testOfficial.value: + return [ + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json", + ], [ + ("test-official-v1-f0-48k-l9-hubert_t", True), + ("test-official-v1-nof0-48k-l9-hubert_t", False), + ("test-official-v2-f0-40k-l12-hubert_t", False), + ("test-official-v2-nof0-40k-l12-hubert_t", False), + ("test-official-v1-f0-48k-l9-hubert_o", True), + ("test-official-v1-nof0-48k-l9-hubert_o", False), + ("test-official-v2-f0-40k-l12-hubert_o", False), + ("test-official-v2-nof0-40k-l12-hubert_o", False), + ] + elif mode == RVCSampleMode.testDDPNTorch.value: + return [ + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json", + ], [ + ("test-ddpn-v1-f0-48k-l9-hubert_t", False), + ("test-ddpn-v1-nof0-48k-l9-hubert_t", False), + ("test-ddpn-v2-f0-40k-l12-hubert_t", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_t", False), + ("test-ddpn-v2-f0-40k-l12-hubert_jp_t", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_jp_t", False), + ] + elif mode == RVCSampleMode.testDDPNONNX.value: + return [ + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json", + ], [ + ("test-ddpn-v1-f0-48k-l9-hubert_o", False), + ("test-ddpn-v1-nof0-48k-l9-hubert_o", False), + ("test-ddpn-v2-f0-40k-l12-hubert_o", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_o", False), + ("test-ddpn-v2-f0-40k-l12-hubert_jp_o", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_jp_o", False), + ] + elif mode == RVCSampleMode.testONNXFull.value: + return [ + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json", + "https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json", + ], [ + ("test-official-v1-f0-48k-l9-hubert_o_full", False), + ("test-official-v1-nof0-48k-l9-hubert_o_full", False), + ("test-official-v2-f0-40k-l12-hubert_o_full", False), + ("test-official-v2-nof0-40k-l12-hubert_o_full", False), + ("test-ddpn-v1-f0-48k-l9-hubert_o_full", False), + ("test-ddpn-v1-nof0-48k-l9-hubert_o_full", False), + ("test-ddpn-v2-f0-40k-l12-hubert_o_full", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_o_full", False), + ("test-ddpn-v2-f0-40k-l12-hubert_jp_o_full", False), + ("test-ddpn-v2-nof0-40k-l12-hubert_jp_o_full", False), + ] + else: + return [], [] RVC_MODEL_DIRNAME = "rvc" diff --git a/server/voice_changer/RVC/RVC.py b/server/voice_changer/RVC/RVC.py index 62a67a4d..b954322f 100644 --- a/server/voice_changer/RVC/RVC.py +++ b/server/voice_changer/RVC/RVC.py @@ -41,7 +41,11 @@ from voice_changer.RVC.deviceManager.DeviceManager import DeviceManager from voice_changer.RVC.pipeline.Pipeline import Pipeline from Exceptions import DeviceCannotSupportHalfPrecisionException, NoModeLoadedException -from const import RVC_MODEL_DIRNAME, SAMPLES_JSONS, UPLOAD_DIR +from const import ( + RVC_MODEL_DIRNAME, + UPLOAD_DIR, + getRVCSampleJsonAndModelIds, +) import shutil import json @@ -71,7 +75,10 @@ class RVC: # サンプルカタログ作成 sampleJsons: list[str] = [] - for url in SAMPLES_JSONS: + sampleJsonUrls, _sampleModels = getRVCSampleJsonAndModelIds( + params.rvc_sample_mode + ) + for url in sampleJsonUrls: filename = os.path.basename(url) sampleJsons.append(filename) sampleModels = getModelSamples(sampleJsons, "RVC") diff --git a/server/voice_changer/RVC/SampleDownloader.py b/server/voice_changer/RVC/SampleDownloader.py index 94c9f37f..c61de359 100644 --- a/server/voice_changer/RVC/SampleDownloader.py +++ b/server/voice_changer/RVC/SampleDownloader.py @@ -1,7 +1,7 @@ from concurrent.futures import ThreadPoolExecutor from dataclasses import asdict import os -from const import RVC_MODEL_DIRNAME, SAMPLE_MODEL_IDS, TMP_DIR +from const import RVC_MODEL_DIRNAME, TMP_DIR from Downloader import download, download_no_tqdm from ModelSample import RVCModelSample, getModelSamples import json @@ -17,9 +17,9 @@ def checkRvcModelExist(model_dir: str): return True -def downloadInitialSampleModels(sampleJsons: list[str], model_dir: str): - sampleModelIds = SAMPLE_MODEL_IDS - +def downloadInitialSampleModels( + sampleJsons: list[str], sampleModelIds: list[str], model_dir: str +): sampleModels = getModelSamples(sampleJsons, "RVC") if sampleModels is None: return diff --git a/server/voice_changer/utils/VoiceChangerParams.py b/server/voice_changer/utils/VoiceChangerParams.py index 8b9e83a4..47e4855a 100644 --- a/server/voice_changer/utils/VoiceChangerParams.py +++ b/server/voice_changer/utils/VoiceChangerParams.py @@ -11,3 +11,4 @@ class VoiceChangerParams: hubert_base_jp: str hubert_soft: str nsf_hifigan: str + rvc_sample_mode: str