Spaces:
Paused
Paused
Commit ·
94fb797
1
Parent(s): 9df2e8c
fix: remove custom dtype/attn params to fix CUDA assert on T4
Browse filesThe qwen_tts model has internal dtype handling. Passing float16 +
custom attention implementation causes CUDA asserts on T4 (Turing).
Use model defaults which handle GPU compatibility internally.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- app.py +14 -1
- voice_clone.py +7 -24
app.py
CHANGED
|
@@ -730,7 +730,20 @@ with gr.Blocks(title="MomsVoice", css=css_code) as demo:
|
|
| 730 |
import soundfile as sf
|
| 731 |
|
| 732 |
progress(0.1, desc="Extracting speaker embedding from recording...")
|
| 733 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
|
| 735 |
progress(0.7, desc="Generating voice preview...")
|
| 736 |
try:
|
|
|
|
| 730 |
import soundfile as sf
|
| 731 |
|
| 732 |
progress(0.1, desc="Extracting speaker embedding from recording...")
|
| 733 |
+
try:
|
| 734 |
+
profile_id = create_voice_profile(recorder_data, voice_name=v_name.strip())
|
| 735 |
+
except Exception as e:
|
| 736 |
+
import logging, traceback
|
| 737 |
+
logging.getLogger(__name__).exception("Voice cloning failed")
|
| 738 |
+
return (
|
| 739 |
+
f"""<div style="padding: 12px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 12px; font-size: 12px; font-weight: 600;">
|
| 740 |
+
Voice cloning failed: {html.escape(str(e))}
|
| 741 |
+
</div>""",
|
| 742 |
+
gr.HTML(visible=False),
|
| 743 |
+
gr.Audio(visible=False),
|
| 744 |
+
gr.Button(visible=False),
|
| 745 |
+
None,
|
| 746 |
+
)
|
| 747 |
|
| 748 |
progress(0.7, desc="Generating voice preview...")
|
| 749 |
try:
|
voice_clone.py
CHANGED
|
@@ -109,7 +109,7 @@ def _select_attn_impl() -> str:
|
|
| 109 |
|
| 110 |
|
| 111 |
def get_qwen_tts():
|
| 112 |
-
"""Lazy-load Qwen3-TTS model
|
| 113 |
global _qwen_tts_model
|
| 114 |
if _qwen_tts_model is None:
|
| 115 |
with _model_lock:
|
|
@@ -117,23 +117,13 @@ def get_qwen_tts():
|
|
| 117 |
from qwen_tts import Qwen3TTSModel
|
| 118 |
|
| 119 |
model_id = CUSTOM_VOICE_MODEL_ID if _MODEL_MODE == "custom_voice" else BASE_MODEL_ID
|
| 120 |
-
|
| 121 |
-
attn_impl = _select_attn_impl()
|
| 122 |
|
| 123 |
-
logger.info(
|
| 124 |
-
"Loading %s (dtype=%s, attn=%s)...",
|
| 125 |
-
model_id, dtype, attn_impl,
|
| 126 |
-
)
|
| 127 |
_qwen_tts_model = Qwen3TTSModel.from_pretrained(
|
| 128 |
model_id,
|
| 129 |
-
device_map=
|
| 130 |
-
torch_dtype=dtype,
|
| 131 |
-
attn_implementation=attn_impl,
|
| 132 |
)
|
| 133 |
-
|
| 134 |
-
# Attempt torch.compile on decoder/predictor for extra speed
|
| 135 |
-
_try_torch_compile(_qwen_tts_model)
|
| 136 |
-
|
| 137 |
logger.info("Qwen3-TTS loaded (%s mode).", _MODEL_MODE)
|
| 138 |
return _qwen_tts_model
|
| 139 |
|
|
@@ -146,20 +136,13 @@ def get_custom_voice_model():
|
|
| 146 |
if _custom_voice_model is None:
|
| 147 |
from qwen_tts import Qwen3TTSModel
|
| 148 |
|
| 149 |
-
|
| 150 |
-
attn_impl = _select_attn_impl()
|
| 151 |
|
| 152 |
-
logger.info(
|
| 153 |
-
"Loading CustomVoice 0.6B (dtype=%s, attn=%s)...",
|
| 154 |
-
dtype, attn_impl,
|
| 155 |
-
)
|
| 156 |
_custom_voice_model = Qwen3TTSModel.from_pretrained(
|
| 157 |
CUSTOM_VOICE_MODEL_ID,
|
| 158 |
-
device_map=
|
| 159 |
-
torch_dtype=dtype,
|
| 160 |
-
attn_implementation=attn_impl,
|
| 161 |
)
|
| 162 |
-
_try_torch_compile(_custom_voice_model)
|
| 163 |
logger.info("CustomVoice 0.6B loaded.")
|
| 164 |
return _custom_voice_model
|
| 165 |
|
|
|
|
| 109 |
|
| 110 |
|
| 111 |
def get_qwen_tts():
|
| 112 |
+
"""Lazy-load Qwen3-TTS model. Thread-safe."""
|
| 113 |
global _qwen_tts_model
|
| 114 |
if _qwen_tts_model is None:
|
| 115 |
with _model_lock:
|
|
|
|
| 117 |
from qwen_tts import Qwen3TTSModel
|
| 118 |
|
| 119 |
model_id = CUSTOM_VOICE_MODEL_ID if _MODEL_MODE == "custom_voice" else BASE_MODEL_ID
|
| 120 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 121 |
|
| 122 |
+
logger.info("Loading %s on %s...", model_id, device)
|
|
|
|
|
|
|
|
|
|
| 123 |
_qwen_tts_model = Qwen3TTSModel.from_pretrained(
|
| 124 |
model_id,
|
| 125 |
+
device_map=device,
|
|
|
|
|
|
|
| 126 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
logger.info("Qwen3-TTS loaded (%s mode).", _MODEL_MODE)
|
| 128 |
return _qwen_tts_model
|
| 129 |
|
|
|
|
| 136 |
if _custom_voice_model is None:
|
| 137 |
from qwen_tts import Qwen3TTSModel
|
| 138 |
|
| 139 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 140 |
|
| 141 |
+
logger.info("Loading CustomVoice 0.6B on %s...", device)
|
|
|
|
|
|
|
|
|
|
| 142 |
_custom_voice_model = Qwen3TTSModel.from_pretrained(
|
| 143 |
CUSTOM_VOICE_MODEL_ID,
|
| 144 |
+
device_map=device,
|
|
|
|
|
|
|
| 145 |
)
|
|
|
|
| 146 |
logger.info("CustomVoice 0.6B loaded.")
|
| 147 |
return _custom_voice_model
|
| 148 |
|