jacky3102 commited on
Commit
f120c4a
·
verified ·
1 Parent(s): e25c372

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
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
- # Ensure RVC directory exists
20
  if not (RVC_DIR / "infer-web.py").exists():
21
- raise FileNotFoundError(f"RVC directory not found at {RVC_DIR}")
22
-
23
- # Set Python execution context to RVC root
 
 
 
 
 
 
 
24
  sys.path.insert(0, str(RVC_DIR))
25
  os.chdir(RVC_DIR)
26
 
27
- # Download required model assets if missing
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
- # Start WebUI server
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",