Skip to content

fix(luxtts): readable error when text is too short for the vocoder - #1199

Open
vincentfranstyo wants to merge 1 commit into
jamiepine:mainfrom
vincentfranstyo:fix/luxtts-short-text
Open

vincentfranstyo wants to merge 1 commit into
jamiepine:mainfrom
vincentfranstyo:fix/luxtts-short-text

Conversation

@vincentfranstyo

Copy link
Copy Markdown

Problem

Generating with LuxTTS on a short input like "This is a test" fails every time with a raw torch error shown in the UI:

RuntimeError: Calculated padded input size per channel: (6). Kernel size: (7). Kernel size can't be greater than actual input size

The text produces too few feature frames for the Vocos vocoder's Conv1d embed layer (kernel size 7).

Fix

In LuxTTSBackend.generate(), catch that specific RuntimeError around generate_speech() and raise a ValueError with a clear message ("Text is too short for LuxTTS. Try a longer sentence or another engine."). The generation service already stores str(e) as the generation error, so this message is what the user sees. Any other RuntimeError is re-raised unchanged.

I went with catching the error rather than a fixed minimum character count, because the frame count depends on the text and the voice prompt, so a hard-coded threshold would either reject valid input or miss some crashes.

Testing

  • Added backend/tests/test_luxtts_short_text.py with a fake model: the kernel-size error becomes a ValueError, and an unrelated RuntimeError still propagates. The first test fails on main and passes with this change.
  • ruff check / ruff format --check clean on the new test.
  • Not tested with the real LuxTTS weights.

Fixes #1046

Very short input produces fewer feature frames than the vocoder's
Conv1d kernel and torch raises a raw padding RuntimeError that the UI
shows as-is. Catch that specific error and raise a ValueError telling
the user to use longer text. Other RuntimeErrors still propagate.
doublesharp added a commit to doublesharp/voicebox-ds that referenced this pull request Oct 29, 2026
Use the shared QueryClient for offline requests, preserve custom server URLs through startup and migration, retain capture decode diagnostics, preserve refinement language, accept supported STT languages, and explain LuxTTS short-input errors. Adapt upstream PRs jamiepine#1208, jamiepine#1204, jamiepine#1219, jamiepine#1218, jamiepine#1198, jamiepine#1199, jamiepine#1220 and jamiepine#1180; retain remote reconnect refreshes and correctly migrate the legacy bundled port.

Wait for the preview output context to resume before playing. Cancel superseded starts and release preview nodes/object URLs on replacement, completion, failure and unmount. Add CI regressions for the upstream integration and preview lifecycle.

Validation: 292 frontend tests on this candidate; 414 frontend tests with the working UI changes; 53 backend tests; app/web/Tauri frontend typechecks and both frontend builds. Independent review accepted the playback change. Native first-click/autoplay, acoustic output, packaging and model quality remain unverified.

Co-authored-by: vincentfranstyo <66989751+vincentfranstyo@users.noreply.github.com>
Co-authored-by: maxazure <405711+maxazure@users.noreply.github.com>
Co-authored-by: FelixKruger <262215022+FelixKruger@users.noreply.github.com>
Co-authored-by: Tony25032 <141424750+Tony25032@users.noreply.github.com>
Co-authored-by: mvoloch <274143174+mvoloch@users.noreply.github.com>
Co-authored-by: Lvigentini <11659311+Lvigentini@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LuxTTS crashes with raw PyTorch RuntimeError on short input text instead of validating

1 participant