Skip to content

Commit

Permalink
Merge pull request #77 from deiteris/minor-improvements
Browse files Browse the repository at this point in the history
Minor improvements
  • Loading branch information
deiteris authored Jun 15, 2024
2 parents bbcc0be + 733c596 commit 9924c0a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 43 deletions.
44 changes: 19 additions & 25 deletions Colab_RealtimeVoiceChanger.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,28 @@
"\n",
"## **READ ME - VERY IMPORTANT**\n",
"\n",
"You can use the following settings for better results:\n",
"You can use the following settings for optimal results:\n",
"\n",
"If you're using a index: `f0: RMVPE_ONNX | Chunk: 40 or higher | Extra: 131072`\\\n",
"If you're not using a index: `f0: RMVPE_ONNX | Chunk: 32 or higher | Extra: 131072`\\\n",
"Best performance: `f0: fcpe | Chunk: 64.0ms or higher | Extra: 2.7s`<br>\n",
"Best quality: `f0: rmvpe | Chunk: 72.0ms or higher | Extra: 5s`<br>\n",
"**Don't forget to select your Colab GPU in the GPU field (<b>Tesla T4</b>, for free users)*\n",
"\n",
"*You can always [click here](https://rentry.co/VoiceChangerGuide#gpu-chart-for-known-working-chunkextra\n",
") to check if these settings are up-to-date*\n",
"You can tune `Chunk` for lower/higher delay and `Extra` for better quality.\n",
"\n",
"*You can always [click here](https://rentry.co/VoiceChangerGuide#gpu-chart-for-known-working-chunkextra) to check if these settings are up-to-date*\n",
"<br><br>\n",
"\n",
"---\n",
"\n",
"###Always use Colab GPU (**VERY VERY VERY IMPORTANT!**)\n",
"### Always use Colab GPU (**VERY VERY VERY IMPORTANT!**)\n",
"You need to use a Colab GPU so the Voice Changer can work faster and better\\\n",
"Use the menu above and click on **Runtime** » **Change runtime** » **Hardware acceleration** to select a GPU (**T4 is the free one**)\n",
"\n",
"---\n",
"\n",
"<br>\n",
"\n",
"# **Credits and Support**\n",
"Realtime Voice Changer by [w-okada](https://github.com/w-okada)\\\n",
"Colab files updated by [rafacasari](https://github.com/Rafacasari)\\\n",
"Recommended settings by [Raven](https://github.com/ravencutie21)\\\n",
"Modified again by [Hina](https://github.com/HinaBl)\n",
"Realtime Voice Changer by [w-okada](https://github.com/w-okada)<br>\n",
"Original instructions by [Hina](https://github.com/HinaBl)<br>\n",
"\n",
"Need help? [AI Hub Discord](https://discord.gg/aihub) » ***#help-realtime-vc***\n",
"\n",
Expand Down Expand Up @@ -107,19 +104,18 @@
"# if not os.path.exists('/content/voice-changer/server/stored_settings.json'):\n",
"# !wget -q https://raw.githubusercontent.com/deiteris/voice-changer/master-custom/presets/colab.json -O /content/voice-changer/server/stored_settings.json\n",
"\n",
"if Use_Drive==True:\n",
" if not os.path.exists('/content/drive'):\n",
" drive.mount('/content/drive')\n",
"if Use_Drive and not os.path.exists('/content/drive'):\n",
" drive.mount('/content/drive')\n",
"\n",
" !mkdir -p /content/drive/MyDrive/voice-changer/server/model_dir\n",
" !mkdir -p /content/drive/MyDrive/voice-changer/server/pretrain\n",
" !rm -rf /content/voice-changer/server/model_dir\n",
" !rm -rf /content/voice-changer/server/pretrain\n",
" !mkdir -p /content/drive/MyDrive/voice-changer/server/model_dir\n",
" !mkdir -p /content/drive/MyDrive/voice-changer/server/pretrain\n",
" !rm -rf /content/voice-changer/server/model_dir\n",
" !rm -rf /content/voice-changer/server/pretrain\n",
"\n",
" time.sleep(5)\n",
" time.sleep(5)\n",
"\n",
" os.symlink(\"/content/drive/MyDrive/voice-changer/server/model_dir\", \"/content/voice-changer/server/model_dir\", True)\n",
" os.symlink(\"/content/drive/MyDrive/voice-changer/server/pretrain\", \"/content/voice-changer/server/pretrain\", True)\n",
" os.symlink(\"/content/drive/MyDrive/voice-changer/server/model_dir\", \"/content/voice-changer/server/model_dir\", True)\n",
" os.symlink(\"/content/drive/MyDrive/voice-changer/server/pretrain\", \"/content/voice-changer/server/pretrain\", True)\n",
"\n",
"print(f\"{Fore.GREEN}> Successfully cloned the repository!{Style.RESET_ALL}\")\n",
"\n",
Expand All @@ -131,9 +127,7 @@
"!pip install pyngrok --quiet\n",
"print(f\"{Fore.CYAN}> Installing dependencies from requirements.txt...{Style.RESET_ALL}\")\n",
"!pip install --upgrade -r requirements-common.txt -r requirements-cuda.txt --quiet\n",
"print(f\"{Fore.GREEN}> Successfully installed all packages!{Style.RESET_ALL}\")\n",
"\n",
"Run_Cell=1"
"print(f\"{Fore.GREEN}> Successfully installed all packages!{Style.RESET_ALL}\")"
]
},
{
Expand Down
13 changes: 7 additions & 6 deletions Kaggle_RealtimeVoiceChanger.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
"\n",
"## **⬇ VERY IMPORTANT ⬇**\n",
"\n",
"You can use the following settings for better results:\n",
"You can use the following settings for optimal results:\n",
"\n",
"If you're using a index: `f0: RMVPE_ONNX | Chunk: 40 or higher | Extra: 131072`<br>\n",
"If you're not using a index: `f0: RMVPE_ONNX | Chunk: 32 or higher | Extra: 131072`<br>\n",
"Best performance: `f0: fcpe | Chunk: 56.0ms or higher | Extra: 2.7s`<br>\n",
"Best quality: `f0: rmvpe | Chunk: 64.0ms or higher | Extra: 5s`<br>\n",
"**Don't forget to select a GPU in the GPU field, <b>NEVER</b> use CPU!\n",
"\n",
"You can tune `Chunk` for lower/higher delay and `Extra` for better quality.\n",
"\n",
"*You can always [click here](https://github.com/YunaOneeChan/Voice-Changer-Settings) to check if these settings are up-to-date*\n",
"\n",
"---\n",
"**Credits**<br>\n",
"Realtime Voice Changer by [w-okada](https://github.com/w-okada)<br>\n",
"Notebook files updated by [rafacasari](https://github.com/Rafacasari)<br>\n",
"Recommended settings by [YunaOneeChan](https://github.com/YunaOneeChan)\n",
"Realtime Voice Changer by [w-okada](https://github.com/w-okada)\n",
"Original instructions by [Hina](https://github.com/HinaBl)\n",
"\n",
"**Need help?** [AI Hub Discord](https://discord.gg/aihub) » ***#help-realtime-vc***\n",
"\n",
Expand Down
12 changes: 4 additions & 8 deletions server/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ def getSampleJsonAndModelIds(mode: RVCSampleMode):
if mode == "production":
return [
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0004_t.json",
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0004_o.json",
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0004_d.json",
], [
("Tsukuyomi-chan_o", {"useIndex": False}),
("Amitaro_o", {"useIndex": False}),
("KikotoMahiro_o", {"useIndex": False}),
("TokinaShigure_o", {"useIndex": False}),
("Tsukuyomi-chan_t", {"useIndex": False}),
("Amitaro_t", {"useIndex": False}),
("KikotoMahiro_t", {"useIndex": False}),
("TokinaShigure_t", {"useIndex": False}),
]
elif mode == "testAll":
return [
Expand Down Expand Up @@ -192,6 +190,4 @@ def getSampleJsonAndModelIds(mode: RVCSampleMode):
else:
return [], []


RVC_MODEL_DIRNAME = "rvc"
MAX_SLOT_NUM = 500
2 changes: 1 addition & 1 deletion server/voice_changer/RVC/inferencer/RVCInferencerv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def load_model(self, file: str):
self.set_props(EnumInferenceTypes.pyTorchRVCv2, file)

# Keep torch.load for backward compatibility, but discourage the use of this loading method
if '.safetensors' in file:
if file.endswith('.safetensors'):
with safe_open(file, 'pt', device=str(dev) if dev.type == 'cuda' else 'cpu') as cpt:
config = json.loads(cpt.metadata()['config'])
model = SynthesizerTrnMs768NSFsid(*config, is_half=is_half).to(dev)
Expand Down
2 changes: 1 addition & 1 deletion server/voice_changer/RVC/inferencer/RVCInferencerv2Nono.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def load_model(self, file: str):
self.set_props(EnumInferenceTypes.pyTorchRVCv2Nono, file, is_half)

# Keep torch.load for backward compatibility, but discourage the use of this loading method
if '.safetensors' in file:
if file.endswith('.safetensors'):
with safe_open(file, 'pt', device=str(dev) if dev.type == 'cuda' else 'cpu') as cpt:
config = json.loads(cpt.metadata()['config'])
model = SynthesizerTrnMs768NSFsid_nono(*config, is_half=is_half).to(dev)
Expand Down
2 changes: 1 addition & 1 deletion server/voice_changer/RVC/onnxExporter/export2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _export2onnx(input_model: str, output_model_simple: str, metadata: dict):
if dev.type == 'privateuseone':
dev = torch.device('cpu')
is_half = False
is_safetensors = '.safetensors' in input_model
is_safetensors = input_model.endswith('.safetensors')

if is_safetensors:
cpt = safetensors.safe_open(input_model, 'pt', device=str(dev))
Expand Down
2 changes: 1 addition & 1 deletion server/voice_changer/common/rmvpe/rmvpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def __init__(self, model_path: str, is_half: bool, device: torch.device | str =
device = 'cuda' if torch.cuda.is_available() else 'cpu'

model = E2E(4, 1, (2, 2))
if '.safetensors' in model_path:
if model_path.endswith('.safetensors'):
with safe_open(model_path, 'pt', device=str(device) if device.type == 'cuda' else 'cpu') as cpt:
load_model(model, cpt, strict=False)
else:
Expand Down

0 comments on commit 9924c0a

Please sign in to comment.