Skip to content

The open-source AI voice studio. Clone, dictate, create.

fix(tts): run VoiceDesign under inference_mode, coerce legacy designed profile engines on update

jamiepine48a682ed5711
diff --git a/backend/backends/qwen_voice_design_backend.py b/backend/backends/qwen_voice_design_backend.py
index ba02efba..bb6ec768 100644
--- a/backend/backends/qwen_voice_design_backend.py
+++ b/backend/backends/qwen_voice_design_backend.py
@@ -212,11 +212,12 @@ class QwenVoiceDesignBackend:
# state. Forcing offline here (issue #462) regressed online
# users whose libraries issue legitimate metadata lookups
# during generation.
- wavs, sample_rate = self.model.generate_voice_design(
- text=text,
- instruct=combined_instruct,
- language=lang_name.capitalize() if lang_name != "auto" else "Auto",
- )
+ with torch.inference_mode():
+ wavs, sample_rate = self.model.generate_voice_design(
+ text=text,
+ instruct=combined_instruct,
+ language=lang_name.capitalize() if lang_name != "auto" else "Auto",
+ )
return wavs[0], sample_rate
audio, sample_rate = await asyncio.to_thread(_generate_sync)
diff --git a/backend/services/profiles.py b/backend/services/profiles.py
index b5c9622e..778f44c6 100644
--- a/backend/services/profiles.py
+++ b/backend/services/profiles.py
@@ -407,6 +407,10 @@ async def update_profile(
preset_voice_id = getattr(profile, "preset_voice_id", None)
design_prompt = getattr(profile, "design_prompt", None)
default_engine = data.default_engine if data.default_engine is not None else getattr(profile, "default_engine", None)
+ # Designed profiles created before the design engine existed could carry
+ # any default_engine; coerce rather than make the profile uneditable.
+ if voice_type == "designed" and default_engine not in DESIGN_ENGINES:
+ default_engine = DEFAULT_DESIGN_ENGINE
validation_error = _validate_profile_fields(
voice_type=voice_type,
@@ -424,6 +428,8 @@ async def update_profile(
profile.personality = data.personality
if data.default_engine is not None:
profile.default_engine = data.default_engine or None # empty string → NULL
+ if voice_type == "designed":
+ profile.default_engine = default_engine
profile.updated_at = datetime.now(UTC)
db.commit()
diff --git a/backend/tests/test_designed_profiles.py b/backend/tests/test_designed_profiles.py
index 9e1cadd9..177f1a96 100644
--- a/backend/tests/test_designed_profiles.py
+++ b/backend/tests/test_designed_profiles.py
@@ -137,3 +137,21 @@ async def test_backend_layers_instruct_on_design_prompt(monkeypatch):
await backend.generate("Hello.", vp, language="fr", instruct="Whisper it.")
assert calls[-1][1] == f"{DESIGN.rstrip('. ')}. Whisper it."
assert calls[-1][2] == "French"
+
+
+async def test_update_coerces_legacy_designed_profile_engine(test_db, mock_profiles_dir):
+ from backend.database.models import VoiceProfile as DBVoiceProfile
+ from backend.services.profiles import update_profile
+
+ profile = await create_profile(
+ VoiceProfileCreate(name="Legacy", language="en", voice_type="designed", design_prompt=DESIGN),
+ test_db,
+ )
+ row = test_db.query(DBVoiceProfile).filter_by(id=profile.id).first()
+ row.default_engine = "qwen"
+ test_db.commit()
+
+ updated = await update_profile(profile.id, VoiceProfileCreate(name="Renamed", language="en"), test_db)
+ assert updated.name == "Renamed"
+ assert updated.default_engine == DEFAULT_DESIGN_ENGINE