58 lines
1.3 KiB
Python
58 lines
1.3 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."""
|
|
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
|