aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_tts.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-09-02 01:26:09 -0400
committerhistoria <historiavg@proton.me>2026-09-02 01:26:09 -0400
commit8579517a35ef1865fc9b428899d73d52dcb27a14 (patch)
treedba52f8d99cfe4014e0b787367de99f238e5a0db /app/tests/test_tts.py
parent391f50da7a085bec75155c0eb9b47910266058cc (diff)
downloadtts-audiobook-generator-8579517a35ef1865fc9b428899d73d52dcb27a14.tar.gz
feat: sglang backend support
Diffstat (limited to 'app/tests/test_tts.py')
-rw-r--r--app/tests/test_tts.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/tests/test_tts.py b/app/tests/test_tts.py
index 39b407d..7170262 100644
--- a/app/tests/test_tts.py
+++ b/app/tests/test_tts.py
@@ -30,6 +30,7 @@ from converter.clients import (
BACKEND_AUDIOCPP,
BACKEND_FASTER,
BACKEND_QWEN,
+ BACKEND_SGLOMNI,
LANGUAGE_CHOICES,
LANGUAGE_ISO_CODES,
MODEL_SIZE,
@@ -2496,6 +2497,19 @@ class BackendWiringTests(unittest.TestCase):
backend=BACKEND_AUDIOCPP, voice=voice,
instructions=instructions)
+ def _sglomni_converter(self, model="qwen3_tts_1_7b_base", clone=None,
+ instructions=None):
+ from backends.sglomni.catalog import entry_by_key
+ api_url = "http://127.0.0.1:8100"
+ with patch("converter.converter.SgOmniTTSClient") as client:
+ client.return_value.entry = entry_by_key(model)
+ client.return_value.api_url = api_url
+ return AudiobookConverter(
+ voice_mode=VOICE_MODE_CLONE if clone else
+ (VOICE_MODE_DESIGN if instructions else VOICE_MODE_CUSTOM),
+ voice_clone_ref_audio=clone, backend=BACKEND_SGLOMNI,
+ model_id=model, instructions=instructions, api_url=api_url)
+
def test_narrator_tag_uses_faster_voice_name(self):
converter = self._faster_converter(voice="male_richard_poe")
self.assertEqual(converter._narrator_tag(), "male_richard_poe")
@@ -2536,6 +2550,32 @@ class BackendWiringTests(unittest.TestCase):
converter._print_banner()
self.assertIn("higgs_audio_tts", buffer.getvalue())
+ def test_sglomni_banner_prints_model_and_resolves_model_id(self):
+ # Regression: the banner read self.model_id, which __init__ never
+ # stored — every sglomni run crashed there after a good connect.
+ converter = self._sglomni_converter(model="zonos2",
+ clone="voices/ref.wav")
+ self.assertEqual(converter.model_id, "zonos2")
+ buffer = io.StringIO()
+ with redirect_stdout(buffer):
+ converter._print_banner() # must not raise
+ output = buffer.getvalue()
+ self.assertIn("ZONOS2", output)
+ self.assertIn("Zyphra/zonos2", output)
+ self.assertIn("voice cloning from a reference clip", output)
+
+ def test_sglomni_wiring_resolves_and_stores_the_model_key(self):
+ from backends.sglomni.catalog import entry_by_key
+ api_url = "http://127.0.0.1:8100"
+ with patch("converter.converter.SgOmniTTSClient") as client:
+ AudiobookConverter(voice_mode=VOICE_MODE_CLONE,
+ voice_clone_ref_audio="voices/ref.wav",
+ backend=BACKEND_SGLOMNI, model_id="zonos2",
+ api_url=api_url)
+ self.assertEqual(
+ client.call_args.kwargs["model"], "zonos2")
+ self.assertEqual(entry_by_key("zonos2").repo, "Zyphra/zonos2")
+
def test_non_faster_narrator_tag_unchanged(self):
with tempfile.TemporaryDirectory() as tmp:
ref = Path(tmp) / "ref.wav"