TaiYouWeb commited on
Commit
e07a041
·
verified ·
1 Parent(s): baa51fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -11,6 +11,18 @@ import gradio as gr
11
 
12
  import config
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  device = "cuda" if torch.cuda.is_available() else "cpu"
15
 
16
  def ask_tos_patch(self, output_path):
@@ -25,7 +37,7 @@ for id, model in config.models.items():
25
  tts.download_model_by_name(model)
26
  models[id] = TTS.api.TTS(model).to(device)
27
 
28
-
29
  def synthesize_tts(
30
  text: str = 'Hello, World!',
31
  speaker_wavs: List[gr.File] = None,
 
11
 
12
  import config
13
 
14
+ try:
15
+ import spaces
16
+ USING_SPACES = True
17
+ except ImportError:
18
+ USING_SPACES = False
19
+
20
+ def gpu_decorator(func):
21
+ if USING_SPACES:
22
+ return spaces.GPU(func)
23
+ else:
24
+ return func
25
+
26
  device = "cuda" if torch.cuda.is_available() else "cpu"
27
 
28
  def ask_tos_patch(self, output_path):
 
37
  tts.download_model_by_name(model)
38
  models[id] = TTS.api.TTS(model).to(device)
39
 
40
+ @gpu_decorator
41
  def synthesize_tts(
42
  text: str = 'Hello, World!',
43
  speaker_wavs: List[gr.File] = None,