Skip to content

Studio: say so when the Audio page stops speech at Max tokens - #12583

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:audio-page-cutting-spoken-paragraph
Oct 3, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:audio-page-cutting-spoken-paragraph

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

On the Audio page, text to speech stops when it reaches the Max tokens setting, which sits under Advanced and starts at 2048. On Orpheus TTS 3B that is about 25 seconds of speech, so a paragraph of a hundred words or more comes back cut short and is saved to the gallery as if it were complete. Nothing on the page says the limit was hit, so it looks like the model skipped the rest of the text.

Now the page shows a warning when a clip stopped at Max tokens, and points to the setting under Advanced so the rest can be spoken. Clips that finish on their own look the same as before, and the default is unchanged.

This covers Orpheus in both the safetensors and GGUF versions, and any GGUF speech model, since llama-server already reports when it stopped at the limit. The response from the audio generate route now says "length" instead of "stop" in that case.

Before / after

Audio page with Orpheus 3B GGUF, Max tokens set to 256, speaking a paragraph that needs far more than 256 tokens. Left is the merge base, right is this PR. Both clips stop at 0:03; only the PR says so.

Audio page before and after: the PR shows a warning toast when speech stops at Max tokens

/api/inference/audio/generate finish_reason for the same requests: cut paragraph stop -> length, short sentence stop on both.

@NilayYadav NilayYadav left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review + reproduction evidence

Pinned review: 284d0b2cc0. 2 findings, fixed in d433d7820c and 284d0b2cc0.

I reproduced the Audio page flow on fresh upstream main (Modal Linux, NVIDIA L4, real install.sh --local, password login, Chromium 1440x900): load a TTS model from "Select audio model", set Max tokens under Advanced, paste a 162 word paragraph, press Generate.

  • main faca4e2: Orpheus 3B GGUF at Max tokens 512 returns a 6.14 s clip with finish_reason: "stop" and nothing on the page says it was cut. Same for Orpheus Safetensors (6.14 s) and Spark TTS 0.5B at 256 (5.1 s). A 484 word text at the 8192 ceiling stops at 1:31, also with no notice.
  • PR as submitted 67fa100: Orpheus GGUF and Safetensors now return "length" and show the warning. Spark TTS (BiCodec) and Oute TTS (DAC) Safetensors still returned "stop" with no warning, and at 8192 the toast told the user to raise a field that is already at its maximum.
  • PR head 284d0b2: all four models return "length" with the warning when cut (Spark 5.1 s, Oute 1.32 s, Orpheus 6.14 s); at 8192 the toast says to split the text instead. A 7 word text that ends on its own returns "stop" with no toast on every model, on both sides.

PR 12583 before/after

  • Tests: the new tests fail on main and pass on the PR (3 FIXED); with the two fixes, 7 FIXED and 31 passed, including new BiCodec and DAC cases.
  • Adjacent: /v1/audio/speech returns 200 with audio on both sides, the /audio/generate response keys are unchanged, and model switching across the four models works.
  • Speed: Orpheus GGUF, 512 tokens, 5 runs each: main median 11.93 s (11.65 to 12.96), PR 11.44 s (11.39 to 11.91).
  • Actions A/B on a fork mirror did not get a runner in time (the fork queue was saturated), so CI evidence here is the test differential above; upstream CI on this head is still running.

Conclusion: real silent truncation on the default Audio page path, fixed for Orpheus (GGUF and Safetensors), Spark and Oute. CSM, native and audio.cpp models report nothing, as before.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Codex coverage

Codex does not answer @codex review on this repo, so it reviewed an exact mirror: NilayYadav/unsloth#362. The PR's files on the mirror are byte-identical to 284d0b2cc0; the current head 99aaad6f76 only adds the pre-commit.ci formatting commit on top (inference.py and test_audio_tts_cancellation.py, +6/-2).

  • Round 1 on 67fa10034d (as submitted): one P2, Spark (BiCodec) and Oute (DAC) Safetensors models still cut silently. Reproduced by hand and fixed in d433d7820c.
  • Round 2 on 284d0b2cc0: "Didn't find any major issues."

Status: converged on the reviewed commit.

@danielhanchen

Copy link
Copy Markdown
Member

Review record for #12583, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#336.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror adb8e7f975 (this PR's 99aaad6f7)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: adb8e7f975

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror adb8e7f975 (this PR's 99aaad6f7).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit dccfb69 into unslothai:main Oct 3, 2026
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Oct 3, 2026
audio-page.tsx: main's Max tokens toast (unslothai#12583) now lives in
use-speech-generation, where the stack moved TTS generation. TTS generation
keeps both main's stats_holder and the stack's run inputs.
JoshuaL3000 pushed a commit to JoshuaL3000/unsloth that referenced this pull request Oct 4, 2026
…hai#12583)

* Say so when the Audio page stops speech at Max tokens

* Report the Max tokens cut for Spark and Oute TTS too

* Suggest splitting the text when Max tokens is already at its ceiling

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants