refactor: remove dead ZeroGPU shim (Docker Spaces don't support ZeroGPU)
Browse files- CLAUDE.md +1 -2
- README.md +5 -7
- server/main.py +1 -3
- server/zerogpu.py +0 -25
- tests/test_zerogpu.py +0 -33
CLAUDE.md
CHANGED
|
@@ -22,7 +22,6 @@ Use the existing local git config; do not override `user.name` / `user.email` an
|
|
| 22 |
|
| 23 |
## Working preferences
|
| 24 |
|
| 25 |
-
- Multi-platform code: must run on macOS (MPS), Linux (CUDA/CPU), Windows (CUDA/CPU), and HF Spaces (Free CPU).
|
| 26 |
-
- ZeroGPU-ready: keep the `@spaces.GPU` decorator path working as a no-op locally.
|
| 27 |
- Server is **stateless**. All voice library and history persistence lives in browser IndexedDB. Do not add server-side DBs.
|
| 28 |
- YAGNI: don't add features beyond what the spec calls for.
|
|
|
|
| 22 |
|
| 23 |
## Working preferences
|
| 24 |
|
| 25 |
+
- Multi-platform code: must run on macOS (MPS), Linux (CUDA/CPU), Windows (CUDA/CPU), and HF Spaces (Free CPU; paid GPU tiers supported).
|
|
|
|
| 26 |
- Server is **stateless**. All voice library and history persistence lives in browser IndexedDB. Do not add server-side DBs.
|
| 27 |
- YAGNI: don't add features beyond what the spec calls for.
|
README.md
CHANGED
|
@@ -17,8 +17,8 @@ short_description: Voice cloning studio for the Chatterbox TTS family.
|
|
| 17 |
|
| 18 |
A multi-platform browser-based voice cloning studio for the Chatterbox TTS family
|
| 19 |
(English, Turbo, Multilingual). Runs locally on macOS (MPS), Linux (CUDA/CPU),
|
| 20 |
-
and Windows (CUDA/CPU). Deploys to Hugging Face Spaces (
|
| 21 |
-
|
| 22 |
|
| 23 |
## Quick start (local)
|
| 24 |
|
|
@@ -47,11 +47,9 @@ and opens the studio at http://127.0.0.1:7860.
|
|
| 47 |
This repo's `Dockerfile` is what HF Spaces uses to build the image.
|
| 48 |
On Free CPU it runs as-is — generation will be slow (30–90s per clip).
|
| 49 |
|
| 50 |
-
To get GPU on Spaces
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
No code change needed; the `@spaces.GPU` decorator activates.
|
| 54 |
-
- Or pick a paid GPU (T4 small / A10G).
|
| 55 |
|
| 56 |
## Environment variables
|
| 57 |
|
|
|
|
| 17 |
|
| 18 |
A multi-platform browser-based voice cloning studio for the Chatterbox TTS family
|
| 19 |
(English, Turbo, Multilingual). Runs locally on macOS (MPS), Linux (CUDA/CPU),
|
| 20 |
+
and Windows (CUDA/CPU). Deploys to Hugging Face Spaces (Docker SDK, Free CPU
|
| 21 |
+
by default; paid GPU tiers supported).
|
| 22 |
|
| 23 |
## Quick start (local)
|
| 24 |
|
|
|
|
| 47 |
This repo's `Dockerfile` is what HF Spaces uses to build the image.
|
| 48 |
On Free CPU it runs as-is — generation will be slow (30–90s per clip).
|
| 49 |
|
| 50 |
+
To get GPU on Spaces, switch the Space hardware to a paid tier (T4 small,
|
| 51 |
+
A10G, L4). ZeroGPU is **not** available on Docker Spaces — it's currently
|
| 52 |
+
restricted to the Gradio SDK only.
|
|
|
|
|
|
|
| 53 |
|
| 54 |
## Environment variables
|
| 55 |
|
server/main.py
CHANGED
|
@@ -25,7 +25,6 @@ from server.dialog import (
|
|
| 25 |
)
|
| 26 |
from server.progress import get_bus
|
| 27 |
from server.registry import Registry
|
| 28 |
-
from server.zerogpu import decorate
|
| 29 |
|
| 30 |
|
| 31 |
STATIC_DIR = Path(__file__).parent / "static"
|
|
@@ -169,12 +168,11 @@ def build_app() -> FastAPI:
|
|
| 169 |
tmp.close()
|
| 170 |
ref_path = tmp.name
|
| 171 |
|
| 172 |
-
gen_fn = decorate(adapter.generate)
|
| 173 |
bus = get_bus()
|
| 174 |
try:
|
| 175 |
async with bus.session("single", total_turns=1) as sess:
|
| 176 |
wav_bytes, _sr, seed_used = await asyncio.to_thread(
|
| 177 |
-
|
| 178 |
)
|
| 179 |
sess.set_seed(seed_used)
|
| 180 |
except Exception as exc:
|
|
|
|
| 25 |
)
|
| 26 |
from server.progress import get_bus
|
| 27 |
from server.registry import Registry
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
STATIC_DIR = Path(__file__).parent / "static"
|
|
|
|
| 168 |
tmp.close()
|
| 169 |
ref_path = tmp.name
|
| 170 |
|
|
|
|
| 171 |
bus = get_bus()
|
| 172 |
try:
|
| 173 |
async with bus.session("single", total_turns=1) as sess:
|
| 174 |
wav_bytes, _sr, seed_used = await asyncio.to_thread(
|
| 175 |
+
adapter.generate, text, ref_path, language, json.loads(params or "{}"),
|
| 176 |
)
|
| 177 |
sess.set_seed(seed_used)
|
| 178 |
except Exception as exc:
|
server/zerogpu.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
"""ZeroGPU decorator shim.
|
| 2 |
-
|
| 3 |
-
When `spaces` is importable (HF ZeroGPU runtime), `decorate` wraps
|
| 4 |
-
functions with `spaces.GPU(duration=...)`. Otherwise it is the
|
| 5 |
-
identity decorator. Local installs and Free CPU Spaces hit the
|
| 6 |
-
no-op branch.
|
| 7 |
-
"""
|
| 8 |
-
from __future__ import annotations
|
| 9 |
-
|
| 10 |
-
from typing import Callable, TypeVar
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
F = TypeVar("F", bound=Callable)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
try: # pragma: no cover — covered by a test that injects a fake module
|
| 17 |
-
import spaces # type: ignore[import-not-found]
|
| 18 |
-
|
| 19 |
-
def decorate(fn: F) -> F:
|
| 20 |
-
return spaces.GPU(duration=120)(fn) # type: ignore[no-any-return]
|
| 21 |
-
|
| 22 |
-
except ImportError: # local / Free CPU
|
| 23 |
-
|
| 24 |
-
def decorate(fn: F) -> F:
|
| 25 |
-
return fn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_zerogpu.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
import sys
|
| 2 |
-
from unittest.mock import MagicMock
|
| 3 |
-
|
| 4 |
-
from server.zerogpu import decorate
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
def test_decorate_is_passthrough_when_spaces_missing(monkeypatch):
|
| 8 |
-
monkeypatch.setitem(sys.modules, "spaces", None)
|
| 9 |
-
|
| 10 |
-
@decorate
|
| 11 |
-
def fn(x):
|
| 12 |
-
return x * 2
|
| 13 |
-
|
| 14 |
-
assert fn(3) == 6
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
def test_decorate_uses_spaces_gpu_when_available(monkeypatch):
|
| 18 |
-
fake_spaces = MagicMock()
|
| 19 |
-
fake_decorator = MagicMock(side_effect=lambda f: f)
|
| 20 |
-
fake_spaces.GPU = MagicMock(return_value=fake_decorator)
|
| 21 |
-
monkeypatch.setitem(sys.modules, "spaces", fake_spaces)
|
| 22 |
-
|
| 23 |
-
import importlib
|
| 24 |
-
import server.zerogpu as zg
|
| 25 |
-
|
| 26 |
-
importlib.reload(zg)
|
| 27 |
-
|
| 28 |
-
@zg.decorate
|
| 29 |
-
def fn(x):
|
| 30 |
-
return x + 1
|
| 31 |
-
|
| 32 |
-
assert fn(2) == 3
|
| 33 |
-
fake_spaces.GPU.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|