Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import sys
|
|
| 3 |
import subprocess
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
-
# Hugging Face Spaces / CPU-only
|
| 7 |
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 8 |
os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
|
| 9 |
os.environ["GRADIO_SERVER_PORT"] = "7860"
|
|
@@ -16,21 +16,19 @@ def run(cmd, cwd=None):
|
|
| 16 |
print(">>>", " ".join(map(str, cmd)), flush=True)
|
| 17 |
subprocess.check_call(cmd, cwd=cwd)
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
if not (RVC_DIR / "infer-web.py").exists():
|
| 21 |
run([
|
| 22 |
"git", "clone", "--depth", "1",
|
| 23 |
"https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git",
|
| 24 |
str(RVC_DIR)
|
| 25 |
])
|
| 26 |
|
| 27 |
-
# Make RVC's Python modules importable
|
| 28 |
sys.path.insert(0, str(RVC_DIR))
|
| 29 |
os.chdir(RVC_DIR)
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
# RVC's official repository documents hubert_base.pt and rmvpe.pt as required
|
| 33 |
-
# inference assets.
|
| 34 |
hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
|
| 35 |
rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
|
| 36 |
|
|
@@ -39,10 +37,10 @@ if not hubert.exists() or not rmvpe.exists():
|
|
| 39 |
if downloader.exists():
|
| 40 |
run([sys.executable, str(downloader)], cwd=RVC_DIR)
|
| 41 |
|
| 42 |
-
# Start the
|
| 43 |
run([
|
| 44 |
sys.executable,
|
| 45 |
"infer-web.py",
|
| 46 |
"--pycmd", sys.executable,
|
| 47 |
"--port", "7860",
|
| 48 |
-
], cwd=RVC_DIR)
|
|
|
|
| 3 |
import subprocess
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
+
# Hugging Face Spaces / CPU-only environment setup
|
| 7 |
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 8 |
os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
|
| 9 |
os.environ["GRADIO_SERVER_PORT"] = "7860"
|
|
|
|
| 16 |
print(">>>", " ".join(map(str, cmd)), flush=True)
|
| 17 |
subprocess.check_call(cmd, cwd=cwd)
|
| 18 |
|
| 19 |
+
# Step 1: Clone official RVC WebUI repository into /app/rvc before changing working directory
|
| 20 |
+
if not RVC_DIR.exists() or not (RVC_DIR / "infer-web.py").exists():
|
| 21 |
run([
|
| 22 |
"git", "clone", "--depth", "1",
|
| 23 |
"https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git",
|
| 24 |
str(RVC_DIR)
|
| 25 |
])
|
| 26 |
|
| 27 |
+
# Step 2: Make RVC's Python modules importable and change directory AFTER the repository is cloned
|
| 28 |
sys.path.insert(0, str(RVC_DIR))
|
| 29 |
os.chdir(RVC_DIR)
|
| 30 |
|
| 31 |
+
# Step 3: Download inference-only pretrained assets if missing
|
|
|
|
|
|
|
| 32 |
hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
|
| 33 |
rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
|
| 34 |
|
|
|
|
| 37 |
if downloader.exists():
|
| 38 |
run([sys.executable, str(downloader)], cwd=RVC_DIR)
|
| 39 |
|
| 40 |
+
# Step 4: Start the RVC WebUI on Hugging Face Space port 7860
|
| 41 |
run([
|
| 42 |
sys.executable,
|
| 43 |
"infer-web.py",
|
| 44 |
"--pycmd", sys.executable,
|
| 45 |
"--port", "7860",
|
| 46 |
+
], cwd=RVC_DIR)
|