Page:
Step 7 Open PDF in the Window
Pages
Design da
Design ms
Design
Home da
Home ms
Home
Reflection da
Reflection ms
Reflection
Step 1 Environment da
Step 1 Environment ms
Step 1 Environment
Step 2 Read the PDF da
Step 2 Read the PDF ms
Step 2 Read the PDF
Step 3 Speak with Coqui TTS da
Step 3 Speak with Coqui TTS ms
Step 3 Speak with Coqui TTS
Step 4 Convert and Command Line da
Step 4 Convert and Command Line ms
Step 4 Convert and Command Line
Step 5 Tests and Quality da
Step 5 Tests and Quality ms
Step 5 Tests and Quality
Step 6 Speak Text Window da
Step 6 Speak Text Window ms
Step 6 Speak Text Window
Step 7 Open PDF in the Window da
Step 7 Open PDF in the Window ms
Step 7 Open PDF in the Window
Clone
1
Step 7 Open PDF in the Window
Tirsvad edited this page 2026-11-20 16:43:13 +01:00
Table of Contents
English · Dansk · Bahasa Malaysia
Step 7: Open a PDF in the window
What we did
- We added an Open PDF button and a Stop button to the window. Open PDF shows a file dialog for PDF files, reads the text with
pypdfand speaks it page by page through the speakers. speak_pdf(pdf_path, engine, player, extract_text)is the use case. The text extractor and the file chooser are injected, so the use case never importspypdfor Tkinter and tests pick a file without a dialog.speak_textandspeak_pdfshare one loop,speak_chunks, so the rule "check for Stop, speak a chunk, play it" exists once. Stop ends the speech between two chunks.- A missing, unreadable or empty PDF is shown as a message in the status line, not as a traceback.
pdf-to-audiobook-window
pwsh scripts/gui-test.ps1
- The container test opens
tests/data/sample.pdfthrough a fake file chooser on a virtual display and reaches the status Done (pwsh scripts/gui-test.ps1). The screenshot above comes from it. - One real run spoke the sample PDF through the speakers: 2 chunks, 23 seconds, exit code 0.
What we gained
- Injecting the extractor and the chooser kept the window testable: only the real run needs a dialog and a sound card.
- Sharing one loop between typed text and PDF text meant that Stop worked for both with one change.
pypdfis imported only when a PDF is opened, so the window starts fast and the container needs it only for this test.