Page:
Step 6 Speak Text 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
3
Step 6 Speak Text Window
Tirsvad edited this page 2026-11-20 18:02:47 +01:00
Table of Contents
English · Dansk · Bahasa Malaysia
Step 6: The speak text window
What we did
- We added a small desktop window with a text box and a Speak button. The text is split into chunks, each chunk is spoken by Coqui TTS and played at once through the speakers with
sounddevice. speak_text(text, engine, player)is the use case. The engine and the audio player are ports, so the use case never imports Tkinter, Coqui TTS orsounddevice.- A view model holds the status and the busy flag; the Tkinter view only draws them and speaks on a worker thread so the window stays responsive. An error is shown as a message in the window, not as a traceback.
pdf-to-audiobook-window
pwsh scripts/gui-test.ps1
- Run the window with
pdf-to-audiobook-windoworpython -m pdf_to_audiobook.presentation.window. - The window test runs in a Linux container on a virtual display (
pwsh scripts/gui-test.ps1), so it never takes your mouse or keyboard. The screenshot above comes from that container. - The real sound was checked once on a real output device: Coqui TTS plus
sounddevicespoke a short sentence.
What we gained
- A second port next to the speech port made the playback easy to replace in tests: no test makes a sound.
- A GUI is best tested in a container: the window, its log and its screenshot come back as files.
- Playback is one more dependency, so the decision is recorded in ADR-0002. On Linux the system needs
libportaudio2. - The console stays quiet: the speech library prints phoneme text, warnings and download bars, so the program hides them and shows only its own lines. Add
--verboseto the command or to the window to see the library output again when you diagnose a problem. Real errors are always shown. - The first sound takes several seconds because the voice model loads. The status line now says
Loading voice...during that time, so the window no longer looks frozen. The engine reports the start of the load through one optional callback, and the window connects it to the status in its composition root only.