multimodalart HF Staff commited on
Commit
9325c48
·
verified ·
1 Parent(s): e005d2b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -16,6 +16,7 @@ import time
16
 
17
  import gradio as gr
18
  import numpy as np
 
19
  from ema_lightning import EMA
20
 
21
  MAX_CHARS = 1200 # keeps the whole request well inside a few seconds of GPU
@@ -31,6 +32,21 @@ SAMPLE_RATE = 48000
31
  # model, so pin it and skip the probe entirely.
32
  tts._batch_size = 1
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  @spaces.GPU(duration=30)
36
  def synthesize(text: str, speed: float = 1.0, seed: int = 0, sample_rate: int = 48000):
@@ -78,7 +94,7 @@ CSS = """
78
  .dark .gradio-container { color: var(--body-text-color); }
79
  """
80
 
81
- with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
82
  gr.Markdown(
83
  "# ⚡ EMA Lightning — Turkish Text-to-Speech\n"
84
  "An 8.6M-parameter (34 MB) flow-matching TTS that reads Turkish "
@@ -146,4 +162,4 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
146
  api_name="synthesize",
147
  )
148
 
149
- demo.launch(mcp_server=True)
 
16
 
17
  import gradio as gr
18
  import numpy as np
19
+ import torch
20
  from ema_lightning import EMA
21
 
22
  MAX_CHARS = 1200 # keeps the whole request well inside a few seconds of GPU
 
32
  # model, so pin it and skip the probe entirely.
33
  tts._batch_size = 1
34
 
35
+ # The package loads checkpoints as .to(device).requires_grad_(False), but the
36
+ # ZeroGPU hijack snapshots requires_grad at .to() time, so the decoder's
37
+ # weights arrive in the worker flagged as grad-tracking. Playhead decodes in a
38
+ # background thread (engine.decode is the one stage without @torch.no_grad()),
39
+ # which makes the audio require grad and kills .numpy(). Wrap it.
40
+ _engine_decode = tts._engine.decode
41
+
42
+
43
+ @torch.no_grad()
44
+ def _decode_nograd(*args, **kwargs):
45
+ return _engine_decode(*args, **kwargs)
46
+
47
+
48
+ tts._engine.decode = _decode_nograd
49
+
50
 
51
  @spaces.GPU(duration=30)
52
  def synthesize(text: str, speed: float = 1.0, seed: int = 0, sample_rate: int = 48000):
 
94
  .dark .gradio-container { color: var(--body-text-color); }
95
  """
96
 
97
+ with gr.Blocks() as demo:
98
  gr.Markdown(
99
  "# ⚡ EMA Lightning — Turkish Text-to-Speech\n"
100
  "An 8.6M-parameter (34 MB) flow-matching TTS that reads Turkish "
 
162
  api_name="synthesize",
163
  )
164
 
165
+ demo.launch(mcp_server=True, theme=gr.themes.Citrus(), css=CSS)