fix(tts): honor explicit empty voices list in custom-openai probing
extractVoiceNames collapsed an explicit `{ voices: [] }` response to null,
which broke the existing contract of treating an empty list as a valid
"no voices" answer. Distinguish a genuinely empty array (honored as []) from
an array whose items yielded no usable names (unrecognized shape -> null, so
the next endpoint or defaults apply).
This commit is contained in:
parent
ce811f7636
commit
5a0b40658a
1 changed files with 7 additions and 0 deletions
|
|
@ -390,9 +390,16 @@ function extractVoiceNames(payload: unknown): string[] | null {
|
|||
}
|
||||
}
|
||||
}
|
||||
// An explicitly empty list is a valid answer ("this server has no voices");
|
||||
// honor it rather than probing further or falling back to defaults.
|
||||
if (value.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const cleaned = Array.from(
|
||||
new Set(names.map((name) => name.trim()).filter((name) => name.length > 0)),
|
||||
);
|
||||
// The value was an array but yielded no usable names (unrecognized shape);
|
||||
// treat as not-a-voices-list so the next endpoint / defaults can apply.
|
||||
return cleaned.length > 0 ? cleaned : null;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue