phatdo commited on
Commit
5ba2040
·
verified ·
1 Parent(s): b5aa651

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -23,11 +23,7 @@ Please select the model's tab above, enter any Frisian text (or choose from the
23
  """
24
  article = "<center>This is a basic demo version intended to accompany my PhD dissertation, showcasing the effects of several findings included in the research (please see the dissertation for details).<br> Due to hosting constraints, the model may be rather slow in synthesizing. Thank you for your patience!<br> Please reach out to <a href='https://www.rug.nl/staff/t.p.do/' target='_blank'>Phat Do</a> or email me at <a href='mailto:t.p.do@rug.nl' target='_blank'>t.p.do@rug.nl</a> if you are interested in knowing more!</center><br><br>To phonetically transcribe the input Frisian text, this work gratefully uses the G2P Frysk model and script kindly provided by the Fryske Akademy:<br> Heeringa, Wilbert & Drenth, Eduard & Van de Velde, Hans (2024). G2P Frysk [computer program]. Retrieved 4 July 2024 from <a href='https://www.fa.knaw.nl/fa-apps/graph2phon/' target='_blank'>https://www.fa.knaw.nl/fa-apps/graph2phon/</a>."
25
 
26
- # device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
27
- device = "cuda" if torch.cuda.is_available() else "cpu"
28
-
29
- @spaces.GPU(duration=10)
30
- def load_models(config_path, model_name):
31
  # getting configs
32
  preprocess_config = yaml.load(open(os.path.join(os.getcwd(), config_path + "preprocess.yaml"), "r"), Loader=yaml.FullLoader)
33
  model_config = yaml.load(open(os.path.join(os.getcwd(), config_path + "model.yaml"), "r"), Loader=yaml.FullLoader)
@@ -45,6 +41,8 @@ configs_multi, model_multi, vocoder_multi = load_models(config_path = "config/Fr
45
 
46
  @spaces.GPU(duration=20)
47
  def infer(text, speaker_ID, configs, model, vocoder):
 
 
48
  speakers = np.array([int(speaker_ID)])
49
  texts = np.array([synthesize.preprocess_frysk(text, configs[0])])
50
  text_lens = np.array([len(texts[0])])
 
23
  """
24
  article = "<center>This is a basic demo version intended to accompany my PhD dissertation, showcasing the effects of several findings included in the research (please see the dissertation for details).<br> Due to hosting constraints, the model may be rather slow in synthesizing. Thank you for your patience!<br> Please reach out to <a href='https://www.rug.nl/staff/t.p.do/' target='_blank'>Phat Do</a> or email me at <a href='mailto:t.p.do@rug.nl' target='_blank'>t.p.do@rug.nl</a> if you are interested in knowing more!</center><br><br>To phonetically transcribe the input Frisian text, this work gratefully uses the G2P Frysk model and script kindly provided by the Fryske Akademy:<br> Heeringa, Wilbert & Drenth, Eduard & Van de Velde, Hans (2024). G2P Frysk [computer program]. Retrieved 4 July 2024 from <a href='https://www.fa.knaw.nl/fa-apps/graph2phon/' target='_blank'>https://www.fa.knaw.nl/fa-apps/graph2phon/</a>."
25
 
26
+ def load_models(config_path, model_name, device = "cpu"):
 
 
 
 
27
  # getting configs
28
  preprocess_config = yaml.load(open(os.path.join(os.getcwd(), config_path + "preprocess.yaml"), "r"), Loader=yaml.FullLoader)
29
  model_config = yaml.load(open(os.path.join(os.getcwd(), config_path + "model.yaml"), "r"), Loader=yaml.FullLoader)
 
41
 
42
  @spaces.GPU(duration=20)
43
  def infer(text, speaker_ID, configs, model, vocoder):
44
+ model.to('cuda')
45
+ vocoder.to('cuda')
46
  speakers = np.array([int(speaker_ID)])
47
  texts = np.array([synthesize.preprocess_frysk(text, configs[0])])
48
  text_lens = np.array([len(texts[0])])