Merge 797a721b03f745d044123ae808e7d83992b2eb8b into 9fb78453e088cd7b553d7779faa0de5c83708e70

This commit is contained in:
Hiago Silva 2026-03-20 22:18:56 -07:00 committed by GitHub
commit c8829a54c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -706,6 +706,11 @@ export async function edgeTTS(params: {
timeoutMs: number;
}): Promise<void> {
const { text, outputPath, config, timeoutMs } = params;
if (!text || text.trim().length === 0) {
throw new Error("Edge TTS requires non-empty text");
}
const tts = new EdgeTTS({
voice: config.voice,
lang: config.lang,
@ -717,11 +722,17 @@ export async function edgeTTS(params: {
volume: config.volume,
timeout: config.timeoutMs ?? timeoutMs,
});
await tts.ttsPromise(text, outputPath);
const { size } = statSync(outputPath);
let { size } = statSync(outputPath);
if (size === 0) {
throw new Error("Edge TTS produced empty audio file");
await tts.ttsPromise(text, outputPath);
({ size } = statSync(outputPath));
if (size === 0) {
throw new Error("Edge TTS produced empty audio file after retry");
}
}
}