Sidreds06's picture
Initial commit
a3c7b61
raw
history blame
435 Bytes
import openai
client = openai.AsyncOpenAI()
async def synthesize_speech(text: str, voice: str = "alloy") -> bytes:
# Use tts-1 for speed (not tts-1-hd)
tts_resp = await client.audio.speech.create(
model="tts-1", # Faster than tts-1-hd
voice=voice,
input=text,
response_format="mp3", # More efficient than default
speed=1.1 # Slightly faster speech
)
return tts_resp.content