Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
|
|
|
| 3 |
import subprocess
|
| 4 |
from pathlib import Path
|
| 5 |
|
|
@@ -16,15 +17,22 @@ 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 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
sys.path.insert(0, str(RVC_DIR))
|
| 25 |
os.chdir(RVC_DIR)
|
| 26 |
|
| 27 |
-
# Download
|
| 28 |
hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
|
| 29 |
rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
|
| 30 |
|
|
@@ -33,7 +41,7 @@ if not hubert.exists() or not rmvpe.exists():
|
|
| 33 |
if downloader.exists():
|
| 34 |
run([sys.executable, str(downloader)], cwd=RVC_DIR)
|
| 35 |
|
| 36 |
-
#
|
| 37 |
run([
|
| 38 |
sys.executable,
|
| 39 |
"infer-web.py",
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
+
import shutil
|
| 4 |
import subprocess
|
| 5 |
from pathlib import Path
|
| 6 |
|
|
|
|
| 17 |
print(">>>", " ".join(map(str, cmd)), flush=True)
|
| 18 |
subprocess.check_call(cmd, cwd=cwd)
|
| 19 |
|
| 20 |
+
# 1. Clone repository safely (cleaning up existing empty/broken dirs if present)
|
| 21 |
if not (RVC_DIR / "infer-web.py").exists():
|
| 22 |
+
if RVC_DIR.exists():
|
| 23 |
+
shutil.rmtree(RVC_DIR)
|
| 24 |
+
|
| 25 |
+
run([
|
| 26 |
+
"git", "clone", "--depth", "1",
|
| 27 |
+
"https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git",
|
| 28 |
+
str(RVC_DIR)
|
| 29 |
+
])
|
| 30 |
+
|
| 31 |
+
# 2. Set execution context
|
| 32 |
sys.path.insert(0, str(RVC_DIR))
|
| 33 |
os.chdir(RVC_DIR)
|
| 34 |
|
| 35 |
+
# 3. Download pretrained assets if missing
|
| 36 |
hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
|
| 37 |
rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
|
| 38 |
|
|
|
|
| 41 |
if downloader.exists():
|
| 42 |
run([sys.executable, str(downloader)], cwd=RVC_DIR)
|
| 43 |
|
| 44 |
+
# 4. Launch RVC WebUI
|
| 45 |
run([
|
| 46 |
sys.executable,
|
| 47 |
"infer-web.py",
|