Merge 797a721b03f745d044123ae808e7d83992b2eb8b into 9fb78453e088cd7b553d7779faa0de5c83708e70
This commit is contained in:
commit
c8829a54c3
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user