Spaces:
Running
on
T4
Running
on
T4
knowsuchagency
commited on
Commit
•
331caac
1
Parent(s):
63b6d33
feat: Fix PDF file reading in generate_audio function
Browse files
main.py
CHANGED
@@ -84,8 +84,9 @@ def generate_audio(file: str, openai_api_key: str = None) -> bytes:
|
|
84 |
if not os.getenv("OPENAI_API_KEY", openai_api_key):
|
85 |
raise gr.Error("OpenAI API key is required")
|
86 |
|
87 |
-
|
88 |
-
|
|
|
89 |
|
90 |
llm_output = generate_dialogue(text)
|
91 |
|
|
|
84 |
if not os.getenv("OPENAI_API_KEY", openai_api_key):
|
85 |
raise gr.Error("OpenAI API key is required")
|
86 |
|
87 |
+
with Path(file).open("rb") as f:
|
88 |
+
reader = PdfReader(f)
|
89 |
+
text = "\n\n".join([page.extract_text() for page in reader.pages])
|
90 |
|
91 |
llm_output = generate_dialogue(text)
|
92 |
|