feat(voice_loop): --stream-text (Antworttext live am Monitor)

- neuer Flag --stream-text setzt stream:true im /ws/voice-Start-Frame;
  token-Events werden inline ausgegeben (Wort fuer Wort, waehrend die KI generiert)
- mit --stream-audio kombinierbar; bei semantic wird die Live-Zeile abgeschlossen
- Token-Events sind winzig -> Audio-Startzeit praktisch unveraendert (gemessen:
  Text 1. Token lokal ~1 s, Cloud ~3 s; erster Ton wie zuvor)
- Test: /ws/voice mit stream:true liefert token-Events; 66 Tests gruen
- Doku ergaenzt (Optionen + Feature-Hinweis)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-06-17 17:47:11 +02:00
commit 5296459b07
3 changed files with 36 additions and 3 deletions

View file

@ -124,6 +124,18 @@ def test_ws_voice_start_frame_options_are_honored(monkeypatch):
assert ws.receive_json()["type"] == "done"
def test_ws_voice_stream_text_emits_token_events(monkeypatch):
# stream:true im START-Frame -> der Server schickt token-Events (Live-Text).
opts = _install_voice_stubs(monkeypatch)
with client.websocket_connect("/ws/voice") as ws:
ws.send_json({"type": "start", "format": "wav", "stream": True, **opts})
ws.send_bytes(b"PCMDATA")
ws.send_json({"type": "end"})
assert ws.receive_json()["type"] == "transcript"
assert ws.receive_json()["type"] == "ack"
assert ws.receive_json()["type"] == "token" # Antworttext kommt als token-Event(e)
def test_ws_voice_empty_buffer_errors(monkeypatch):
opts = _install_voice_stubs(monkeypatch)
with client.websocket_connect("/ws/voice") as ws: