From 9c4b712d69b653d525cf5e9f87263e74318066e8 Mon Sep 17 00:00:00 2001 From: Hiago Silva <97215740+Huntterxx@users.noreply.github.com> Date: Sun, 15 Mar 2026 15:10:07 -0300 Subject: [PATCH] style: fix formatting --- src/tts/tts-core.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/tts/tts-core.ts b/src/tts/tts-core.ts index 4ce8681c470..ea449e4fcef 100644 --- a/src/tts/tts-core.ts +++ b/src/tts/tts-core.ts @@ -704,6 +704,10 @@ export async function edgeTTS(params: { }): Promise { 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, @@ -716,18 +720,16 @@ export async function edgeTTS(params: { timeout: config.timeoutMs ?? timeoutMs, }); - if (text && text.trim().length > 0) { - await tts.ttsPromise(text, outputPath); + await tts.ttsPromise(text, outputPath); - let { size } = statSync(outputPath); + let { size } = statSync(outputPath); + + if (size === 0) { + await tts.ttsPromise(text, outputPath); + ({ size } = statSync(outputPath)); if (size === 0) { - await tts.ttsPromise(text, outputPath); - ({ size } = statSync(outputPath)); - - if (size === 0) { - throw new Error("Edge TTS produced empty audio file after retry"); - } + throw new Error("Edge TTS produced empty audio file after retry"); } } }