fix(tts): harden StepFun provider integration

- Validate voice.provider against known whitelist (xiaomi|stepfun) in
  beat-audio route to return a clear 400 instead of falling through
- Move single-char pronouns (他/她) to weak-signal fallback in
  detectGender to avoid false positives on compounds like 其他
- Update .env.example with StepFun configuration examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-09 14:24:27 +08:00
parent 04f22249c9
commit 1a6238f8b8
3 changed files with 28 additions and 10 deletions
+6 -4
View File
@@ -68,14 +68,16 @@ function hashStr(s: string): number {
}
function detectGender(desc: string): "male" | "female" {
// Female signals (broader cast — galgame skews toward female NPCs).
if (/女性|女声|少女|姐姐|妹妹|熟女|御姐|阿姨|奶奶|女孩|姑娘|大妈|女子|女生|女士|她|小姐/.test(desc)) {
if (/女性|女声|少女|姐姐|妹妹|熟女|御姐|阿姨|奶奶|女孩|姑娘|大妈|女子|女生|女士|小姐/.test(desc)) {
return "female";
}
if (/男性|男声|少年|青年|大叔|哥哥|弟弟|男人|男孩|大爷|爷爷|男子|男生|先生|他|公子|师傅/.test(desc)) {
if (/男性|男声|少年|青年|大叔|哥哥|弟弟|男人|男孩|大爷|爷爷|男子|男生|先生|公子|师傅/.test(desc)) {
return "male";
}
// No strong signal: default female (matches the catalog's center of mass).
// Weak signals: single-char pronouns checked last to avoid false positives
// on compound words like "其他" (other) or "她们" (they-fem).
if (/她/.test(desc)) return "female";
if (/他/.test(desc)) return "male";
return "female";
}