Spaces:
Sleeping
Sleeping
File size: 435 Bytes
a3c7b61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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
|