69 lines
1.8 KiB
Python

"""Pinned Atlas TTS route anchors used by image-patch tests."""
import html as _html
import json
import os
from urllib.request import ProxyHandler, Request, build_opener
class _NoRedirectTtsHandler:
"""Placeholder for the upstream no-redirect opener handler."""
class _Logger:
def exception(self, message):
return None
logger = _Logger()
class _Upstream:
def read(self):
return b"RIFFsynthetic"
def __enter__(self):
return self
def __exit__(self, *exc_info):
return False
def _buffer_tts_audio_response(response):
return response.read()
def _tts_open(req, *, timeout=30, opener_factory=None):
return _Upstream()
def _handle_tts(handler, data, text, rate_str, engine):
# ── ElevenLabs TTS ──────────────────────────────────────────────────
return None
def handle_get(handler, parsed) -> bool:
"""Handle all GET routes. Returns True if handled, False for 404."""
if parsed.path == "/api/settings":
settings = {}
# Inject the running version so the UI badge stays in sync with git tags
# without any manual release step.
try:
from api.updates import AGENT_VERSION, WEBUI_VERSION
settings["webui_version"] = WEBUI_VERSION
settings["agent_version"] = AGENT_VERSION
except Exception:
pass
return j(handler, settings)
return False
def handle_post(handler, parsed) -> bool:
"""Pinned POST route anchors for the Atlas voice patch."""
if parsed.path == "/api/transcribe":
return handle_transcribe(handler)
if parsed.path == "/api/tts":
return _handle_tts(handler, parsed)
return False