Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -14,13 +14,45 @@ subprocess.run(
|
|
| 14 |
)
|
| 15 |
print(f"After pip install: cuda_available={torch.cuda.is_available()}")
|
| 16 |
|
|
|
|
| 17 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 18 |
print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
import gradio as gr
|
| 26 |
|
|
|
|
| 14 |
)
|
| 15 |
print(f"After pip install: cuda_available={torch.cuda.is_available()}")
|
| 16 |
|
| 17 |
+
# Test: just import chatterbox, don't load model
|
| 18 |
from chatterbox_flash import ChatterboxFlashTTS
|
| 19 |
print(f"After chatterbox import: cuda_available={torch.cuda.is_available()}")
|
| 20 |
|
| 21 |
+
# Test: load just the voice encoder (small model)
|
| 22 |
+
from chatterbox.models.ve.model import VoiceEncoder
|
| 23 |
+
from safetensors.torch import load_file
|
| 24 |
+
import tempfile, os as _os
|
| 25 |
+
from huggingface_hub import hf_hub_download
|
| 26 |
+
|
| 27 |
+
print("Downloading ve.safetensors...")
|
| 28 |
+
ve_path = hf_hub_download("ResembleAI/chatterbox-flash", "ve.safetensors")
|
| 29 |
+
ve = VoiceEncoder()
|
| 30 |
+
ve.load_state_dict(load_file(ve_path))
|
| 31 |
+
ve.to("cpu").eval()
|
| 32 |
+
print(f"After ve load: cuda_available={torch.cuda.is_available()}")
|
| 33 |
+
|
| 34 |
+
# Test: load just the t3 model
|
| 35 |
+
from chatterbox_flash.t3 import ChatterboxFlashT3
|
| 36 |
+
print("Downloading t3_flash.safetensors...")
|
| 37 |
+
t3_path = hf_hub_download("ResembleAI/chatterbox-flash", "t3_flash.safetensors")
|
| 38 |
+
t3 = ChatterboxFlashT3(drf_block_size=16)
|
| 39 |
+
t3_state = load_file(t3_path)
|
| 40 |
+
if "model" in t3_state:
|
| 41 |
+
t3_state = t3_state["model"][0]
|
| 42 |
+
t3.load_state_dict(t3_state)
|
| 43 |
+
t3.to(device="cpu", dtype=torch.bfloat16).eval()
|
| 44 |
+
print(f"After t3 load: cuda_available={torch.cuda.is_available()}")
|
| 45 |
+
|
| 46 |
+
# Test: load s3gen
|
| 47 |
+
from chatterbox.models.s3gen.s3gen import S3Gen
|
| 48 |
+
print("Downloading s3gen.safetensors...")
|
| 49 |
+
s3gen_path = hf_hub_download("ResembleAI/chatterbox-flash", "s3gen.safetensors")
|
| 50 |
+
s3gen = S3Gen(meanflow=True)
|
| 51 |
+
s3gen.load_state_dict(load_file(s3gen_path), strict=False)
|
| 52 |
+
s3gen.to("cpu").eval()
|
| 53 |
+
print(f"After s3gen load: cuda_available={torch.cuda.is_available()}")
|
| 54 |
+
|
| 55 |
+
print("All models loaded on CPU. Testing GPU...")
|
| 56 |
|
| 57 |
import gradio as gr
|
| 58 |
|