Limit voice selection to avoid awkward assignments
CI / macos-latest (push) Has been cancelled
CI / ubuntu-latest (push) Has been cancelled
CI / windows-latest (push) Has been cancelled

This commit is contained in:
pleb
2026-07-28 18:08:10 -07:00
parent 514fb832c7
commit 561ace9443
2 changed files with 40 additions and 3 deletions
+4 -2
View File
@@ -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.`).
+36 -1
View File
@@ -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"]);