Spaces:
Sleeping
Sleeping
tempfile
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
4 |
import json
|
|
|
|
|
5 |
|
6 |
|
7 |
OPEN_AI_KEY = os.getenv("OPEN_AI_KEY")
|
@@ -271,12 +273,11 @@ def paragraph_save_and_tts(paragraph_text):
|
|
271 |
input=paragraph_text,
|
272 |
)
|
273 |
|
274 |
-
|
275 |
-
|
276 |
|
277 |
-
#
|
278 |
-
|
279 |
-
audio_file.write(response.data)
|
280 |
|
281 |
# Return the path to the audio file along with the text
|
282 |
return paragraph_text, audio_path
|
|
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
4 |
import json
|
5 |
+
import tempfile
|
6 |
+
|
7 |
|
8 |
|
9 |
OPEN_AI_KEY = os.getenv("OPEN_AI_KEY")
|
|
|
273 |
input=paragraph_text,
|
274 |
)
|
275 |
|
276 |
+
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as temp_file:
|
277 |
+
temp_file.write(response.content)
|
278 |
|
279 |
+
# Get the file path of the temp file
|
280 |
+
audio_path = temp_file.name
|
|
|
281 |
|
282 |
# Return the path to the audio file along with the text
|
283 |
return paragraph_text, audio_path
|