From 50259751d99a802c3f432d7f5461084f3975d39d Mon Sep 17 00:00:00 2001 From: Shiven Mian Date: Sat, 3 Feb 2024 20:37:09 -0800 Subject: [PATCH] feat: added tts model --- OS/01/assistant/tts.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OS/01/assistant/tts.py b/OS/01/assistant/tts.py index 1a1f55c..4117d06 100644 --- a/OS/01/assistant/tts.py +++ b/OS/01/assistant/tts.py @@ -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 \ No newline at end of file +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) + \ No newline at end of file