Spaces:
Runtime error
Runtime error
File size: 330 Bytes
d3f638a 26dc945 d3f638a 26dc945 d3f638a 3a94722 d3f638a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# tts.py
import openai
import os
openai.api_key = os.getenv("OPENAI_API_KEY")
def generate_voice(text):
speech_file_path = "output.mp3"
response = openai.audio.speech.create(
model="tts-1",
voice="nova",
input=text,
)
response.stream_to_file(speech_file_path)
return speech_file_path
|