feat(tts): echtes lokales TTS via piper (kein Stub mehr)
PiperTTSProvider ruft das piper-Binary (--output-raw) async auf, liest die native Sample-Rate aus der .onnx.json und resampelt per ffmpeg auf 24000 Hz (Gateway-Norm). Nicht passende Stimmen (z. B. Cloud-Stimme 'Zephyr' aus der Route) fallen auf die konfigurierte Default-Stimme zurueck. Damit ist eine voll-lokale Konstellation (faster-whisper + Ollama + piper) moeglich -> keine API-Kosten, max. Datenschutz. - config: PIPER_BIN/PIPER_VOICES_DIR/PIPER_VOICE/TTS_SAMPLE_RATE (+ .env.example) - dependencies: piper-Factory mit Settings verdrahtet - tests: tests/test_piper_tts.py (offline, Fake-Binary; Resample-Test skippt ohne ffmpeg); e2e/auth-Tests nutzen jetzt einen Stub-TTS statt 'piper' als Pseudo-Stub - docs: README, BEDIENUNGSANLEITUNG (voll-lokal-Beispiel), Architektur-Roadmap Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
84d6ac6e7b
commit
cca423dac3
10 changed files with 269 additions and 15 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
import app.dependencies as deps
|
||||
from app.main import app
|
||||
from app.config import settings
|
||||
|
||||
|
|
@ -67,17 +68,23 @@ def test_tenant_isolation_returns_403(monkeypatch):
|
|||
|
||||
def test_user_prefs_applied_to_route(monkeypatch):
|
||||
_enable_auth(monkeypatch)
|
||||
|
||||
class StubTTS:
|
||||
async def synthesize(self, text, voice=None, audio_format="pcm"):
|
||||
return b""
|
||||
monkeypatch.setitem(deps.TTS_REGISTRY, "stub-tts", lambda s: StubTTS())
|
||||
|
||||
token = _create_user("Pref")
|
||||
auth = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
client.put(
|
||||
"/api/me/prefs",
|
||||
headers=auth,
|
||||
json={"tts_provider": "piper", "output_endpoint": "loopback"},
|
||||
json={"tts_provider": "stub-tts", "output_endpoint": "loopback"},
|
||||
)
|
||||
resp = client.post("/api/speak", headers=auth, json={"text": "hallo"})
|
||||
assert resp.status_code == 200
|
||||
assert resp.headers["X-TTS-Provider"] == "piper"
|
||||
assert resp.headers["X-TTS-Provider"] == "stub-tts"
|
||||
assert resp.headers["X-Output-Endpoint"] == "loopback"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue