Spaces:
Sleeping
Sleeping
Convert to CPU-compatible Space: remove ZeroGPU dependency
Browse files- Remove spaces import and @spaces.GPU decorator from app.py
- Add map_location="cpu" in mtl_tts.py for CPU/MPS device loading
- Fix improperly uncommented optional deps in requirements.txt
- Update README title/description for CPU variant
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- README.md +3 -3
- app.py +0 -2
- requirements.txt +3 -3
- src/chatterbox/mtl_tts.py +5 -2
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: Chatterbox
|
| 3 |
emoji: π
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
|
@@ -7,5 +7,5 @@ sdk: gradio
|
|
| 7 |
sdk_version: 5.29.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
short_description: Chatterbox TTS supporting 23 languages
|
| 11 |
-
---
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Chatterbox Multilingual TTS CPU
|
| 3 |
emoji: π
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
|
|
|
| 7 |
sdk_version: 5.29.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Chatterbox TTS supporting 23 languages (CPU)
|
| 11 |
+
---
|
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import numpy as np
|
|
| 3 |
import torch
|
| 4 |
from src.chatterbox.mtl_tts import ChatterboxMultilingualTTS, SUPPORTED_LANGUAGES
|
| 5 |
import gradio as gr
|
| 6 |
-
import spaces
|
| 7 |
|
| 8 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
print(f"π Running on device: {DEVICE}")
|
|
@@ -176,7 +175,6 @@ def resolve_audio_prompt(language_id: str, provided_path: str | None) -> str | N
|
|
| 176 |
return LANGUAGE_CONFIG.get(language_id, {}).get("audio")
|
| 177 |
|
| 178 |
|
| 179 |
-
@spaces.GPU
|
| 180 |
def generate_tts_audio(
|
| 181 |
text_input: str,
|
| 182 |
language_id: str,
|
|
|
|
| 3 |
import torch
|
| 4 |
from src.chatterbox.mtl_tts import ChatterboxMultilingualTTS, SUPPORTED_LANGUAGES
|
| 5 |
import gradio as gr
|
|
|
|
| 6 |
|
| 7 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
print(f"π Running on device: {DEVICE}")
|
|
|
|
| 175 |
return LANGUAGE_CONFIG.get(language_id, {}).get("audio")
|
| 176 |
|
| 177 |
|
|
|
|
| 178 |
def generate_tts_audio(
|
| 179 |
text_input: str,
|
| 180 |
language_id: str,
|
requirements.txt
CHANGED
|
@@ -13,7 +13,7 @@ safetensors
|
|
| 13 |
|
| 14 |
# Optional language-specific dependencies
|
| 15 |
# Uncomment the ones you need for specific languages:
|
| 16 |
-
spacy_pkuseg # For Chinese text segmentation
|
| 17 |
-
pykakasi>=2.2.0 # For Japanese text processing (Kanji to Hiragana)
|
| 18 |
-
russian-text-stresser @ git+https://github.com/Vuizur/add-stress-to-epub
|
| 19 |
# dicta-onnx>=0.1.0 # For Hebrew diacritization
|
|
|
|
| 13 |
|
| 14 |
# Optional language-specific dependencies
|
| 15 |
# Uncomment the ones you need for specific languages:
|
| 16 |
+
# spacy_pkuseg # For Chinese text segmentation
|
| 17 |
+
# pykakasi>=2.2.0 # For Japanese text processing (Kanji to Hiragana)
|
| 18 |
+
# russian-text-stresser @ git+https://github.com/Vuizur/add-stress-to-epub
|
| 19 |
# dicta-onnx>=0.1.0 # For Hebrew diacritization
|
src/chatterbox/mtl_tts.py
CHANGED
|
@@ -161,9 +161,12 @@ class ChatterboxMultilingualTTS:
|
|
| 161 |
def from_local(cls, ckpt_dir, device) -> 'ChatterboxMultilingualTTS':
|
| 162 |
ckpt_dir = Path(ckpt_dir)
|
| 163 |
|
|
|
|
|
|
|
|
|
|
| 164 |
ve = VoiceEncoder()
|
| 165 |
ve.load_state_dict(
|
| 166 |
-
torch.load(ckpt_dir / "ve.pt", weights_only=True)
|
| 167 |
)
|
| 168 |
ve.to(device).eval()
|
| 169 |
|
|
@@ -176,7 +179,7 @@ class ChatterboxMultilingualTTS:
|
|
| 176 |
|
| 177 |
s3gen = S3Gen()
|
| 178 |
s3gen.load_state_dict(
|
| 179 |
-
torch.load(ckpt_dir / "s3gen.pt", weights_only=True)
|
| 180 |
)
|
| 181 |
s3gen.to(device).eval()
|
| 182 |
|
|
|
|
| 161 |
def from_local(cls, ckpt_dir, device) -> 'ChatterboxMultilingualTTS':
|
| 162 |
ckpt_dir = Path(ckpt_dir)
|
| 163 |
|
| 164 |
+
# Load to CPU first for non-CUDA devices to handle CUDA-saved checkpoints
|
| 165 |
+
map_location = "cpu" if str(device) in ("cpu", "mps") else None
|
| 166 |
+
|
| 167 |
ve = VoiceEncoder()
|
| 168 |
ve.load_state_dict(
|
| 169 |
+
torch.load(ckpt_dir / "ve.pt", weights_only=True, map_location=map_location)
|
| 170 |
)
|
| 171 |
ve.to(device).eval()
|
| 172 |
|
|
|
|
| 179 |
|
| 180 |
s3gen = S3Gen()
|
| 181 |
s3gen.load_state_dict(
|
| 182 |
+
torch.load(ckpt_dir / "s3gen.pt", weights_only=True, map_location=map_location)
|
| 183 |
)
|
| 184 |
s3gen.to(device).eval()
|
| 185 |
|