WEICALVIN commited on
Commit
4e188fa
·
verified ·
1 Parent(s): 56773bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -6,20 +6,23 @@ from huggingface_hub import snapshot_download
6
  REPO_DIR = "/tmp/CosyVoice"
7
  MODEL_DIR = "/tmp/CosyVoice2-0.5B"
8
  cosyvoice = None
9
- load_status = "正在初始化環境與下載模型(約 1~2 分鐘)..."
10
 
11
  def init_model():
12
  global cosyvoice, load_status
13
  try:
14
  if not os.path.exists(REPO_DIR):
15
- load_status = "正在下載 CosyVoice 原始碼..."
16
  subprocess.run(["git", "clone", "--depth", "1", "--recursive", "https://github.com/FunAudioLLM/CosyVoice.git", REPO_DIR], check=True)
17
 
 
 
 
18
  if not os.path.exists(f"{MODEL_DIR}/cosyvoice2.yaml"):
19
- load_status = "正在從 Hugging Face 內網高速下載 CosyVoice2-0.5B 模型..."
20
  snapshot_download(repo_id="FunAudioLLM/CosyVoice2-0.5B", local_dir=MODEL_DIR)
21
 
22
- load_status = "正在載入模型結構..."
23
  if REPO_DIR not in sys.path:
24
  sys.path.insert(0, REPO_DIR)
25
  matcha_dir = f"{REPO_DIR}/third_party/Matcha-TTS"
 
6
  REPO_DIR = "/tmp/CosyVoice"
7
  MODEL_DIR = "/tmp/CosyVoice2-0.5B"
8
  cosyvoice = None
9
+ load_status = "正在自動補齊官方全套依賴與模型(首次約 2~3 分鐘,之後秒開)..."
10
 
11
  def init_model():
12
  global cosyvoice, load_status
13
  try:
14
  if not os.path.exists(REPO_DIR):
15
+ load_status = "1/4 正在下載 CosyVoice 官方原始碼..."
16
  subprocess.run(["git", "clone", "--depth", "1", "--recursive", "https://github.com/FunAudioLLM/CosyVoice.git", REPO_DIR], check=True)
17
 
18
+ load_status = "2/4 正在自動讀取並安裝官方完整套件清單..."
19
+ subprocess.run([sys.executable, "-m", "pip", "install", "-q", "--no-build-isolation", "-r", f"{REPO_DIR}/requirements.txt"], check=False)
20
+
21
  if not os.path.exists(f"{MODEL_DIR}/cosyvoice2.yaml"):
22
+ load_status = "3/4 正在從 Hugging Face 內網下載 CosyVoice2-0.5B 模型..."
23
  snapshot_download(repo_id="FunAudioLLM/CosyVoice2-0.5B", local_dir=MODEL_DIR)
24
 
25
+ load_status = "4/4 正在將模型載入記憶體..."
26
  if REPO_DIR not in sys.path:
27
  sys.path.insert(0, REPO_DIR)
28
  matcha_dir = f"{REPO_DIR}/third_party/Matcha-TTS"