Spaces:
Running on Zero
Running on Zero
github-actions[bot] commited on
Commit ·
30a5c8e
1
Parent(s): 7d0e89c
deploy: switch to chatterbox requirements @ 0ef36cd
Browse files- tools_api/dramabox.py +40 -24
tools_api/dramabox.py
CHANGED
|
@@ -22,6 +22,8 @@ import threading
|
|
| 22 |
import time
|
| 23 |
from pathlib import Path
|
| 24 |
|
|
|
|
|
|
|
| 25 |
# Backend env knobs — kept compatible with the upstream Space.
|
| 26 |
_LTX_DTYPE = os.environ.get("LTX_DTYPE", "bf16")
|
| 27 |
|
|
@@ -79,6 +81,33 @@ def _ensure_server():
|
|
| 79 |
return _tts_server
|
| 80 |
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
def generate_scene(
|
| 83 |
*,
|
| 84 |
prompt: str,
|
|
@@ -105,30 +134,17 @@ def generate_scene(
|
|
| 105 |
if not prompt:
|
| 106 |
raise ValueError("Prompt is empty.")
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
audio_ref=audio_ref,
|
| 120 |
-
cfg=cfg, stg=stg, dur_mult=dur_mult,
|
| 121 |
-
gen_dur=gen_dur, ref_dur=ref_dur, seed=seed,
|
| 122 |
-
)
|
| 123 |
-
return _run()
|
| 124 |
-
except ImportError:
|
| 125 |
-
return _generate_impl(
|
| 126 |
-
prompt=prompt,
|
| 127 |
-
out_dir=out_dir,
|
| 128 |
-
audio_ref=audio_ref,
|
| 129 |
-
cfg=cfg, stg=stg, dur_mult=dur_mult,
|
| 130 |
-
gen_dur=gen_dur, ref_dur=ref_dur, seed=seed,
|
| 131 |
-
)
|
| 132 |
|
| 133 |
|
| 134 |
def _generate_impl(
|
|
|
|
| 22 |
import time
|
| 23 |
from pathlib import Path
|
| 24 |
|
| 25 |
+
import spaces
|
| 26 |
+
|
| 27 |
# Backend env knobs — kept compatible with the upstream Space.
|
| 28 |
_LTX_DTYPE = os.environ.get("LTX_DTYPE", "bf16")
|
| 29 |
|
|
|
|
| 81 |
return _tts_server
|
| 82 |
|
| 83 |
|
| 84 |
+
@spaces.GPU(duration=60)
|
| 85 |
+
def _generate_scene_gpu(
|
| 86 |
+
*,
|
| 87 |
+
prompt: str,
|
| 88 |
+
out_dir: Path,
|
| 89 |
+
audio_ref: Path | None,
|
| 90 |
+
cfg: float,
|
| 91 |
+
stg: float,
|
| 92 |
+
dur_mult: float,
|
| 93 |
+
gen_dur: float,
|
| 94 |
+
ref_dur: float,
|
| 95 |
+
seed: int,
|
| 96 |
+
) -> dict:
|
| 97 |
+
"""Top-level ZeroGPU wrapper so HF detects Dramabox GPU usage at startup."""
|
| 98 |
+
return _generate_impl(
|
| 99 |
+
prompt=prompt,
|
| 100 |
+
out_dir=out_dir,
|
| 101 |
+
audio_ref=audio_ref,
|
| 102 |
+
cfg=cfg,
|
| 103 |
+
stg=stg,
|
| 104 |
+
dur_mult=dur_mult,
|
| 105 |
+
gen_dur=gen_dur,
|
| 106 |
+
ref_dur=ref_dur,
|
| 107 |
+
seed=seed,
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
def generate_scene(
|
| 112 |
*,
|
| 113 |
prompt: str,
|
|
|
|
| 134 |
if not prompt:
|
| 135 |
raise ValueError("Prompt is empty.")
|
| 136 |
|
| 137 |
+
return _generate_scene_gpu(
|
| 138 |
+
prompt=prompt,
|
| 139 |
+
out_dir=out_dir,
|
| 140 |
+
audio_ref=audio_ref,
|
| 141 |
+
cfg=cfg,
|
| 142 |
+
stg=stg,
|
| 143 |
+
dur_mult=dur_mult,
|
| 144 |
+
gen_dur=gen_dur,
|
| 145 |
+
ref_dur=ref_dur,
|
| 146 |
+
seed=seed,
|
| 147 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
def _generate_impl(
|