[PR #5333] [MERGED] Add the narrator crate: GameNarrator, SAPI speech and screen narration state #6215

Closed
opened 2026-11-03 06:15:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5333
Author: @leifiyoo
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: narrator/01-core


📝 Commits (2)

  • 2fd9fe6 Add the narrator crate: GameNarrator, SAPI speech and screen narration state
  • 38ab275 Merge main into #5333 (main's perf_bench, triage-list and launcher-string failures, fixed by #5369 and #5397)

📊 Changes

10 files changed (+1123 additions, -0 deletions)

View changed files

📝 Cargo.lock (+8 -0)
📝 Cargo.toml (+1 -0)
➕ crates/horizon-narrator/Cargo.toml (+17 -0)
➕ crates/horizon-narrator/examples/say.rs (+28 -0)
➕ crates/horizon-narrator/src/lib.rs (+421 -0)
➕ crates/horizon-narrator/src/screen.rs (+417 -0)
➕ crates/horizon-narrator/src/speech.rs (+120 -0)
➕ crates/horizon-narrator/src/speech/linux.rs (+14 -0)
➕ crates/horizon-narrator/src/speech/mac.rs (+14 -0)
➕ crates/horizon-narrator/src/speech/windows.rs (+83 -0)

📄 Description

🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo.

Part 1 of 16 of the narrator series. All 16 PRs have to be merged, in this order, for the narrator to work completely: #5333 → #5334 → #5335 → #5336 → #5337 → #5338 → #5339 → #5340 → #5341 → #5342 → #5343 → #5344 → #5346 → #5347 → #5348 → #5349. Each PR builds on the one before it (stacked branches), so until the previous one is merged this PR's diff also shows its commits; merging only some of them, or out of order, leaves the narrator unfinished.

First of a series of 16 stacked PRs that port vanilla's narrator. This one adds the horizon-narrator crate on its own; nothing in the game uses it yet, so players see no change.

What vanilla does

  • net.minecraft.client.GameNarrator keeps the narrator's NarratorStatus (Off, All, Chat, System) and decides what is said: sayChatQueued, saySystemQueued, saySystemChatQueued, saySystemNow, updateNarratorStatus (clear, then "Narrator : "), isActive, clear, destroy; the toggle toast's keys.
  • com.mojang.text2speech.NarratorWindows speaks through SAPI's SpVoice.
  • net.minecraft.client.gui.narration.ScreenNarrationCollector narrates only what changed since the last run; Screen times the narration (NARRATE_DELAY_*, the suppression after init, afterMouseMove, afterKeyboardAction) and picks the widget (findNarratableWidget).

What changed

  • crates/horizon-narrator/src/lib.rs: GameNarrator's status rules, queued vs. interrupting messages, the status announcement, the toast's text, the last 32 messages (for scripts).
  • crates/horizon-narrator/src/speech.rs, speech/windows.rs: a speech thread of its own so a frame never waits on speech; the SAPI backend. speech/{linux,mac}.rs are "not available" stubs until PR 04.
  • crates/horizon-narrator/src/screen.rs: ScreenNarrationCollector and Screen's timing.
  • crates/horizon-narrator/examples/say.rs: says a line, for trying a backend by hand.
  • HORIZON_NO_AUDIO gives an active but silent narrator for scripted runs.
  • Workspace Cargo.toml / Cargo.lock: the new member (the windows crate's SAPI features).

How it was tested

  • cargo test -p horizon-narrator: status rules (what each status lets through, interrupting vs. queued, the announcement), the collector (only changed entries, by priority), the screen timing.
  • cargo clippy -p horizon-narrator --all-targets clean on Windows; cargo fmt --all --check.

Known differences from vanilla

  • Where text-to-speech can't start, vanilla shows a message box at startup (checkStatus); Horizon logs vanilla's message instead (wired in PR 02).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5333 **Author:** [@leifiyoo](https://github.com/leifiyoo) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `narrator/01-core` --- ### 📝 Commits (2) - [`2fd9fe6`](https://github.com/horizon-rust/horizon/commit/2fd9fe63b4d576f1778c89f2a886edbb9c0772fa) Add the narrator crate: GameNarrator, SAPI speech and screen narration state - [`38ab275`](https://github.com/horizon-rust/horizon/commit/38ab275114d010179755e66f032be84b3aaea254) Merge main into #5333 (main's perf_bench, triage-list and launcher-string failures, fixed by #5369 and #5397) ### 📊 Changes **10 files changed** (+1123 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+8 -0) 📝 `Cargo.toml` (+1 -0) ➕ `crates/horizon-narrator/Cargo.toml` (+17 -0) ➕ `crates/horizon-narrator/examples/say.rs` (+28 -0) ➕ `crates/horizon-narrator/src/lib.rs` (+421 -0) ➕ `crates/horizon-narrator/src/screen.rs` (+417 -0) ➕ `crates/horizon-narrator/src/speech.rs` (+120 -0) ➕ `crates/horizon-narrator/src/speech/linux.rs` (+14 -0) ➕ `crates/horizon-narrator/src/speech/mac.rs` (+14 -0) ➕ `crates/horizon-narrator/src/speech/windows.rs` (+83 -0) </details> ### 📄 Description > 🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo. **Part 1 of 16 of the narrator series.** All 16 PRs have to be merged, in this order, for the narrator to work completely: #5333 → #5334 → #5335 → #5336 → #5337 → #5338 → #5339 → #5340 → #5341 → #5342 → #5343 → #5344 → #5346 → #5347 → #5348 → #5349. Each PR builds on the one before it (stacked branches), so until the previous one is merged this PR's diff also shows its commits; merging only some of them, or out of order, leaves the narrator unfinished. First of a series of 16 stacked PRs that port vanilla's narrator. This one adds the `horizon-narrator` crate on its own; nothing in the game uses it yet, so players see no change. ## What vanilla does - `net.minecraft.client.GameNarrator` keeps the narrator's `NarratorStatus` (Off, All, Chat, System) and decides what is said: `sayChatQueued`, `saySystemQueued`, `saySystemChatQueued`, `saySystemNow`, `updateNarratorStatus` (clear, then "Narrator : <status>"), `isActive`, `clear`, `destroy`; the toggle toast's keys. - `com.mojang.text2speech.NarratorWindows` speaks through SAPI's `SpVoice`. - `net.minecraft.client.gui.narration.ScreenNarrationCollector` narrates only what changed since the last run; `Screen` times the narration (`NARRATE_DELAY_*`, the suppression after `init`, `afterMouseMove`, `afterKeyboardAction`) and picks the widget (`findNarratableWidget`). ## What changed - `crates/horizon-narrator/src/lib.rs`: `GameNarrator`'s status rules, queued vs. interrupting messages, the status announcement, the toast's text, the last 32 messages (for scripts). - `crates/horizon-narrator/src/speech.rs`, `speech/windows.rs`: a speech thread of its own so a frame never waits on speech; the SAPI backend. `speech/{linux,mac}.rs` are "not available" stubs until PR 04. - `crates/horizon-narrator/src/screen.rs`: `ScreenNarrationCollector` and `Screen`'s timing. - `crates/horizon-narrator/examples/say.rs`: says a line, for trying a backend by hand. - `HORIZON_NO_AUDIO` gives an active but silent narrator for scripted runs. - Workspace `Cargo.toml` / `Cargo.lock`: the new member (the `windows` crate's SAPI features). ## How it was tested - `cargo test -p horizon-narrator`: status rules (what each status lets through, interrupting vs. queued, the announcement), the collector (only changed entries, by priority), the screen timing. - `cargo clippy -p horizon-narrator --all-targets` clean on Windows; `cargo fmt --all --check`. ## Known differences from vanilla - Where text-to-speech can't start, vanilla shows a message box at startup (`checkStatus`); Horizon logs vanilla's message instead (wired in PR 02). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6215
No description provided.