|
|
@ -2,5 +2,17 @@
|
|
|
|
Defines a function which takes text and returns a path to an audio file.
|
|
|
|
Defines a function which takes text and returns a path to an audio file.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def tts(text):
|
|
|
|
from openai import OpenAI
|
|
|
|
return path_to_audio
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|