feat(voice): implement local S2S responsiveness candidate and direct TTS routing
Add local S2S responsiveness candidate pinning ASR options and sentence-at-a-time generation. Route speech synthesis directly to OpenAI API for fluent Persian phonetics with gpt-4o-mini-tts-2025-12-15. Add responsiveness, budget carry, and browser watch unit tests along with acceptance benchmarks and evaluation evidence.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""The Windows handoff supervisor must fail closed and stop only its engine."""
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def watcher(tmp_path,monkeypatch):
|
||||
spec=importlib.util.spec_from_file_location('windows_watch',Path(__file__).parents[2]/'docs/evaluation/local-s2s/watch-windows-browser.py')
|
||||
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
||||
monkeypatch.setattr(m,'EVIDENCE',tmp_path)
|
||||
monkeypatch.setattr(m,'REPORT',tmp_path/'report.json')
|
||||
monkeypatch.setattr(m,'available',lambda:4*1024**3)
|
||||
monkeypatch.setattr(m,'vm_available',lambda:6*1024**3)
|
||||
monkeypatch.setattr(m.signal,'signal',lambda *args:None)
|
||||
calls=[]
|
||||
monkeypatch.setattr(m.subprocess,'run',lambda command,**kwargs:calls.append(command))
|
||||
return m,calls
|
||||
|
||||
def test_existing_ledger_never_restarts(watcher):
|
||||
m,calls=watcher;(m.EVIDENCE/'browser-paid-ledger.json').write_text('{}')
|
||||
with pytest.raises(SystemExit):m.main()
|
||||
assert calls==[]
|
||||
|
||||
def test_low_memory_makes_no_launch(watcher,monkeypatch):
|
||||
m,calls=watcher;monkeypatch.setattr(m,'available',lambda:1024**3)
|
||||
with pytest.raises(SystemExit):m.main(enforce_memory=True)
|
||||
assert calls==[]
|
||||
assert json.loads(m.REPORT.read_text())['reason']=='prestart_memory'
|
||||
|
||||
@pytest.mark.parametrize('reason',['memory_floor','handoff_expired_30_minutes'])
|
||||
def test_runtime_guard_stops_only_owned_engine(watcher,monkeypatch,reason):
|
||||
m,calls=watcher
|
||||
if reason=='memory_floor':
|
||||
readings=iter([4*1024**3,2*1024**3]);monkeypatch.setattr(m,'available',lambda:next(readings))
|
||||
monkeypatch.setattr(m.time,'monotonic',lambda:0)
|
||||
else:
|
||||
times=iter([0,1801,1801]);monkeypatch.setattr(m.time,'monotonic',lambda:next(times))
|
||||
m.main(enforce_memory=True)
|
||||
assert len(calls)==2
|
||||
assert calls[0][-5:]==['--pull','never','--no-deps','-d','local-s2s-engine']
|
||||
assert calls[1][-4:]==['stop','--timeout','5','local-s2s-engine']
|
||||
assert json.loads(m.REPORT.read_text())['reason']==reason
|
||||
|
||||
|
||||
def test_default_observes_low_memory_without_blocking_or_stopping(watcher,monkeypatch):
|
||||
m,calls=watcher
|
||||
monkeypatch.setattr(m,'available',lambda:1024**3)
|
||||
monkeypatch.setattr(m,'vm_available',lambda:1024**3)
|
||||
times=iter([0,1801,1801]);monkeypatch.setattr(m.time,'monotonic',lambda:next(times))
|
||||
m.main()
|
||||
report=json.loads(m.REPORT.read_text())
|
||||
assert report['memory_enforcement'] is False
|
||||
assert report['reason']=='handoff_expired_30_minutes'
|
||||
assert report['minimum_windows_available_bytes']==1024**3
|
||||
assert len(calls)==2
|
||||
assert calls[0][-1]=='local-s2s-engine'
|
||||
assert calls[1][-4:]==['stop','--timeout','5','local-s2s-engine']
|
||||
Reference in New Issue
Block a user