feat: added tts model

This commit is contained in:
Shiven Mian 2024-02-03 20:37:09 -08:00
parent 9f1efb5680
commit 50259751d9
1 changed files with 14 additions and 2 deletions

View File

@ -2,5 +2,17 @@
Defines a function which takes text and returns a path to an audio file.
"""
def tts(text):
return path_to_audio
from openai import OpenAI
client = OpenAI()
def tts(text, file_path):
response = client.with_streaming_response.audio.speech.create(
model="tts-1",
voice="alloy",
input=text,
)
response.stream_to_file(file_path)