anzorq commited on
Commit
e893623
1 Parent(s): 81e802e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -27,8 +27,10 @@ def download_model_and_config(gender):
27
  os.makedirs(dir_path)
28
  model_url = MALE_MODEL_URL if gender == "male" else FEMALE_MODEL_URL
29
  config_url = MALE_CONFIG_URL if gender == "male" else FEMALE_CONFIG_URL
 
30
  download_url(model_url, dir_path, "model.pth")
31
  download_url(config_url, dir_path, "config.json")
 
32
  return dir_path
33
 
34
  download_model_and_config("male")
@@ -46,7 +48,7 @@ def tts(text: str, voice: str = "Male", use_onnx: bool = True):
46
  text = text.lower()
47
 
48
  if use_onnx:
49
- onnx_model_url = MALE_ONNX_MODEL_URL if voice == "Male" else FEMALE_ONNX_MODEL_URL
50
 
51
  config = VitsConfig()
52
  config.load_json(config_file)
@@ -60,7 +62,7 @@ def tts(text: str, voice: str = "Male", use_onnx: bool = True):
60
  )
61
 
62
  vits = Vits.init_from_config(config)
63
- vits.load_onnx(onnx_model_url)
64
 
65
  text_inputs = np.asarray(
66
  vits.tokenizer.text_to_ids(text),
 
27
  os.makedirs(dir_path)
28
  model_url = MALE_MODEL_URL if gender == "male" else FEMALE_MODEL_URL
29
  config_url = MALE_CONFIG_URL if gender == "male" else FEMALE_CONFIG_URL
30
+ onnx_model_url = MALE_ONNX_MODEL_URL if gender == "male" else FEMALE_ONNX_MODEL_URL
31
  download_url(model_url, dir_path, "model.pth")
32
  download_url(config_url, dir_path, "config.json")
33
+ download_url(onnx_model_url, dir_path, "model.onnx")
34
  return dir_path
35
 
36
  download_model_and_config("male")
 
48
  text = text.lower()
49
 
50
  if use_onnx:
51
+ onnx_model_path = f"{model_dir}/model.onnx"
52
 
53
  config = VitsConfig()
54
  config.load_json(config_file)
 
62
  )
63
 
64
  vits = Vits.init_from_config(config)
65
+ vits.load_onnx(onnx_model_path)
66
 
67
  text_inputs = np.asarray(
68
  vits.tokenizer.text_to_ids(text),