Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

Python based tool to use text to speech to read books or study material quickly.

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Repository files navigation

SpeedReader

Python based tool to use text to speech to read books or study material quickly.

History

In college my now father in law was using a text to speech program and talking about how he can listen to books at 500 WPM and recommended it to me. It was a pivotal point in my education because I realized I could listen & read a document at 500 words per minute and internalize the information. I began to receive better grades and was able to get ‘A’ letter grades on tests composed of 3 months of materials by listening for 2 hours. I later wrote a speed reader for myself that I used for 10 years and now I felt like it was time to write an updated version in python. I suggest trying it at low speeds first, then increasing the speed as you feel comfortable. Start at 200, and increment by 25 each time you use it until you find that your level of understanding is decreasing then take it slower till you reach 500 WPM.

I believe if you are an auditory learning this tool can be massively helpful to you.

Setup

Run Locally Setup

Tested with Python 3.14 (originally developed on 3.7)

install requirements.txt pyttsx3==2.71 due to a bug detailed here: nateshmbhat/pyttsx3#78

Controls

  • Speed — words per minute (spin box, steps of 25; start low, e.g. 200, and work up to 500). Your last speed (100–1000) is saved to config.json as ui.wpm and restored at the next launch.
  • Speech engine — SpeedReader speaks with the Windows OneCore voices by default, which go up to ~840 WPM. The older SAPI voices stop getting faster at ~470 WPM. To switch back to SAPI, set "speech": {"engine": "sapi"} in config.json. If OneCore can't start, SpeedReader falls back to SAPI on its own. OneCore and SAPI voice IDs differ, so after you switch, Agent Voices… enables all voices until you pick again.
  • Voice — pick from the text-to-speech voices installed on your system; the choice applies to both your reading and any AI agent speaking through the MCP server.
  • Agent Voices… — choose which system voices agents are allowed to use (see below). All voices are enabled by default.
  • Light mode / Dark mode — toggles the modern Windows 11 look (sv-ttk), including the title bar. Dark by default; the choice is saved to config.json as ui.theme.
  • Shortcuts… / F1 — a page listing every keyboard shortcut and hidden option (paste & speak, sentence skip, focus mode, tray behaviour…).
  • Pause / Resume (left of Speak) — pause mid-text; Resume picks up at the same word.
  • Resume where you left off — the text and the word you stopped at (Pause, Stop, finishing, or quitting mid-read) are saved to %LOCALAPPDATA%\SpeedReader\session.json; next launch the text is back and Resume continues from that word (Speak starts over). Agent speech never replaces your saved reading.
  • Training checkbox (under Speed) — each time you finish a whole reading, the speed goes up 25 WPM, up to 500, following the advice above; stopped or paused readings don't count. Saved to config.json as ui.train.
  • Double-click a word — start reading from that word.
  • ← / → (while speaking, with the text box focused) — rewind to the start of the sentence (again to go back one more) / skip to the next sentence.
  • Time left — m:ss left in the header, from the remaining words and the current WPM.
  • Ctrl+O — open a .txt/.md file (UTF-8, falls back to Windows-1252). You can also drop a file onto SpeedReader.exe (or pass it as the first argument) to open it.
  • F11 focus mode — hide the text box and settings so only the big current word (and its neighbours) shows; F11 again restores.
  • Update check — at startup SpeedReader asks GitHub Releases for a newer version (one anonymous HTTPS GET, failures ignored); if found, the title says vX.Y available and the bottom-right link becomes Get vX.Y.
  • Shortcuts: Ctrl+B paste & speak (interrupts and clears anything currently playing or queued, including agent speech, then reads the clipboard now), Ctrl+A select all. Agent (MCP) utterances otherwise queue and play in order.
  • Ctrl+Alt+B from any app — system-wide paste & speak, even while SpeedReader is hidden. If another app already owns that hotkey, SpeedReader just skips it.
  • System tray — closing the window hides SpeedReader to the tray (so agents can keep speaking). Tray menu: Show SpeedReader, Read clipboard, Quit (Quit is how you exit). Only one SpeedReader runs at a time: starting it again (taskbar, Start menu, speedreader) just brings the running window back instead of adding another tray icon.
  • Markdown is read as plain words — when the text (yours or an agent's) looks like Markdown, SpeedReader drops the formatting before speaking: # headings, **bold**/*italic*/~~strike~~, inline `code` backticks, list bullets and numbers, - [x] task boxes, > quotes, --- rules and table pipes. Links read their text ([docs](url) → "docs"), images their alt text. Plain text such as 5 * 3 or snake_case is left alone.
  • Junk isn't read character by character — for both your text and agent speech: code blocks → "[code]", links → "[URL]", Windows paths (C:\..., C:/..., \\server\...) → "[file path]", emails → "[email]", GUIDs → "[ID]", hex hashes → "[hash]", any 40+ character token → "[long text]". Plain numbers and words stay as they are.

MCP server (let AI agents speak through SpeedReader)

SpeedReader ships a Model Context Protocol server so an AI agent (e.g. in VS Code) can read text aloud on your machine. It exposes these tools:

  • speak(text, agent?, voice?, rate?) — read text aloud. Omit rate to use the WPM last set in the app; pass the agent you claimed with (or an explicit voice).
  • list_voices() — list the voices the user enabled for agents, with claim status.
  • claim_voice(agent?, voice?) — claim a voice to speak with (see Per-agent voices below).
  • release_voice(agent) — release a claimed voice.
  • stop_speaking() — stop whatever SpeedReader is saying now and drop queued speech.
  • speech_status() — {speaking, pending}: whether agent speech is playing and how many speak calls are in flight.

It runs over stdio: your agent starts it when it needs it, so it works whether or not the SpeedReader window is open. Agent speech uses the speed you last set in the app (ui.wpm, re-read for every sentence). It needs a Python checkout (the EXE can't serve stdio):

  1. pip install -r requirements.txt into the repo's .venv.
  2. Point your agent at it.
    • Claude Code — already wired in .mcp.json:

      "speedreader": {
        "command": "${CLAUDE_PROJECT_DIR:-.}/.venv/Scripts/python.exe",
        "args": ["${CLAUDE_PROJECT_DIR:-.}/mcp_server.py"]
      }
    • VS Code — .vscode/mcp.json:

      {
        "servers": {
          "speedreader": {
            "type": "stdio",
            "command": "${workspaceFolder}/.venv/Scripts/python.exe",
            "args": ["${workspaceFolder}/mcp_server.py"]
          }
        }
      }
    • From another repo, use absolute paths to SpeedReader's .venv\Scripts\python.exe and mcp_server.py.

Agents speak with the installed SAPI voices (up to ~470 WPM). Each agent gets its own server, so voice claims are per agent session.

Per-agent voices (multiple agents, multiple voices)

Use Agent Voices… in the app to enable/disable which installed voices agents may use; the choice is saved to config.json under mcp.voices. The agent handshake is:

  1. (optional) discover — list_voices() shows enabled voices and who holds each.
  2. reserve — claim_voice(agent="my-repo") reserves a voice and returns it. Use a stable identifier (repo folder name or current task). Re-claiming returns the same voice.
  3. speak — speak("hello", agent="my-repo") reads in your reserved voice.
  4. (optional) release — release_voice("my-repo") frees it for others.

Rules:

  • speak requires a reservation: calling it without a reserved agent (or an explicit voice="...") is an error that tells the agent to claim_voice first — unless only one voice is enabled (then it's used automatically).
  • Claims are exclusive while unused voices remain. When every assignable voice is taken, claim_voice requires an agent label and shares another agent's voice (never yours, unless yours is the only voice).

Speech is serialized so each utterance reads in its own voice without bleeding into the next.

Pause agent speech while you're on a call

Set mcp.pause_when_mic_in_use to true in config.json to stop agents talking over you during calls:

{
  "mcp": { "pause_when_mic_in_use": true }
}

When enabled, the speak tool checks whether any app is currently using your microphone (a proxy for "in a call") and, if so, skips speaking and returns a message instead of playing audio. It's off by default, only affects agent/MCP speech (your own reading is never paused), and currently uses Windows microphone state — on other platforms it never pauses.

Media Pause on Speaking

A new setting, mcp.pause_media_when_speaking, controls whether the system should pause media playback (like background music or videos) when SpeedReader is actively speaking. This feature is useful for ensuring that TTS audio is not masked by other sounds playing on the system.

To enable this:

  1. Update your config.json at the repo root to include:

    {
      "mcp": { "pause_media_when_speaking": true }
    }
  2. Restart SpeedReader for the change to take effect.

To run it by hand (it waits for JSON-RPC on stdin): python mcp_server.py.

Convert to EXE

The build uses Nuitka. For background on the bootloader fix: pyinstaller/pyinstaller#3268

.\build.ps1
  • Creates/uses .venv, installs requirements.txt, runs the tests, then builds with the venv's Nuitka (python -m nuitka) — a global nuitka would bundle global packages (e.g. an incompatible mcp 2.x) and the MCP server won't start.
  • Output: SpeedReader.dist\SpeedReader.exe. config.json is copied next to it; the app reads config.json from the working directory first, then from the EXE's folder.
  • The EXE has no console window; errors and server logs go to %TEMP%\SpeedReader.err.txt (and SpeedReader.out.txt), so it also runs from read-only folders like Program Files.
  • Close any running SpeedReader.exe first — the script refuses to build while it locks SpeedReader.dist.
  • The tray icon uses pystray (LGPL-3.0). It is not compiled into the EXE: pystray (and its six dependency) ship as plain, replaceable .py files in SpeedReader.dist\pystray\.

Code signing (Smart App Control)

Windows Smart App Control blocks unsigned EXEs/DLLs. A self-signed certificate does not help — the signature must chain to a Microsoft-trusted CA. The build signs with Azure Artifact Signing (formerly Trusted Signing, ~$10/month) when configured:

  1. In Azure: create an Artifact Signing account, complete identity validation, create a Public Trust certificate profile, and give yourself the … Certificate Profile Signer role on the account.
  2. Install the Azure CLI (winget install -e --id Microsoft.AzureCLI, then open a new terminal) and sign in: az login --tenant <your-tenant> --scope "https://codesigning.azure.net/.default". --tenant is required for personal Microsoft accounts (otherwise AADSTS500200); the build signs with this CLI login.
  3. Set env vars and build:
$env:ARTIFACT_SIGNING_ENDPOINT = "https://eus.codesigning.azure.net"  # your account's region
$env:ARTIFACT_SIGNING_ACCOUNT  = "<account>"
$env:ARTIFACT_SIGNING_PROFILE  = "<certificate profile>"
.\build.ps1
  • Installs the sign dotnet tool if missing, signs every not-yet-signed .exe/.dll/.pyd in SpeedReader.dist, and fails the build if SpeedReader.exe isn't validly signed afterwards.
  • Without the env vars, the build is unsigned and prints a warning.

Release (GitHub + winget)

After a signed .\build.ps1:

python -m tools.release v0.6                # release\SpeedReader-v0.6-win-x64.zip + .sha256 + release\winget\*.yaml
python -m tools.release v0.6 --publish      # ...then gh release create v0.6 (uses release-notes.md)
  • Refuses to package if SpeedReader.exe isn't validly signed; leaves out the local *.err.txt/*.out.txt logs.
  • --publish needs the GitHub CLI (winget install -e --id GitHub.cli, then gh auth login) and should run from master after the release commit is pushed.
  • winget: copy release\winget\*.yaml into a fork of microsoft/winget-pkgs under manifests/c/ChrisLucian/SpeedReader/<version>/ and open a PR (or use wingetcreate submit).

Tests

pip install -r requirements-dev.txt
python -m pytest -q
  • ~230 tests in ~10 s. GUI tests use a hidden window; every real OS side effect (media keys, clipboard, config file, title bar/DPI, microphone registry, browser, MCP server/port, global hotkey, tray icon) is locked by testsupport/locks.py — a test that reaches one without mocking it fails with SideEffectLocked.

Prompt other agents to use your local agent

## Speak via the SpeedReader MCP

A local MCP server named `speedreader` exposes voice tools. Use them to READ
ALOUD every task-completion summary AND every clarifying question you ask me.

Rules (follow exactly):
1. ONCE per session, reserve a voice: call `claim_voice(agent="<this-repo-folder-name>")`.
   Use a stable id (the repo folder name) as `agent` — not a random string.
2. For EVERY summary and EVERY question, call `speak(agent="<same-id>", text="<the message>")`.
   - Keep `text` to the spoken gist (1–3 sentences), not full code or logs.
   - Omit `rate` so it uses the WPM last set in the SpeedReader app.
3. When the task is fully done, call `release_voice(agent="<same-id>")`.
4. If multiple voices exist and you skip `agent`, `speak` errors — always pass `agent`.
   To see/pick a voice, call `list_voices` and optionally `claim_voice(agent=..., voice="<name|id>")`.

If the `speedreader` tools are NOT available, do NOT silently skip speaking —
tell me to register it (stdio: SpeedReader's venv python running `mcp_server.py`,
see SpeedReader's README) so the `speak` tool is reachable, and
continue the task without speaking until it's on.

REPEAT (high-risk, easy to forget): speak the summary AND every question; claim
once, speak with that same agent, release at the end.

About

Python based tool to use text to speech to read books or study material quickly.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages