Yurii Paniv commited on
Commit
cf6a4f7
1 Parent(s): 278c35e

Fix model caching to specified directory

Browse files
Files changed (1) hide show
  1. ukrainian_tts/tts.py +5 -3
ukrainian_tts/tts.py CHANGED
@@ -1,6 +1,6 @@
1
  from io import BytesIO
2
  import requests
3
- from os.path import exists, join
4
  from espnet2.bin.tts_inference import Text2Speech
5
  from enum import Enum
6
  from .formatter import preprocess_text
@@ -112,8 +112,8 @@ class TTS:
112
  print("downloaded.")
113
 
114
  self.synthesizer = Text2Speech(
115
- train_config="config.yaml",
116
- model_file="model.pth",
117
  device=self.device,
118
  # Only for VITS
119
  noise_scale=0.333,
@@ -124,6 +124,8 @@ class TTS:
124
  def __download(self, url, file_name):
125
  """Downloads file from `url` into local `file_name` file."""
126
  if not exists(file_name):
 
 
127
  print(f"Downloading {file_name}")
128
  r = requests.get(url, allow_redirects=True)
129
  with open(file_name, "wb") as file:
1
  from io import BytesIO
2
  import requests
3
+ from os.path import exists, join, dirname
4
  from espnet2.bin.tts_inference import Text2Speech
5
  from enum import Enum
6
  from .formatter import preprocess_text
112
  print("downloaded.")
113
 
114
  self.synthesizer = Text2Speech(
115
+ train_config=config_path,
116
+ model_file=model_path,
117
  device=self.device,
118
  # Only for VITS
119
  noise_scale=0.333,
124
  def __download(self, url, file_name):
125
  """Downloads file from `url` into local `file_name` file."""
126
  if not exists(file_name):
127
+ if not exists(dirname(file_name)):
128
+ raise ValueError(f"Directory \"{dirname(file_name)}\" doesn't exist!")
129
  print(f"Downloading {file_name}")
130
  r = requests.get(url, allow_redirects=True)
131
  with open(file_name, "wb") as file: