ford442 commited on
Commit
ebed5e1
·
verified ·
1 Parent(s): 913ceff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -10,27 +10,25 @@ import os
10
  from huggingface_hub import snapshot_download
11
 
12
  # ... (Whisper and Vicuna setup remain the same)
13
-
14
  # --- VITS (TTS) Setup ---
15
- TTS_MODEL_NAME = "espnet/kan_bayashi_ljspeech_vits"
16
  tts_device = "cuda" if torch.cuda.is_available() else "cpu"
17
 
18
- # Download the ESPnet model files and get the download path
19
- model_dir = "vits_model"
20
- if not os.path.exists(model_dir):
21
- os.makedirs(model_dir)
22
 
 
23
  download_path = snapshot_download(repo_id=TTS_MODEL_NAME, local_dir=model_dir, local_dir_use_symlinks=False)
24
- print(f"Downloaded ESPnet model to: {download_path}") # Print the path!
25
 
26
- # Construct *absolute* paths to the config and model files.
27
- config_path = os.path.join(download_path, "exp/tts_train_vits_raw_phn_tacotron_g2p_en_no_space/config.yaml")
28
- model_path = os.path.join(download_path, "exp/tts_train_vits_raw_phn_tacotron_g2p_en_no_space/train.total_count.ave_10best.pth")
29
 
30
- # Load the Text2Speech model using the downloaded files and absolute paths
31
  tts_model = Text2Speech(train_config=config_path, model_file=model_path, device=tts_device)
32
 
33
-
34
  # --- Vicuna (LLM) Setup ---
35
  VICUNA_MODEL_NAME = "lmsys/vicuna-7b-v1.5"
36
  vicuna_device = "cuda" if torch.cuda.is_available() else "cpu"
 
10
  from huggingface_hub import snapshot_download
11
 
12
  # ... (Whisper and Vicuna setup remain the same)
 
13
  # --- VITS (TTS) Setup ---
14
+ TTS_MODEL_NAME = "espnet/speechlm_tts_v1" # Updated Model Name
15
  tts_device = "cuda" if torch.cuda.is_available() else "cpu"
16
 
17
+ model_dir = "speechlm_model" # Updated directory name
18
+
19
+ if os.path.exists(model_dir):
20
+ shutil.rmtree(model_dir)
21
 
22
+ os.makedirs(model_dir)
23
  download_path = snapshot_download(repo_id=TTS_MODEL_NAME, local_dir=model_dir, local_dir_use_symlinks=False)
24
+ print(f"Downloaded ESPnet model to: {download_path}")
25
 
26
+ # --- KEY CHANGE: Adjust paths for speechlm_tts_v1 ---
27
+ config_path = os.path.join(download_path, "exp/speechlm_tts_v1/config.yaml") # Correct path for speechlm_tts_v1
28
+ model_path = os.path.join(download_path, "exp/speechlm_tts_v1/model.pth") # Correct path for speechlm_tts_v1
29
 
 
30
  tts_model = Text2Speech(train_config=config_path, model_file=model_path, device=tts_device)
31
 
 
32
  # --- Vicuna (LLM) Setup ---
33
  VICUNA_MODEL_NAME = "lmsys/vicuna-7b-v1.5"
34
  vicuna_device = "cuda" if torch.cuda.is_available() else "cpu"