clean: archive legacy stt/tts/llm services; update ARCHITECTURE.md + README.md to current stack (REST gpt-4o-transcribe, nano, sage, Honcho, incremental TTS, white noise)
Per PLAN item 6. Legacy files moved to archive/legacy-pipeline/.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Text-to-speech via OpenAI TTS API"""
|
||||
|
||||
import logging
|
||||
from openai import AsyncOpenAI
|
||||
from config import settings
|
||||
|
||||
logger = logging.getLogger("kira.tts")
|
||||
|
||||
|
||||
def _get_client() -> AsyncOpenAI:
|
||||
return AsyncOpenAI(api_key=settings.openai_api_key)
|
||||
|
||||
|
||||
async def synthesize_speech(text: str, voice: str = "nova") -> bytes:
|
||||
"""Synthesize text to speech audio bytes.
|
||||
|
||||
Voices available: alloy, echo, fable, nova, shimmer
|
||||
Nova is the warmest female voice — fits Kira's personality.
|
||||
"""
|
||||
try:
|
||||
client = _get_client()
|
||||
resp = await client.audio.speech.create(
|
||||
model="tts-1",
|
||||
voice=voice,
|
||||
input=text,
|
||||
response_format="opus",
|
||||
)
|
||||
return resp.content
|
||||
except Exception as e:
|
||||
logger.error(f"TTS error: {e}")
|
||||
return b""
|
||||
Reference in New Issue
Block a user