Merge branch 'refactor/backend-architecture' into development

This commit is contained in:
yangshilin
2026-03-18 17:18:23 +08:00
parent 2070a03d35
commit 48b70e1350
266 changed files with 12386 additions and 9690 deletions

View File

@@ -0,0 +1,27 @@
"""OpenAI TTS adapter — implements TTSProvider port."""
from io import BytesIO
from openai import OpenAI
class OpenAITTSProvider:
def __init__(self, api_key: str, model: str = "tts-1"):
self._client = OpenAI(api_key=api_key) if api_key else None
self._model = model
async def synthesize(self, text: str, voice: str = "alloy") -> bytes:
if not self._client:
return b""
try:
response = self._client.audio.speech.create(
model=self._model,
voice=voice,
input=text,
)
buf = BytesIO()
for chunk in response.iter_bytes():
buf.write(chunk)
return buf.getvalue()
except Exception:
return b""