Merge pull request #57 from zonghaoyuan/feat/tts-stepfun-provider

feat(tts): add StepFun preset-voice provider, route by URL + voice tag
This commit is contained in:
Zonghao Yuan
2026-06-09 14:28:36 +08:00
committed by GitHub
9 changed files with 284 additions and 16 deletions
+11 -2
View File
@@ -13,9 +13,18 @@ export async function POST(req: Request) {
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
}
if (!body.beat?.id || !body.beat?.line || !body.voice?.referenceAudioBase64) {
// Accept either provider's voice shape — xiaomi carries referenceAudioBase64,
// stepfun carries voiceId. We only check the discriminator + the line text;
// shape-specific validation lives in each provider's synth function.
const VALID_TTS_PROVIDERS = ["xiaomi", "stepfun"];
if (
!body.beat?.id ||
!body.beat?.line ||
!body.voice?.provider ||
!VALID_TTS_PROVIDERS.includes(body.voice.provider)
) {
return NextResponse.json(
{ error: "beat.id, beat.line and voice.referenceAudioBase64 are required" },
{ error: "beat.id, beat.line and voice.provider (xiaomi|stepfun) are required" },
{ status: 400 },
);
}
+1 -1
View File
@@ -525,7 +525,7 @@ async function resolveByoVoice(
return ready;
}
if (!speaker.voiceDescription) return null;
const p = provisionVoice(cfg, speaker.voiceDescription);
const p = provisionVoice(cfg, speaker.voiceDescription, speaker.name);
cache.set(speaker.name, p);
try {
return await p;