mirror of https://github.com/openclaw/openclaw.git
Merge 133fb1a300 into c4265a5f16
This commit is contained in:
commit
d683c4e6a4
|
|
@ -703,6 +703,11 @@ export async function edgeTTS(params: {
|
||||||
timeoutMs: number;
|
timeoutMs: number;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const { text, outputPath, config, timeoutMs } = params;
|
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({
|
const tts = new EdgeTTS({
|
||||||
voice: config.voice,
|
voice: config.voice,
|
||||||
lang: config.lang,
|
lang: config.lang,
|
||||||
|
|
@ -714,11 +719,17 @@ export async function edgeTTS(params: {
|
||||||
volume: config.volume,
|
volume: config.volume,
|
||||||
timeout: config.timeoutMs ?? timeoutMs,
|
timeout: config.timeoutMs ?? timeoutMs,
|
||||||
});
|
});
|
||||||
|
|
||||||
await tts.ttsPromise(text, outputPath);
|
await tts.ttsPromise(text, outputPath);
|
||||||
|
|
||||||
const { size } = statSync(outputPath);
|
let { size } = statSync(outputPath);
|
||||||
|
|
||||||
if (size === 0) {
|
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…
Reference in New Issue