From 561ace944388c1b43090960bec1f4edc35fddc24 Mon Sep 17 00:00:00 2001 From: pleb Date: Tue, 28 Jul 2026 18:08:10 -0700 Subject: [PATCH] Limit voice selection to avoid awkward assignments --- README.md | 6 ++++-- src/kokoro.rs | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index beb57e2..7dcc8c4 100644 --- a/README.md +++ b/README.md @@ -18,12 +18,14 @@ speaker mappings, generated audio, and TTS endpoint stay on your computer. - Watches an EverQuest log without replaying historical lines on startup. - Speaks `Name says, '…'` NPC dialogue by default. - Calls `GET /health`, shows live Kokoro connectivity in the status bar, and - refreshes its selectable voice catalog from `GET /v1/audio/voices`. + refreshes its selectable voice catalog from `GET /v1/audio/voices`. NPC + selection is limited to Mudmouth's curated 27-voice English pool. - Sends non-streaming WAV requests to `POST /v1/audio/speech` and plays clips sequentially with native audio support. - Repeats an NPC's identical line at 1.5x speed, then 2x speed when each repeat arrives within 15 seconds; a later line returns to normal speed. -- Picks a real voice from your Kokoro server for a newly seen NPC and saves it. +- Picks a curated voice available on your Kokoro server for a newly seen NPC + and saves it. - Lets you pin an NPC to a particular voice, reroll a persistent random voice, or set the NPC to get a new random voice for every line. - Can optionally narrate zone entries (`You have entered Lake Rathetear.`). diff --git a/src/kokoro.rs b/src/kokoro.rs index 6c47188..ea10dab 100644 --- a/src/kokoro.rs +++ b/src/kokoro.rs @@ -3,6 +3,40 @@ use reqwest::Url; use serde::{Deserialize, Serialize}; use std::time::Duration; +/// Curated English Kokoro voices used for NPC selection and the voice manager. +/// +/// Keeping this allowlist here means a server update cannot unexpectedly add +/// voices to Mudmouth's random assignment pool. +const NPC_VOICE_ALLOWLIST: &[&str] = &[ + "af_heart", + "af_bella", + "af_nicole", + "af_alloy", + "af_aoede", + "af_kore", + "af_nova", + "af_sarah", + "af_river", + "af_jessica", + "af_sky", + "am_michael", + "am_fenrir", + "am_eric", + "am_echo", + "am_liam", + "am_onyx", + "am_adam", + "am_puck", + "bf_alice", + "bf_emma", + "bf_isabella", + "bf_lily", + "bm_daniel", + "bm_fable", + "bm_george", + "bm_lewis", +]; + #[derive(Clone)] pub struct KokoroClient { client: reqwest::Client, @@ -80,6 +114,7 @@ impl KokoroClient { .into_voices() .into_iter() .map(|voice| voice.id) + .filter(|voice| NPC_VOICE_ALLOWLIST.contains(&voice.as_str())) .collect()) } @@ -136,7 +171,7 @@ mod tests { let url = serve_once( "200 OK", "application/json", - br#"[{"id":"af_heart","name":"Heart"},{"id":"am_adam","name":"Adam"}]"#, + br#"[{"id":"af_heart","name":"Heart"},{"id":"am_adam","name":"Adam"},{"id":"af_onyx","name":"Onyx"}]"#, ); let voices = KokoroClient::new(&url).unwrap().voices().await.unwrap(); assert_eq!(voices, vec!["af_heart", "am_adam"]);