improve: add empty-text guard and retry for Edge TTS#47232
improve: add empty-text guard and retry for Edge TTS#47232Huntterxx wants to merge 20 commits intoopenclaw:mainfrom
Conversation
Follow-up to PR openclaw#43385 Implements reviewer suggestions: - Add pre-check for empty or whitespace-only text - Retry once if Edge TTS produces a zero-byte file - Include file size in error message for debugging
Greptile SummaryThis PR improves robustness of Edge TTS by adding an empty/whitespace-only text guard and a single retry when the output file is zero bytes. The changes are minimal and well-scoped, but there are two issues worth addressing before merging.
Confidence Score: 3/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/tts/tts-core.ts
Line: 707-722
Comment:
**Empty-text guard placed after `EdgeTTS` construction**
The empty-text guard (line 720) is checked *after* `new EdgeTTS(...)` is already instantiated (lines 707–717). If constructing `EdgeTTS` allocates resources, opens connections, or has any other side effects, those happen before the guard can short-circuit. The guard should be the very first thing in the function body to prevent unnecessary initialization.
```suggestion
const { text, outputPath, config, timeoutMs } = params;
if (!text || text.trim().length === 0) {
throw new Error("TTS text cannot be empty");
}
const tts = new EdgeTTS({
voice: config.voice,
lang: config.lang,
outputFormat: config.outputFormat,
saveSubtitles: config.saveSubtitles,
proxy: config.proxy,
rate: config.rate,
pitch: config.pitch,
volume: config.volume,
timeout: config.timeoutMs ?? timeoutMs,
});
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/tts/tts-core.ts
Line: 734
Comment:
**`size` in error message is always `0`**
The PR description states the goal is to "include file size in error message for debugging," but `size` at this point is always `0` — we only reach this line inside a branch guarded by `if (size === 0)`. The interpolated value provides no additional diagnostic information beyond what the phrase "empty audio file" already conveys.
If the intent is future-proofing for a condition where the file is non-zero but suspiciously small, that threshold should be made explicit. Otherwise, the `(size=0)` suffix can be dropped to keep the message clean.
```suggestion
throw new Error("Edge TTS produced empty audio file after retry");
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: e179a32 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7fdf9716c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
To use Codex here, create an environment for this repo. |
|
@BunsDev This pull request is ready for review and merge. All changes have been completed, tested, and no errors were found. Please let me know if any adjustments are needed. |
|
Maintainer review update against current The underlying robustness gap still exists, but the implementation target has moved. Current main has Microsoft/Edge TTS in Current source evidence:
Minimal good rebase:
So: valid fix idea, but needs a rebase onto the Microsoft speech plugin layout before we should merge it. |
|
Thanks @Huntterxx. I ported the useful part of this PR to the current Microsoft provider path and landed it on The shipped fix is in
Validation: |
Follow-up to PR #43385
Implements reviewer suggestions:
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Improves robustness of Edge TTS.
Empty or whitespace-only text now fails fast instead of invoking TTS.
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
Verified empty-text guard throws before invoking TTS.
Verified retry executes when zero-byte file is produced.
Verified error includes file size when failure persists.
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.