Spaces:
Paused
Paused
updating to Soprano-1.1-80M
Browse files
app.py
CHANGED
|
@@ -8,6 +8,36 @@ try:
|
|
| 8 |
import torch # type: ignore
|
| 9 |
except Exception: # pragma: no cover
|
| 10 |
torch = None # type: ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
try:
|
| 12 |
from soprano import SopranoTTS # type: ignore
|
| 13 |
except Exception: # pragma: no cover
|
|
@@ -76,7 +106,7 @@ def soprano_tts(
|
|
| 76 |
|
| 77 |
# --- Gradio UI ---
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
-
gr.HTML("<h1 style='text-align: center;'>Soprano-TTS</h1><p style='text-align: center;'>Powered by Soprano-80M | 32kHz High-Fidelity Audio</p>")
|
| 80 |
|
| 81 |
with gr.Row(variant="panel"):
|
| 82 |
temperature = gr.Slider(
|
|
|
|
| 8 |
import torch # type: ignore
|
| 9 |
except Exception: # pragma: no cover
|
| 10 |
torch = None # type: ignore
|
| 11 |
+
|
| 12 |
+
# Patch soprano's TransformersModel to fix dtype bug in v0.2.0
|
| 13 |
+
# The library incorrectly uses 'dtype=' instead of 'torch_dtype=' in from_pretrained()
|
| 14 |
+
def _patch_soprano_transformers():
|
| 15 |
+
try:
|
| 16 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 17 |
+
import soprano.backends.transformers as soprano_transformers
|
| 18 |
+
|
| 19 |
+
class PatchedTransformersModel(soprano_transformers.BaseModel):
|
| 20 |
+
def __init__(self, device='cuda', model_path=None, **kwargs):
|
| 21 |
+
self.device = device
|
| 22 |
+
model_name_or_path = model_path if model_path else 'ekwek/Soprano-1.1-80M'
|
| 23 |
+
self.model = AutoModelForCausalLM.from_pretrained(
|
| 24 |
+
model_name_or_path,
|
| 25 |
+
torch_dtype=torch.bfloat16 if device == 'cuda' else torch.float32,
|
| 26 |
+
device_map=device
|
| 27 |
+
)
|
| 28 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
| 29 |
+
self.model.eval()
|
| 30 |
+
|
| 31 |
+
# Inherit all other methods from original
|
| 32 |
+
infer = soprano_transformers.TransformersModel.infer
|
| 33 |
+
stream_infer = soprano_transformers.TransformersModel.stream_infer
|
| 34 |
+
|
| 35 |
+
soprano_transformers.TransformersModel = PatchedTransformersModel
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print(f"Warning: Could not patch soprano transformers backend: {e}")
|
| 38 |
+
|
| 39 |
+
_patch_soprano_transformers()
|
| 40 |
+
|
| 41 |
try:
|
| 42 |
from soprano import SopranoTTS # type: ignore
|
| 43 |
except Exception: # pragma: no cover
|
|
|
|
| 106 |
|
| 107 |
# --- Gradio UI ---
|
| 108 |
with gr.Blocks() as demo:
|
| 109 |
+
gr.HTML("<h1 style='text-align: center;'>Soprano-TTS</h1><p style='text-align: center;'>Powered by Soprano-1.1-80M | 32kHz High-Fidelity Audio</p>")
|
| 110 |
|
| 111 |
with gr.Row(variant="panel"):
|
| 112 |
temperature = gr.Slider(
|