mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-15 12:58:04 +00:00
fix: TTS available crashes on non-string tts_provider (#2034)
This commit is contained in:
@@ -68,7 +68,7 @@ class TTSService:
|
|||||||
if provider == "local":
|
if provider == "local":
|
||||||
kokoro = self._get_kokoro()
|
kokoro = self._get_kokoro()
|
||||||
return kokoro is not None and kokoro.available
|
return kokoro is not None and kokoro.available
|
||||||
if provider.startswith("endpoint:"):
|
if isinstance(provider, str) and provider.startswith("endpoint:"):
|
||||||
return True # assume reachable; errors surface at synthesis time
|
return True # assume reachable; errors surface at synthesis time
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from services.tts.tts_service import TTSService
|
||||||
|
|
||||||
|
|
||||||
|
def test_available_tolerates_non_string_provider(tmp_path):
|
||||||
|
"""A hand-edited/corrupt data/settings.json can store a non-string
|
||||||
|
tts_provider (e.g. null or a number). available reads it and calls
|
||||||
|
provider.startswith("endpoint:"), which raised AttributeError on a
|
||||||
|
non-str. It must instead fall through and report unavailable."""
|
||||||
|
service = TTSService(cache_dir=str(tmp_path))
|
||||||
|
service._load_settings = lambda: {
|
||||||
|
"tts_enabled": True,
|
||||||
|
"tts_provider": 123,
|
||||||
|
"tts_model": "tts-1",
|
||||||
|
"tts_voice": "alloy",
|
||||||
|
"tts_speed": "1",
|
||||||
|
}
|
||||||
|
assert service.available is False
|
||||||
Reference in New Issue
Block a user