[PR #5336] [MERGED] Narrator voices on Linux (flite) and macOS (NSSpeechSynthesizer) #6217

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

📋 Pull Request Information

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

Base: main ← Head: narrator/04-mac-linux


📝 Commits (7)

  • 19c2a6f Narrate chat, overlays and the game's messages where vanilla does
  • 93adc09 Port NarratorLinux: flite's cmu_us_kal16 voice on the narrator
  • b309894 Add horizon-ctl narration: the narrator's status and recent messages
  • 0308ba7 Port NarratorMac: NSSpeechSynthesizer on the narrator
  • 7983abb Turn the macOS speech thread's run loop over while it idles
  • 73bdc8e Merge main into #5335
  • 17f988c Merge #5335's main merge into #5336 (main merged, conflicts resolved below)

📊 Changes

24 files changed (+907 additions, -102 deletions)

View changed files

📝 Cargo.lock (+4 -0)
📝 crates/horizon-client-render/src/chat.rs (+34 -4)
📝 crates/horizon-client-render/src/chat_tests.rs (+33 -0)
📝 crates/horizon-client-render/src/tab_list.rs (+44 -1)
📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+3 -0)
📝 crates/horizon-client/src/game.rs (+5 -0)
📝 crates/horizon-client/src/game/control.rs (+10 -0)
📝 crates/horizon-client/src/game/creative_hotbar.rs (+2 -0)
📝 crates/horizon-client/src/game/debug_keys.rs (+7 -2)
📝 crates/horizon-client/src/game/jukebox.rs (+4 -2)
📝 crates/horizon-client/src/game/lan_screen.rs (+15 -12)
📝 crates/horizon-client/src/game/narrator.rs (+35 -0)
📝 crates/horizon-client/src/game/remote.rs (+200 -65)
📝 crates/horizon-client/src/game/scoreboard.rs (+4 -1)
📝 crates/horizon-client/src/game/startup_menu.rs (+3 -0)
📝 crates/horizon-client/src/lan/discovery.rs (+49 -1)
📝 crates/horizon-client/src/multiplayer.rs (+45 -0)
📝 crates/horizon-client/src/title.rs (+8 -0)
📝 crates/horizon-narrator/Cargo.toml (+10 -0)
📝 crates/horizon-narrator/src/speech.rs (+13 -4)

...and 4 more files

📄 Description

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

Part 4 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.

Stacked on #5335 — merge that first; until then this PR also shows its commits.

The narrator now speaks on Linux (with flite installed, as vanilla needs) and macOS, instead of reading "Not Available".

What vanilla does

  • com.mojang.text2speech.NarratorLinux: loads libflite and libflite_cmu_us_kal16 through JNA, splits each message at punctuation and plays the pieces on a "Narrator #0" executor; clear() drops what is queued while the piece playing finishes.
  • com.mojang.text2speech.NarratorMac: NSSpeechSynthesizer with its own queue: a message waits while another is said, an interrupt stops the speech but keeps the queue, clear() empties it, didFinishSpeaking starts the next.

What changed

  • crates/horizon-narrator/src/speech/linux.rs, speech/linux_split.rs: flite loaded at run time (.so or .so.1), vanilla's splitting, the batch counter for clear().
  • crates/horizon-narrator/src/speech/mac.rs: NSSpeechSynthesizer through objc2, vanilla's queue; the speech thread runs its run loop while it idles (every 50 ms) and polls isSpeaking for didFinishSpeaking.
  • speech.rs, Cargo.toml, Cargo.lock: the platform dependencies.

How it was tested

  • cargo test -p horizon-narrator (the Linux splitter's tests run on every platform).
  • cargo clippy -p horizon-narrator --all-targets --target x86_64-unknown-linux-gnu -- -D warnings and the same for aarch64-apple-darwin pass (cross-checked from Windows); the voices themselves have not been heard on Linux or macOS after the rebase: worth a run there (cargo run -p horizon-narrator --example say) before merging.

Known differences from vanilla

  • The macOS backend has no crashed state: a failing synthesizer message would end vanilla's narration for good and raises nothing in Horizon.

🤖 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/5336 **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/04-mac-linux` --- ### 📝 Commits (7) - [`19c2a6f`](https://github.com/horizon-rust/horizon/commit/19c2a6ff82507ef54d26cfb381f8ecc01c9565fb) Narrate chat, overlays and the game's messages where vanilla does - [`93adc09`](https://github.com/horizon-rust/horizon/commit/93adc0997c67723c684c2644f1af349798787c13) Port NarratorLinux: flite's cmu_us_kal16 voice on the narrator - [`b309894`](https://github.com/horizon-rust/horizon/commit/b309894c945d30637be8a347b8ff34a020520f5c) Add horizon-ctl narration: the narrator's status and recent messages - [`0308ba7`](https://github.com/horizon-rust/horizon/commit/0308ba799fdd9fc680c5e9d177a2f98dfd9b259b) Port NarratorMac: NSSpeechSynthesizer on the narrator - [`7983abb`](https://github.com/horizon-rust/horizon/commit/7983abb95e233ec78b05996ded3ffe83bd05ed8e) Turn the macOS speech thread's run loop over while it idles - [`73bdc8e`](https://github.com/horizon-rust/horizon/commit/73bdc8ef5a4229307a8bbc6ae6ba5914865ac9f0) Merge main into #5335 - [`17f988c`](https://github.com/horizon-rust/horizon/commit/17f988c72a6486a6075b8c0f4d26dc0d2f937981) Merge #5335's main merge into #5336 (main merged, conflicts resolved below) ### 📊 Changes **24 files changed** (+907 additions, -102 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+4 -0) 📝 `crates/horizon-client-render/src/chat.rs` (+34 -4) 📝 `crates/horizon-client-render/src/chat_tests.rs` (+33 -0) 📝 `crates/horizon-client-render/src/tab_list.rs` (+44 -1) 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+3 -0) 📝 `crates/horizon-client/src/game.rs` (+5 -0) 📝 `crates/horizon-client/src/game/control.rs` (+10 -0) 📝 `crates/horizon-client/src/game/creative_hotbar.rs` (+2 -0) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+7 -2) 📝 `crates/horizon-client/src/game/jukebox.rs` (+4 -2) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+15 -12) 📝 `crates/horizon-client/src/game/narrator.rs` (+35 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+200 -65) 📝 `crates/horizon-client/src/game/scoreboard.rs` (+4 -1) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+3 -0) 📝 `crates/horizon-client/src/lan/discovery.rs` (+49 -1) 📝 `crates/horizon-client/src/multiplayer.rs` (+45 -0) 📝 `crates/horizon-client/src/title.rs` (+8 -0) 📝 `crates/horizon-narrator/Cargo.toml` (+10 -0) 📝 `crates/horizon-narrator/src/speech.rs` (+13 -4) _...and 4 more files_ </details> ### 📄 Description > 🤖 Opened by leifiyoo's AI agent (Claude), not by leifiyoo. **Part 4 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. Stacked on #5335 — merge that first; until then this PR also shows its commits. The narrator now speaks on Linux (with `flite` installed, as vanilla needs) and macOS, instead of reading "Not Available". ## What vanilla does - `com.mojang.text2speech.NarratorLinux`: loads `libflite` and `libflite_cmu_us_kal16` through JNA, splits each message at punctuation and plays the pieces on a "Narrator #0" executor; `clear()` drops what is queued while the piece playing finishes. - `com.mojang.text2speech.NarratorMac`: `NSSpeechSynthesizer` with its own queue: a message waits while another is said, an interrupt stops the speech but keeps the queue, `clear()` empties it, `didFinishSpeaking` starts the next. ## What changed - `crates/horizon-narrator/src/speech/linux.rs`, `speech/linux_split.rs`: flite loaded at run time (`.so` or `.so.1`), vanilla's splitting, the batch counter for `clear()`. - `crates/horizon-narrator/src/speech/mac.rs`: `NSSpeechSynthesizer` through `objc2`, vanilla's queue; the speech thread runs its run loop while it idles (every 50 ms) and polls `isSpeaking` for `didFinishSpeaking`. - `speech.rs`, `Cargo.toml`, `Cargo.lock`: the platform dependencies. ## How it was tested - `cargo test -p horizon-narrator` (the Linux splitter's tests run on every platform). - `cargo clippy -p horizon-narrator --all-targets --target x86_64-unknown-linux-gnu -- -D warnings` and the same for `aarch64-apple-darwin` pass (cross-checked from Windows); the voices themselves have not been heard on Linux or macOS after the rebase: worth a run there (`cargo run -p horizon-narrator --example say`) before merging. ## Known differences from vanilla - The macOS backend has no `crashed` state: a failing synthesizer message would end vanilla's narration for good and raises nothing in Horizon. 🤖 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:16:01 +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#6217
No description provided.