Akjava commited on
Commit
697c000
·
1 Parent(s): 00a6409

change zero-gpu support

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -15,6 +15,15 @@ import onnxruntime as ort
15
  import pyopenjtalk
16
  import soundfile as sf
17
 
 
 
 
 
 
 
 
 
 
18
  # ============================================================================
19
  # Configuration
20
  # ============================================================================
@@ -206,14 +215,17 @@ def get_model_manager(model_name: str) -> ONNXModelManager:
206
  return model_managers[model_name]
207
 
208
 
209
- # Initialize default model
210
- get_model_manager(DEFAULT_MODEL)
 
 
 
211
 
212
  # ============================================================================
213
  # Gradio Interface Functions
214
  # ============================================================================
215
 
216
-
217
  def synthesise(
218
  text: str,
219
  model_name: str,
 
15
  import pyopenjtalk
16
  import soundfile as sf
17
 
18
+ try:
19
+ import spaces
20
+ except ImportError:
21
+ class spaces:
22
+ @staticmethod
23
+ def GPU(func):
24
+ return func
25
+
26
+
27
  # ============================================================================
28
  # Configuration
29
  # ============================================================================
 
215
  return model_managers[model_name]
216
 
217
 
218
+ # Pre-load all available models
219
+ print("Pre-loading all models for ZeroGPU...")
220
+ for model_name in get_available_models():
221
+ get_model_manager(model_name)
222
+ print("All models loaded.")
223
 
224
  # ============================================================================
225
  # Gradio Interface Functions
226
  # ============================================================================
227
 
228
+ @spaces.GPU
229
  def synthesise(
230
  text: str,
231
  model_name: str,