Commit Graph
45 Commits
Author SHA1 Message Date
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
vasqu 587ebf6389 fixup wrong flags 2026-01-23 10:18:08 +01:00
Xiong Wang 0c6a7cbb6c update: modify default non_streaming_mode 2026-01-23 14:08:26 +08:00
Andrew 6c07ea2a85 Merge branch 'QwenLM:main' into main 2026-01-23 09:20:45 +04:00
Xiong Wang 8a98526da0 fix and update: fix finetuning/prepare_data.py and update citation 2026-01-23 13:19:19 +08:00
dffdeeq 2331298c38 add streaming TTS generation
- stream_generate_pcm() | real-time
- stream_generate_voice_clone()
2026-01-23 08:58:38 +04:00
Xiong Wang d5c446171a fix: hf speech_tokenizer download bug. 2026-01-22 23:34:21 +08:00
Xiong Wang d8146d5305 Initial commit 2026-01-22 17:57:04 +08:00