mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 21:22:57 +00:00
* refactor(providers): catalog voice models * feat(tts): route speech through voice models * refactor(tts): rename speaker selection fields * refactor(tts): mark default speech models * test(tts): type migrated speaker config assertions * refactor(providers): avoid catalog merge map spread * fix(tts): honor voice model fallbacks * refactor(tts): move speech core into package * chore(tts): register speech core knip workspace * fix(tts): show migrated speaker voice in status * fix(tts): satisfy speech core lint * fix(tts): preserve explicit model aliases * test(tts): narrow provider config assertion * test(doctor): allow slow commitments repair check --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
export type SpeakerSelectionConfig = Record<string, unknown>;
|
|
|
|
function readString(value: unknown): string | undefined {
|
|
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
}
|
|
|
|
export function withSpeakerSelectionCompat(
|
|
config: SpeakerSelectionConfig | undefined,
|
|
): SpeakerSelectionConfig {
|
|
const next: SpeakerSelectionConfig = config ? { ...config } : {};
|
|
const speakerVoice = readString(next.speakerVoice);
|
|
const speakerVoiceId = readString(next.speakerVoiceId);
|
|
const voice = readString(next.voice);
|
|
const voiceName = readString(next.voiceName);
|
|
const voiceId = readString(next.voiceId);
|
|
const canonicalVoice = speakerVoice ?? voice ?? voiceName;
|
|
const canonicalVoiceId = speakerVoiceId ?? voiceId;
|
|
if (canonicalVoice) {
|
|
next.speakerVoice = canonicalVoice;
|
|
next.voice = canonicalVoice;
|
|
next.voiceName = canonicalVoice;
|
|
}
|
|
if (canonicalVoiceId) {
|
|
next.speakerVoiceId = canonicalVoiceId;
|
|
next.voiceId = canonicalVoiceId;
|
|
}
|
|
return next;
|
|
}
|
|
|
|
export function withSpeakerSelectionFallbackCompat(
|
|
config: SpeakerSelectionConfig | undefined,
|
|
): SpeakerSelectionConfig {
|
|
const next: SpeakerSelectionConfig = config ? { ...config } : {};
|
|
const speakerVoice = readString(next.speakerVoice);
|
|
const speakerVoiceId = readString(next.speakerVoiceId);
|
|
if (speakerVoice) {
|
|
next.voice ??= speakerVoice;
|
|
next.voiceName ??= speakerVoice;
|
|
}
|
|
if (speakerVoiceId) {
|
|
next.voiceId ??= speakerVoiceId;
|
|
}
|
|
return next;
|
|
}
|