Spaces:
Sleeping
Sleeping
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 | |