fix: reject empty TTS text at the schema boundary (Fixes #946)#1303
Open
MushiSenpai wants to merge 1 commit into
Open
fix: reject empty TTS text at the schema boundary (Fixes #946)#1303MushiSenpai wants to merge 1 commit into
MushiSenpai wants to merge 1 commit into
Conversation
ServeTTSRequest.text was an unconstrained `str`, so empty text reached synthesis, produced zero audio segments, and surfaced as an HTTP 500 with a JSON error body (issue fishaudio#946) which a streaming client then writes as a .wav. The sibling AddReferenceRequest.text already constrains min_length=1; apply the same to ServeTTSRequest.text so empty input is rejected with a clean 4xx at the boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Is this a feature or a BUG fix? BUG fix.
Related issue: Fixes #946
Summary
POST /v1/ttsreturns an HTTP 500 with a JSON error body whentextis empty.A client that streams the response then writes that JSON error into a
.wavfile.Root cause is a schema asymmetry in
fish_speech/utils/schema.py:ServeTTSRequest.textwas an unconstrainedstr, so an empty string passesvalidation and flows into synthesis.
TTSInferenceEngine.inferencereports as an error and
tools/server/inference.pyre-raises asHTTPException(INTERNAL_SERVER_ERROR)→ the 500 reported in baize.exceptions.HTTPException: (500, "'No audio generated, please check the input text.'") #946(
"No audio generated, please check the input text.").AddReferenceRequest.textalready constrainsmin_length=1, so the asymmetry is the bug.The fix
Constrain
ServeTTSRequest.textthe same way, so empty input is rejected with aclean 4xx validation error at the request boundary — before any model work:
One line, no behavior change for valid input. Matches the existing
min_length=1on
AddReferenceRequest.textand theField(...)constraint style already used onServeTTSRequest(top_p,temperature,repetition_penalty).Validation
The change is pure pydantic validation (no model weights needed). Importing the
model and constructing it:
text=""ValidationError(clean 4xx)text="hello"Scope
This fixes the empty-string trigger at the schema boundary. The broader
"no segments generated → 500" path (e.g. other degenerate inputs) is a separate,
larger change in
tools/server/inference.pyand is intentionally out of scope here.Disclosure: this fix was drafted with AI assistance (Claude) and reviewed, tested,
and submitted by me. The commit carries a
Co-Authored-Bytrailer.