57 Commits
Author SHA1 Message Date
Nighthawk 611f1022d4 Added additional endpoints, updated Gradio demo. 2026-02-18 01:48:10 -05:00
Nighthawk b0588a0c93 Added initial API code and documentation. 2026-02-18 01:38:09 -05:00
Kedara Studios b8db6ff1ce update README.md: list experimental branch features; GPU-resident repetition penalty and batch compaction 2026-02-12 18:54:48 +01:00
Kedara Studios a757bf2bf0 update README.md -> move to experimental branch 2026-02-12 02:36:47 +01:00
Kedara Studios 81275c6895 Update README.md 2026-02-10 11:21:01 +01:00
Kedara Studios c7b9bc6b76 fix: disable repetition penalty by default for streaming and add windowed penalty
The unbounded repetition penalty was causing sentence repetition by
progressively starving the 2048-token codec vocabulary. Streaming
wrappers now default to repetition_penalty=1.0 (disabled), passed as
an explicit parameter that bypasses _merge_generate_kwargs' 1.05
default. Non-streaming generate_voice_clone() is unaffected.

Also fix decode_padded to pad with -1 instead of 0 (a valid codebook
index), then clamp to >= 0 before decoding, avoiding silent corruption
of the first frames in windowed streaming decode.
2026-02-10 10:45:24 +01:00
Kedara Studios 0cc89f619c fix: apply upstream ConvTranspose padding and audio_lengths fixes
Port two upstream bug fixes:

1. ConvTranspose padding (5f8581d): the chained assignment
   `self.right_pad = pad = self.left_pad` destroyed the original pad
   value, causing symmetric trimming instead of right-only trimming.
   This lost 20 extra samples per decode pass across the 4 decoder
   blocks. Fix: set left_pad=0, right_pad=int(pad).

2. Padding value / audio_lengths (6cafe55): batch padding used value 0,
   but code index 0 is a valid codebook entry. audio_lengths computed
   with `> 0` then incorrectly treated real code-0 tokens as padding,
   truncating audio. Fix: pad with -1, compute lengths with `> -1`,
   then clamp codes to min=0 before decoding.

Upstream commits:
- https://github.com/QwenLM/Qwen3-TTS/commit/5f8581d05e70d2a11c6f0787284eede65f044d98
- https://github.com/QwenLM/Qwen3-TTS/commit/6cafe5582caea83df269c36b1ce62d953a9cc66b
2026-02-09 21:22:57 +01:00
Kedara Studios 233a141057 revert: restore codec levels 1-15 embedding summing in finetuning
Reverts a change we applied from open upstream PR #178 (commit f83f184),
which removed the sub-codebook embedding loop arguing the talker shouldn't
see levels 1-15 during training. Investigation of the inference code
(modeling_qwen3_tts.py:1894-1920) shows the sub-talker generates levels
1-15 before the talker's next step, and all 16 levels are summed into
the input. Omitting them from training creates a train/inference mismatch.
2026-02-09 20:05:23 +01:00
Kedara Studios 32c00eb088 fix: remove double label-shifting in finetuning that caused speech speed-up
The HF ForCausalLMLoss already shifts labels internally, but sft_12hz.py
was also manually shifting before passing to model.talker(), causing
double-shifting and progressively faster audio with more epochs.

Additionally, the sub-talker forward_finetune used ForCausalLMLoss on
already-aligned logits/labels, adding another unwanted shift. Replaced
with direct cross_entropy.

See: https://github.com/QwenLM/Qwen3-TTS/issues/179#issuecomment-3870059313
2026-02-09 19:46:43 +01:00
Kedara Studios a48510a58d refactor: batch GPU decode calls in batch_stream_generate_voice_clone
Restructure the batch streaming loop and flush into a 3-phase approach:
1) collect decode windows for all active items, 2) perform a single
batched GPU decode call, 3) per-item post-processing (crossfade, trim).

Add decode_streaming_batch() to Qwen3TTSTokenizer to support B>1 batch
decoding. Remove examples/test_batch_streaming.py test script.
2026-02-09 01:57:30 +01:00
Kedara Studios dc7a8da2b1 fix: guard chunk trimming against zero blend_samples to prevent full truncation 2026-02-08 19:16:34 +01:00
Kedara Studios 74fd5823c5 fix: guard fade-out against zero blend_samples to prevent full-array fade 2026-02-08 18:43:41 +01:00
Kedara Studios 7e616bbf9f docs: reorder README sections and update repetition_penalty description 2026-02-08 17:45:00 +01:00
Kedara Studios fa20ec2dc3 docs: add batch streaming section to README with usage example
Document the new batch_stream_generate_voice_clone() method including
a usage example showing voice prompt broadcasting, per-item chunk
accumulation, and WAV output. Add entry to the "Added in this fork" list.
2026-02-08 17:36:34 +01:00
rekuenkdr c6d0a2c416 Merge pull request #8 from rekuenkdr/feature/batch-streaming
feat: add batch streaming generation for parallel multi-item TTS
2026-02-08 17:30:24 +01:00
Kedara Studios 117ec6192a feat: add batch streaming generation for parallel multi-item TTS synthesis
Introduce batch streaming methods that process multiple text inputs in a
single batched pass through the transformer, enabling parallel audio
generation with shared KV cache and lockstep frame advancement.

Core model layer (modeling_qwen3_tts.py):
- Add `batch_stream_generate_pcm()` to Qwen3TTSForConditionalGeneration
- Batched prefill and single-step decode with shared KV cache across items
- Per-item state management for codec buffers, crossfade tails, repetition
  penalty tracking, ref_code ICL contexts, and independent EOS detection
- Two-phase streaming support: aggressive first-chunk emission followed by
  stable-phase parameters for balancing latency vs quality
- Windowed decode with per-item Hann fade-in/out and overlap crossfade
- Flush pass to decode remaining frames per item after generation completes

High-level API (qwen3_tts_model.py):
- Add `batch_stream_generate_voice_clone()` to Qwen3TTSModel
- Handles broadcasting of language and voice_clone_prompt to batch size
- Input validation, tokenization, and ref_ids construction per item
- Filters and merges generation kwargs before delegating to core method

Example script (examples/test_batch_streaming.py):
- Demonstrates batch streaming with 3 texts using a shared voice prompt
- Benchmarks batch vs sequential single-item streaming for comparison
- Saves per-item WAV outputs with timing and size reporting
2026-02-08 17:23:39 +01:00
rekuenkdr 1275736834 Merge pull request #7 from rekuenkdr/fix/repetition-penalty-and-finetune-fixes
docs: add repetition_penalty param to README with streaming context
2026-02-07 10:42:41 +01:00
rekuenkdr f88566ac7e Merge branch 'main' into fix/repetition-penalty-and-finetune-fixes 2026-02-07 10:42:24 +01:00
Kedara Studios a3f95c5e65 docs: add repetition_penalty param to README with streaming context 2026-02-07 10:36:34 +01:00
rekuenkdr cecfe01b67 Merge pull request #6 from rekuenkdr/fix/repetition-penalty-and-finetune-fixes
chore: relax transformers and accelerate version pins to >= minimum
2026-02-06 16:33:30 +01:00
Kedara Studios 837960761b chore: relax transformers and accelerate version pins to >= minimum 2026-02-06 16:31:24 +01:00
rekuenkdr 1a067a0cc6 Merge pull request #5 from rekuenkdr/fix/repetition-penalty-and-finetune-fixes
fix: add repetition penalty to streaming and sync upstream finetuning



Streaming inference (voice clone) - repetition penalty:

Without repetition penalty, the model can fall into a degenerate state where it keeps sampling the same codec tokens over and over. This manifests as:

    Looping audio: the same syllable or sound fragment repeats endlessly
    Extremely long generation: instead of reaching EOS in ~200-500 frames, it runs for thousands of frames (up to max_frames=10000)
    Apparent "slowness": a response that should take ~1s of audio takes 10-30s to generate

The fix works by tracking previously generated first-codebook token IDs and penalizing them before sampling:

    Tokens with positive logits get divided by repetition_penalty (lowering their probability)
    Tokens with negative logits get multiplied by it (pushing them further down)

This nudges the model away from re-selecting the same tokens, so it progresses through the text naturally and reaches EOS in a reasonable number of steps rather than looping. Default is 1.0 (disabled) and is exposed through the supported_params whitelist in
stream_generate_voice_clone() so it can be set via generate_config or user kwargs.

Upstream sync (QwenLM/Qwen3-TTS):

    Bump version 0.0.4 -> 0.1.1 to match upstream release.
    finetuning/sft_12hz.py: weight sub-talker loss by 0.3 factor to prevent the code predictor gradient from dominating the main talker loss during SFT.
    finetuning/sft_12hz.py: remove sub-codebook embedding accumulation loop (codec groups 1-15) from input embeddings, unnecessary and harmful for finetuning convergence (upstream PR Resolve each training epoch resulting in progressively faster output QwenLM/Qwen3-TTS#178).
    finetuning/README.md: update recommended hyperparameters to batch_size=32, lr=2e-6, num_epochs=10 for more stable training.
2026-02-06 16:26:41 +01:00
Kedara Studios f83f18439d fix: add repetition penalty to streaming and sync upstream finetuning
Streaming inference (voice clone) - repetition penalty:

Without repetition penalty, the model can fall into a degenerate state
where it keeps sampling the same codec tokens over and over. This
manifests as:
- Looping audio: the same syllable or sound fragment repeats endlessly
- Extremely long generation: instead of reaching EOS in ~200-500 frames,
  it runs for thousands of frames (up to max_frames=10000)
- Apparent "slowness": a response that should take ~1s of audio takes
  10-30s to generate

The fix works by tracking previously generated first-codebook token IDs
and penalizing them before sampling:
- Tokens with positive logits get divided by repetition_penalty (lowering
  their probability)
- Tokens with negative logits get multiplied by it (pushing them further
  down)

This nudges the model away from re-selecting the same tokens, so it
progresses through the text naturally and reaches EOS in a reasonable
number of steps rather than looping. Default is 1.0 (disabled) and is
exposed through the supported_params whitelist in
stream_generate_voice_clone() so it can be set via generate_config or
user kwargs.

Upstream sync (QwenLM/Qwen3-TTS):
- Bump version 0.0.4 -> 0.1.1 to match upstream release.
- finetuning/sft_12hz.py: weight sub-talker loss by 0.3 factor to
  prevent the code predictor gradient from dominating the main talker
  loss during SFT.
- finetuning/sft_12hz.py: remove sub-codebook embedding accumulation
  loop (codec groups 1-15) from input embeddings, unnecessary and
  harmful for finetuning convergence (upstream PR #178).
- finetuning/README.md: update recommended hyperparameters to
  batch_size=32, lr=2e-6, num_epochs=10 for more stable training.
2026-02-06 16:25:05 +01:00
rekuenkdr 97da215d4d Merge pull request #4 from rekuenkdr/fix/audio-crossfade-fixes
fix: handle multiple EOS tokens for generation termination
Add support for multiple EOS tokens that can terminate TTS generation, rather than just checking for a single codec EOS token. This handles different EOS tokens the model might emit (codec EOS, TTS special tokens, endoftext, etc.) in order to avoid the issues with the 0.6B model.
2026-02-04 19:38:18 +01:00
Kedara Studios 3640831a47 fix: handle multiple EOS tokens for generation termination 2026-02-04 19:34:58 +01:00
rekuenkdr d9724dd494 Merge pull request #3 from rekuenkdr/fix/audio-crossfade-fixes
feat(audio): make overlap_samples fully configurable
2026-02-03 08:56:13 +01:00
Kedara Studios 909e1089be feat(audio): make overlap_samples fully configurable
Allow users to set any overlap_samples value including 0 to disable
crossfade blending entirely. Renamed MIN_BLEND_SAMPLES to
DEFAULT_BLEND_SAMPLES and removed the enforced minimum.
2026-02-03 08:48:13 +01:00
rekuenkdr ec5c320a41 Merge pull request #2 from rekuenkdr/fix/audio-crossfade-fixes
fix(audio): Hann window crossfade and boundary click prevention
2026-02-02 23:39:15 +01:00
Kedara Studios 96137074c8 fix(audio): Hann window crossfade and boundary click prevention
- Replace linear crossfade with Hann window for smoother transitions
- Add MIN_BLEND_SAMPLES (512) as floor for blend region
- Add Hann fade-in on first chunk to prevent startup pop
- Add Hann fade-out on final chunk to prevent ending pop
- Trim chunk tails before emission to prevent echo artifacts
- Update README with audio quality fixes documentation
2026-02-02 23:38:16 +01:00
rekuenkdr 92aaeac93c Merge pull request #1 from rekuenkdr/feature/two-phase-emit
feat: add two-phase streaming for reduced first-chunk latency
2026-02-02 20:29:27 +01:00
Kedara Studios 7bf2c43a2e feat: add two-phase streaming for reduced first-chunk latency
- Phase 1: aggressive emit/decode settings for fast first chunk
- Phase 2: stable settings with optimized decode for quality
- New parameters: first_chunk_emit_every, first_chunk_decode_window, first_chunk_frames
- Phase 1 disables torch.compile to allow flexible window sizes
2026-02-02 20:27:15 +01:00
dffdeeq 01b51f0cb1 README update 2026-01-28 02:26:50 +04:00
Andrew 8c533a60e0 Merge pull request #3 from dffdeeq/fix/streaming-startup-artifacts
fix(streaming): add ref_code context for stable first chunks
2026-01-27 19:49:39 +04:00
dffdeeq b7f12c4941 fix(streaming): add ref_code context for stable first chunks 2026-01-27 19:14:52 +04:00
dffdeeq 990bfa2766 Revert upstream changes that broke inference speed 2026-01-27 11:18:11 +04:00
dffdeeq e5662324c6 minor 2026-01-26 23:24:18 +04:00
Andrew 66f26eb640 Merge pull request #2 from dffdeeq/feature/inference-speed-up
reference changed
2026-01-26 23:17:05 +04:00
Andrew ee3bf7a862 Merge branch 'main' into feature/inference-speed-up 2026-01-26 23:16:53 +04:00
dffdeeq b5a75200d9 reference changed 2026-01-26 23:14:50 +04:00
Andrew 648b7100bd benchmarks update
Fixed formatting issues and improved clarity in the README.
2026-01-26 17:54:30 +04:00
Andrew 45d455dd3f Merge pull request #1 from dffdeeq/feature/inference-speed-up
Feature/inference speed up
2026-01-26 16:57:34 +04:00
dffdeeq f2ae2b039c no streaming optimization 2026-01-26 15:52:39 +04:00
dffdeeq d8488d2727 ,,, 2026-01-26 06:16:51 +04:00
Andrew e03d44f3f4 README.md update 2026-01-25 23:45:27 +04:00
Andrew d7fd4bb1ae Update language and text for voice cloning example 2026-01-25 23:33:58 +04:00
Andrew ec708743ea Merge branch 'QwenLM:main' into main 2026-01-25 23:26:36 +04:00
Xiong Wang 1ab0dd7535 update: update readme 2026-01-26 00:11:02 +08:00
Xiong Wang 3b30a4e509 update: update readme 2026-01-24 21:44:35 +08:00
Xiong Wang c25ce958ea Merge pull request #15 from vasqu/fix-fa-flags
[`FA`] Fixup wrong flags and loading logic
2026-01-24 16:32:32 +08:00
vasqu ab0f77849b fix loading logic 2026-01-23 10:48:11 +01:00