feat: Geräte-TTS, native Stimmen, Favicon, Auth-Gate, UI-Fixes
Web-UI / TTS:
- Geräte-TTS ("📱 Gerät"): Antwort wird on-device vorgelesen (Web Speech
API), Server sendet nur Text (text_only) -> spart Bandbreite/Kosten.
Mobil-Default, geräte-lokale Speicherung, iOS-Autoplay-Freischaltung.
- Vorlese-Symbol (🔊) je Bubble: Hybrid-Replay (Assistent-PCM gecacht,
Eingabe via /api/speak); SVG-Icon mit kontrastreicher Farbe.
- Kombiniertes Sprachmenü (Flex + feste Sprachen) statt separatem Modus-Menü.
- "Neues Gespräch"-Button (frische Session gegen Sprach-Trägheit).
- Dark-Mode: lesbare <option>-Popups (Kontrast-Fix).
- Favicon (SVG + PNG-Fallbacks) aus mund.png.
TTS-Backend:
- Sprache wird an alle TTS-Provider durchgereicht; Piper-Stimme folgt der
Sprache; Chatterbox mehrsprachig + cross-lingual.
- Native Referenz-Stimmen je Sprache (config/voices/<lang>.wav, FLEURS CC-BY),
loudness-normalisiert.
LLM-Sprache:
- Antwort folgt zuverlässig der gewählten Sprache (verstärkte Anweisung +
Erinnerung an der letzten Nutzer-Nachricht gegen History-Trägheit).
Admin / Auth:
- Wörterbuch: alle 8 Sprachen, Zeilen editierbar, alphabetische Sortierung.
- Web-UI hinter Auth-Gate (Redirect auf SSO_LOGIN_URL / 401); Favicons offen.
- Log-Tab: Hinweis, wenn der systemd-Dienst nicht aktiv ist.
- Einstellungen: Hinweis "pro Nutzer überschreibbar" bei Sprache/Modus/Qualität.
Doku (BEDIENUNGSANLEITUNG.md): Geräte-TTS §6.5.0, Fix/Flex §6.6, native
Stimmen §6.5.3, llama.cpp<->Ollama-Wechsel §4.7, Auth/SSO §7.4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
dc8ac80505
commit
878bf785dd
51 changed files with 985 additions and 202 deletions
|
|
@ -70,7 +70,7 @@ def test_user_prefs_applied_to_route(monkeypatch):
|
|||
_enable_auth(monkeypatch)
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b""
|
||||
monkeypatch.setitem(deps.TTS_REGISTRY, "stub-tts", lambda s: StubTTS())
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,15 @@ def test_empty_text_raises(monkeypatch):
|
|||
|
||||
def test_ref_voice_selection():
|
||||
p = ChatterboxTTSProvider("http://x:9999", voice="/default.wav")
|
||||
assert p._ref_voice(None) == "/default.wav"
|
||||
assert p._ref_voice("Zephyr") == "/default.wav" # Cloud-Name -> Default
|
||||
assert p._ref_voice("/custom.wav") == "/custom.wav" # Pfad -> uebernommen
|
||||
assert p._ref_voice(None, "de") == "/default.wav"
|
||||
assert p._ref_voice("Zephyr", "de") == "/default.wav" # Cloud-Name -> Default
|
||||
assert p._ref_voice("/custom.wav", "de") == "/custom.wav" # Pfad -> uebernommen
|
||||
|
||||
|
||||
def test_ref_voice_per_language(tmp_path):
|
||||
# Native Sprach-Referenz gewinnt über die Default-Stimme, fehlt sie -> Default.
|
||||
(tmp_path / "fr.wav").write_bytes(b"RIFF")
|
||||
p = ChatterboxTTSProvider("http://x:9999", voice="/default.wav", voices_dir=str(tmp_path))
|
||||
assert p._ref_voice(None, "fr") == str(tmp_path / "fr.wav") # native fr-Stimme
|
||||
assert p._ref_voice(None, "de") == "/default.wav" # keine de.wav -> Default
|
||||
assert p._ref_voice("/custom.wav", "fr") == "/custom.wav" # expliziter Pfad gewinnt
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ client = TestClient(app)
|
|||
def _stub_tts(monkeypatch, name="stub-tts", audio=b""):
|
||||
"""Registriert einen deterministischen TTS-Stub (kein Netz, kein lokales Binary)."""
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return audio
|
||||
monkeypatch.setitem(deps.TTS_REGISTRY, name, lambda s: StubTTS())
|
||||
return name
|
||||
|
|
@ -63,7 +63,7 @@ def test_chat_per_request_override_and_loopback(monkeypatch):
|
|||
return "Mir geht es gut, danke."
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"AUDIO"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "stub", lambda s: StubLLM())
|
||||
|
|
|
|||
|
|
@ -72,6 +72,37 @@ def test_admin_users_endpoint_gated(forward_auth):
|
|||
|
||||
|
||||
def test_static_index_served():
|
||||
# Auth aus (LAN-Dev) -> anonymer Nutzer -> Seite wird ausgeliefert.
|
||||
r = client.get("/")
|
||||
assert r.status_code == 200
|
||||
assert "Voice Assistant" in r.text
|
||||
|
||||
|
||||
def test_static_index_gated_without_auth(monkeypatch):
|
||||
# Auth an, keine Identitaet -> Seite ist gesperrt (kein Login-URL -> 401).
|
||||
monkeypatch.setattr(settings, "auth_enabled", True)
|
||||
monkeypatch.setattr(settings, "trusted_auth_header", "")
|
||||
monkeypatch.setattr(settings, "trusted_auth_cookie", "")
|
||||
monkeypatch.setattr(settings, "sso_login_url", "")
|
||||
r = client.get("/", follow_redirects=False)
|
||||
assert r.status_code == 401
|
||||
|
||||
|
||||
def test_static_index_redirects_to_sso(monkeypatch):
|
||||
# Auth an, keine Identitaet, Login-URL gesetzt -> Redirect zum SSO-Portal.
|
||||
monkeypatch.setattr(settings, "auth_enabled", True)
|
||||
monkeypatch.setattr(settings, "trusted_auth_header", "")
|
||||
monkeypatch.setattr(settings, "trusted_auth_cookie", "")
|
||||
monkeypatch.setattr(settings, "sso_login_url", "https://linix.de/yunohost/sso/")
|
||||
r = client.get("/", follow_redirects=False)
|
||||
assert r.status_code == 302
|
||||
assert r.headers["location"].startswith("https://linix.de/yunohost/sso/")
|
||||
|
||||
|
||||
def test_health_open_without_auth(monkeypatch):
|
||||
# Health-Check bleibt auch bei aktiver Auth ohne Identitaet erreichbar.
|
||||
monkeypatch.setattr(settings, "auth_enabled", True)
|
||||
monkeypatch.setattr(settings, "trusted_auth_header", "")
|
||||
monkeypatch.setattr(settings, "trusted_auth_cookie", "")
|
||||
r = client.get("/health")
|
||||
assert r.status_code == 200
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ def _install_stubs(monkeypatch, captured):
|
|||
return f"Antwort auf: {text}"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"AUDIO"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "mem", lambda s: MemLLM())
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def _stub_chat(monkeypatch, answer="ok"):
|
|||
return answer
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"A"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "l", lambda s: StubLLM())
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def _install_slow_stream(monkeypatch):
|
|||
yield f"t{i} "
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"A"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "slow", lambda s: SlowLLM())
|
||||
|
|
@ -93,7 +93,7 @@ def _install_voice_stubs(monkeypatch):
|
|||
return "antwort"
|
||||
|
||||
class TTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"A"
|
||||
|
||||
monkeypatch.setitem(deps.STT_REGISTRY, "s", lambda x: STT())
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ def test_config_llm_fallback_applied(monkeypatch):
|
|||
return "rescued"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"A"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "bad", lambda s: BadLLM())
|
||||
|
|
@ -106,7 +106,7 @@ def test_metrics_endpoint_records_requests_and_stages(monkeypatch):
|
|||
return "hi"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"A"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "l", lambda s: StubLLM())
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def _install_streaming(monkeypatch, tokens):
|
|||
yield tok
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"AUD"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "stream", lambda s: StreamLLM())
|
||||
|
|
@ -99,7 +99,7 @@ def test_ws_stream_fallback_for_nonstreaming_llm(monkeypatch):
|
|||
return "komplett"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"X"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "oc", lambda s: OnlyComplete())
|
||||
|
|
@ -126,7 +126,7 @@ def test_ws_audio_stream_sends_chunks_per_sentence(monkeypatch):
|
|||
yield tok
|
||||
|
||||
class CountTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
tts_calls.append(text)
|
||||
return b"A" * len(tts_calls)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ def test_warmup_loads_piper(monkeypatch):
|
|||
calls = {}
|
||||
|
||||
class FakePiperTTSProvider: # Name muss zur Typpruefung im warmup passen
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
calls["tts"] = text
|
||||
return b"AUDIO"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ def _install_stubs(monkeypatch, captured):
|
|||
return f"Echo: {text}"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"WSAUDIO"
|
||||
|
||||
monkeypatch.setitem(deps.LLM_REGISTRY, "mem", lambda s: MemLLM())
|
||||
|
|
@ -78,7 +78,7 @@ def _install_voice_stubs(monkeypatch):
|
|||
return f"Antwort zu {text}"
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm", language=None):
|
||||
return b"VOICEAUD"
|
||||
|
||||
monkeypatch.setitem(deps.STT_REGISTRY, "ss", lambda s: StubSTT())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue