Limit voice selection to avoid awkward assignments
This commit is contained in:
+36
-1
@@ -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"]);
|
||||
|
||||
Reference in New Issue
Block a user