is_space_imported
Browse files
app.py
CHANGED
@@ -3,12 +3,17 @@ import json
|
|
3 |
import torch
|
4 |
import time
|
5 |
import random
|
|
|
6 |
try:
|
7 |
-
# Only on HuggingFace
|
8 |
import spaces
|
9 |
is_space_imported = True
|
10 |
-
except
|
11 |
is_space_imported = False
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
from tqdm import tqdm
|
14 |
from huggingface_hub import snapshot_download
|
@@ -115,6 +120,7 @@ def update_output(output_format, output_number):
|
|
115 |
gr.update(visible = False)
|
116 |
]
|
117 |
|
|
|
118 |
def text2audio(
|
119 |
prompt,
|
120 |
output_number,
|
@@ -150,9 +156,6 @@ def text2audio(
|
|
150 |
gr.update(visible = True, value = "Start again to get a different result. The output have been generated in " + ((str(hours) + " h, ") if hours != 0 else "") + ((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + str(secondes) + " sec.")
|
151 |
]
|
152 |
|
153 |
-
if is_space_imported:
|
154 |
-
text2audio = spaces.GPU(text2audio, duration = 420)
|
155 |
-
|
156 |
# Gradio interface
|
157 |
with gr.Blocks() as interface:
|
158 |
gr.Markdown("""
|
|
|
3 |
import torch
|
4 |
import time
|
5 |
import random
|
6 |
+
|
7 |
try:
|
|
|
8 |
import spaces
|
9 |
is_space_imported = True
|
10 |
+
except:
|
11 |
is_space_imported = False
|
12 |
+
class spaces():
|
13 |
+
def GPU(*args, **kwargs):
|
14 |
+
def decorator(function):
|
15 |
+
return lambda *dummy_args, **dummy_kwargs: function(*dummy_args, **dummy_kwargs)
|
16 |
+
return decorator
|
17 |
|
18 |
from tqdm import tqdm
|
19 |
from huggingface_hub import snapshot_download
|
|
|
120 |
gr.update(visible = False)
|
121 |
]
|
122 |
|
123 |
+
@spaces.GPU(duration = 420)
|
124 |
def text2audio(
|
125 |
prompt,
|
126 |
output_number,
|
|
|
156 |
gr.update(visible = True, value = "Start again to get a different result. The output have been generated in " + ((str(hours) + " h, ") if hours != 0 else "") + ((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + str(secondes) + " sec.")
|
157 |
]
|
158 |
|
|
|
|
|
|
|
159 |
# Gradio interface
|
160 |
with gr.Blocks() as interface:
|
161 |
gr.Markdown("""
|