mhrahmani commited on
Commit
1981b8a
1 Parent(s): 94d56ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -26,6 +26,19 @@ for model_name, model_file, config_file, repo_name in MODEL_INFO:
26
  hf_hub_download(repo_id=repo_name, filename=model_file, cache_dir=model_name, use_auth_token=TOKEN)
27
  hf_hub_download(repo_id=repo_name, filename=config_file, cache_dir=model_name, use_auth_token=TOKEN)
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  def synthesize(text: str, model_name: str) -> str:
30
  """Synthesize speech using the selected model."""
31
  if len(text) > MAX_TXT_LEN:
 
26
  hf_hub_download(repo_id=repo_name, filename=model_file, cache_dir=model_name, use_auth_token=TOKEN)
27
  hf_hub_download(repo_id=repo_name, filename=config_file, cache_dir=model_name, use_auth_token=TOKEN)
28
 
29
+ # Verify if the files are downloaded correctly
30
+ for model_name, model_file, config_file, repo_name in MODEL_INFO:
31
+ os.makedirs(model_name, exist_ok=True)
32
+ print(f"|> Downloading: {model_name}")
33
+
34
+ model_file_path = hf_hub_download(repo_id=repo_name, filename=model_file, cache_dir=model_name, use_auth_token=TOKEN)
35
+ config_file_path = hf_hub_download(repo_id=repo_name, filename=config_file, cache_dir=model_name, use_auth_token=TOKEN)
36
+
37
+ # Check if the files exist after download
38
+ if not os.path.exists(model_file_path) or not os.path.exists(config_file_path):
39
+ raise FileNotFoundError(f"Failed to download files for {model_name}. Please check the repository and file names.")
40
+
41
+
42
  def synthesize(text: str, model_name: str) -> str:
43
  """Synthesize speech using the selected model."""
44
  if len(text) > MAX_TXT_LEN: