Skip to content

Commit

Permalink
feat: Fix PDF file reading in generate_audio function
Browse files Browse the repository at this point in the history
  • Loading branch information
knowsuchagency committed Jun 9, 2024
1 parent 84aff95 commit 1d51479
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def generate_audio(file: str, openai_api_key: str = None) -> bytes:
if not os.getenv("OPENAI_API_KEY", openai_api_key):
raise gr.Error("OpenAI API key is required")

reader = PdfReader(Path(file).open("rb"))
text = "\n\n".join([page.extract_text() for page in reader.pages])
with Path(file).open("rb") as f:
reader = PdfReader(f)
text = "\n\n".join([page.extract_text() for page in reader.pages])

llm_output = generate_dialogue(text)

Expand Down

0 comments on commit 1d51479

Please sign in to comment.