fix(tts): correct language input handling for Replicate Kokoro model

Adjust language input resolution in TTS generation to ensure Replicate Kokoro
model receives the appropriate language code mapping even when the language
property is absent or falsy. Update tests to cover this scenario and verify
correct input construction.
This commit is contained in:
Richard R 2026-06-06 16:18:40 -06:00
parent 9c685d7590
commit 92df3f907c
2 changed files with 16 additions and 1 deletions

View file

@ -521,7 +521,6 @@ async function addReplicateLanguageInput(
input: Record<string, unknown>,
request: ResolvedServerTTSRequest,
): Promise<Record<string, unknown>> {
if (!request.language) return input;
if (request.model === REPLICATE_KOKORO_82M_VERSIONED_MODEL) {
const languageCode = resolveReplicateKokoroLanguageCode({
language: request.language,
@ -532,6 +531,7 @@ async function addReplicateLanguageInput(
}
return input;
}
if (!request.language) return input;
const languageInput = await resolveReplicateLanguageInput({
provider: 'replicate',
model: request.model as string,

View file

@ -105,5 +105,20 @@ describe('Replicate language schema values', () => {
voice: 'bf_emma',
language_code: 'b',
});
await expect(buildReplicateInput({
text: 'Hello world',
voice: 'af_sarah',
speed: 1,
format: 'mp3',
model: REPLICATE_KOKORO_82M_VERSIONED_MODEL,
provider: 'replicate',
apiKey: 'r8_token',
testNamespace: null,
})).resolves.toEqual({
text: 'Hello world',
voice: 'af_sarah',
language_code: 'a',
});
});
});