Spaces:
Running
on
T4
Running
on
T4
knowsuchagency
commited on
Commit
•
3cf1f43
1
Parent(s):
8729c75
replace gemini with gpt 4o-mini
Browse files
main.py
CHANGED
@@ -60,24 +60,19 @@ def get_mp3(text: str, voice: str, api_key: str = None) -> bytes:
|
|
60 |
return file.getvalue()
|
61 |
|
62 |
|
63 |
-
def generate_audio(
|
64 |
-
file: str,
|
65 |
-
openai_api_key: str = None,
|
66 |
-
gemini_api_key: str = None,
|
67 |
-
) -> bytes:
|
68 |
|
69 |
if not os.getenv("OPENAI_API_KEY", openai_api_key):
|
70 |
raise gr.Error("OpenAI API key is required")
|
71 |
-
|
72 |
-
if not os.getenv("GEMINI_API_KEY", gemini_api_key):
|
73 |
-
raise gr.Error("Gemini API key is required")
|
74 |
|
75 |
with Path(file).open("rb") as f:
|
76 |
reader = PdfReader(f)
|
77 |
text = "\n\n".join([page.extract_text() for page in reader.pages])
|
78 |
|
79 |
@retry(retry=retry_if_exception_type(ValidationError))
|
80 |
-
@llm(
|
|
|
|
|
81 |
def generate_dialogue(text: str) -> Dialogue:
|
82 |
"""
|
83 |
Your task is to take the input text provided and turn it into an engaging, informative podcast dialogue. The input text may be messy or unstructured, as it could come from a variety of sources like PDFs or web pages. Don't worry about the formatting issues or any irrelevant information; your goal is to extract the key points and interesting facts that could be discussed in a podcast.
|
@@ -166,16 +161,12 @@ demo = gr.Interface(
|
|
166 |
label="OpenAI API Key",
|
167 |
visible=not os.getenv("OPENAI_API_KEY"),
|
168 |
),
|
169 |
-
gr.Textbox(
|
170 |
-
label="Gemini API Key",
|
171 |
-
visible=not os.getenv("GEMINI_API_KEY"),
|
172 |
-
),
|
173 |
],
|
174 |
outputs=[
|
175 |
gr.Audio(label="Audio", format="mp3"),
|
176 |
gr.Textbox(label="Transcript"),
|
177 |
],
|
178 |
-
allow_flagging=
|
179 |
clear_btn=None,
|
180 |
head=os.getenv("HEAD", "") + Path("head.html").read_text(),
|
181 |
cache_examples="lazy",
|
|
|
60 |
return file.getvalue()
|
61 |
|
62 |
|
63 |
+
def generate_audio(file: str, openai_api_key: str = None) -> bytes:
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if not os.getenv("OPENAI_API_KEY", openai_api_key):
|
66 |
raise gr.Error("OpenAI API key is required")
|
|
|
|
|
|
|
67 |
|
68 |
with Path(file).open("rb") as f:
|
69 |
reader = PdfReader(f)
|
70 |
text = "\n\n".join([page.extract_text() for page in reader.pages])
|
71 |
|
72 |
@retry(retry=retry_if_exception_type(ValidationError))
|
73 |
+
@llm(
|
74 |
+
model="gpt-4o-mini",
|
75 |
+
)
|
76 |
def generate_dialogue(text: str) -> Dialogue:
|
77 |
"""
|
78 |
Your task is to take the input text provided and turn it into an engaging, informative podcast dialogue. The input text may be messy or unstructured, as it could come from a variety of sources like PDFs or web pages. Don't worry about the formatting issues or any irrelevant information; your goal is to extract the key points and interesting facts that could be discussed in a podcast.
|
|
|
161 |
label="OpenAI API Key",
|
162 |
visible=not os.getenv("OPENAI_API_KEY"),
|
163 |
),
|
|
|
|
|
|
|
|
|
164 |
],
|
165 |
outputs=[
|
166 |
gr.Audio(label="Audio", format="mp3"),
|
167 |
gr.Textbox(label="Transcript"),
|
168 |
],
|
169 |
+
allow_flagging="never",
|
170 |
clear_btn=None,
|
171 |
head=os.getenv("HEAD", "") + Path("head.html").read_text(),
|
172 |
cache_examples="lazy",
|