fix(minimax): normalize tts pitch for api

This commit is contained in:
Peter Steinberger
2026-04-25 04:57:57 +01:00
parent 5d724863bb
commit 978a50a3c5
5 changed files with 22 additions and 4 deletions

View File

@@ -309,7 +309,13 @@ describe("buildMinimaxSpeechProvider", () => {
text: "Test",
cfg: {} as never,
providerConfig: { apiKey: "sk-test" },
providerOverrides: { model: "speech-01-240228", voiceId: "custom_voice", speed: 1.5 },
providerOverrides: {
model: "speech-01-240228",
voiceId: "custom_voice",
speed: 1.5,
vol: 1.5,
pitch: 0.5,
},
target: "audio-file",
timeoutMs: 30000,
});
@@ -318,6 +324,8 @@ describe("buildMinimaxSpeechProvider", () => {
expect(body.model).toBe("speech-01-240228");
expect(body.voice_setting.voice_id).toBe("custom_voice");
expect(body.voice_setting.speed).toBe(1.5);
expect(body.voice_setting.vol).toBe(1.5);
expect(body.voice_setting.pitch).toBe(0);
});
it("throws when API key is missing", async () => {

View File

@@ -24,6 +24,10 @@ export function normalizeMinimaxTtsBaseUrl(baseUrl?: string): string {
return trimmed.replace(/\/+$/, "");
}
function normalizeMinimaxTtsPitch(pitch: number): number {
return Math.trunc(pitch);
}
export async function minimaxTTS(params: {
text: string;
apiKey: string;
@@ -70,7 +74,7 @@ export async function minimaxTTS(params: {
voice_id: voiceId,
speed,
vol,
pitch,
pitch: normalizeMinimaxTtsPitch(pitch),
},
audio_setting: {
format,