mhrahmani commited on
Commit
d6e1594
·
1 Parent(s): 1981b8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -15
app.py CHANGED
@@ -17,26 +17,18 @@ MODEL_NAMES = [info[0] for info in MODEL_INFO]
17
  MAX_TXT_LEN = 400
18
  TOKEN = os.environ.get('HUGGING_FACE_HUB_TOKEN') # Replace with the environment variable containing your token, if different
19
 
20
- # Download models
21
- for model_name, model_file, config_file, repo_name in MODEL_INFO:
22
- os.makedirs(model_name, exist_ok=True)
23
- print(f"|> Downloading: {model_name}")
24
-
25
- # Use hf_hub_download to download models from Hugging Face repositories
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:
@@ -48,7 +40,7 @@ def synthesize(text: str, model_name: str) -> str:
48
  # Extract model_file and config_file based on the model_name
49
  model_file, config_file = next((model_file, config_file) for name, model_file, config_file, _ in MODEL_INFO if name == model_name)
50
 
51
- synthesizer = Synthesizer(f"{model_name}/{model_file}", f"{model_name}/{config_file}")
52
  if synthesizer is None:
53
  raise NameError("Model not found")
54
 
 
17
  MAX_TXT_LEN = 400
18
  TOKEN = os.environ.get('HUGGING_FACE_HUB_TOKEN') # Replace with the environment variable containing your token, if different
19
 
 
 
 
 
 
 
 
 
20
 
21
  # Verify if the files are downloaded correctly
22
  for model_name, model_file, config_file, repo_name in MODEL_INFO:
23
+ # os.makedirs(model_name, exist_ok=True)
24
  print(f"|> Downloading: {model_name}")
25
 
26
+ model_file_path = hf_hub_download(repo_id=repo_name, filename=model_file, use_auth_token=TOKEN)
27
+ config_file_path = hf_hub_download(repo_id=repo_name, filename=config_file, use_auth_token=TOKEN)
28
 
29
+ # # Check if the files exist after download
30
+ # if not os.path.exists(model_file_path) or not os.path.exists(config_file_path):
31
+ # raise FileNotFoundError(f"Failed to download files for {model_name}. Please check the repository and file names.")
32
 
33
 
34
  def synthesize(text: str, model_name: str) -> str:
 
40
  # Extract model_file and config_file based on the model_name
41
  model_file, config_file = next((model_file, config_file) for name, model_file, config_file, _ in MODEL_INFO if name == model_name)
42
 
43
+ synthesizer = Synthesizer(model_file_path, config_file_path)
44
  if synthesizer is None:
45
  raise NameError("Model not found")
46