Files
openclaw/packages/speech-core/speaker.ts
Vincent Koc 27b15a19e8 refactor(voice): catalog voice models through providers (#87794)
* 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>
2026-05-29 04:46:45 +01:00

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;
}