Skip to content

feat: add reference-audio voice cloning to KugelAudio - #1275

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
mirek190:agent/kugelaudio-reference-cloning-20261113
Nov 13, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
mirek190:agent/kugelaudio-reference-cloning-20261113

Conversation

@mirek190

@mirek190 mirek190 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Adds reference-audio voice cloning to the existing KugelAudio family. Previously, raw speaker references were rejected; this enables --task clon --voice-ref reference.wav, reference conditioning in TTS sessions, and the existing server voice_ref field.

The model-local implementation uses the causal acoustic encoder already present in the original checkpoint. Its mean features feed the existing generator's voice-conditioning path, which applies sampling/scaling once. The generator and shared GGML, CUDA, Vulkan, and server-runtime code are unchanged.

Implementation

  • Downmix/resample references to mono 24 kHz, apply the original -25 dBFS normalization, and reject silence, invalid samples, malformed frames, or references longer than 30 seconds.
  • Cache one completed reference per session; release temporary encoder weights/graphs before synthesis. Failed reference preparation preserves the previous prepared voice.
  • Parse encoder configuration only when cloning is requested. Preset-only loading retains its original behavior, including with encoder settings removed.
  • Support an encoder-bearing GGUF or separate matching encoder GGUF/safetensors. Add --include-reference-encoder to conversion and a helper to augment existing GGUFs without changing their generator tensors. Preset-only conversions retain preset-only embedded capabilities.
  • Cover offline, long-form chunking, and streamed cloned speech using the existing request/session APIs.

Validation

Tested on Windows with an RTX 3090 24 GiB, Ryzen 7950X3D, and 8 CPU threads, after updating to upstream eb8281c9.

The short test says “Hello, this is a test of the cloned voice.” Both references are six-second speech clips. Seed 1234, default 20 diffusion steps and guidance 3, Q8_0 generator, max_tokens=64. Model loading and one preset warmup are excluded. First clone includes reference preparation and generation; cached clone reuses its features.

Backend Generated audio First clone Cached clone Sampled peak VRAM, model included
CPU 3.067 s 17.12 s 14.78 s —
CUDA 3.200 s 2.13 s 0.76 s 10.84 GiB
Vulkan 3.200 s 2.47 s 0.91 s 11.21 GiB

These are short single-case timings, not a throughput comparison. VRAM was sampled every 100 ms and includes a 0.244 GiB baseline. CPU peak RSS was 20.09 GiB, including model storage/mappings.

Independent WavLM speaker similarity, comparing each reference against its clone and the original English male preset:

Backend Reader: clone / preset Video speaker: clone / preset
CPU 0.941 / 0.681 0.955 / 0.839
CUDA 0.937 / 0.673 0.961 / 0.824
Vulkan 0.936 / 0.676 0.936 / 0.844

These scores support the tested references, not universal speaker accuracy. Longer normal/cloned comparison samples were also generated and listened to locally; the final audited implementation reproduces them bit for bit.

Checks passed:

  • All 9 native-versus-original-PyTorch encoder cases on CPU/CUDA/Vulkan. CPU/Vulkan maximum relative L2 error is below 0.0004%; CUDA is below 0.084% under its existing TF32 policy.
  • Long-lived sessions on all three backends: cached seeded repeats, reference switching, failed-preparation recovery, preset restoration, clearing prepared voices, missing-reference recovery, two text chunks, and streaming. All audited waveforms match the earlier tested implementation bit for bit.
  • Twelve CUDA/Vulkan legacy-server HTTP cases: path/base64 parity, cache reuse, HTTP 400 for silence, recovery, and unchanged preset audio.
  • Three selected CTests in each CPU/GPU build: reference frontend/configuration, GGUF tensor source, and model-spec system. Loader/catalog sync and its self-tests also pass.
  • Synthetic conversion smoke tests for both preset-only and encoder-enabled contracts, including BF16 encoder preservation and Q8_0 generator conversion.
  • Actual augmented package: all 656 existing tensors and all 276 added original encoder tensors are bit-identical to their sources. GGUF sizes are 9,752,398,658 bytes before and 10,439,833,634 bytes after.

Usage and limits

audiocpp_cli --family kugelaudio --task clon \
  --model /path/to/kugelaudio-0-open-q8_0-clone.gguf \
  --backend cuda --voice-ref reference.wav \
  --text "Hello from the cloned voice." --seed 1234 --out cloned.wav

This remains experimental: the original open processor exposes prepared voice caches, not a supported raw-WAV cloning API. The reference comparison covers its original encoder component, not full PyTorch/native TTS waveform parity. Cross-backend waveforms differ; independent ASR recovered all requested words in five of six short samples, with “clone” versus “cloned” in the remaining CPU sample. Both complete sentences were recovered in all long-form tests. Metal and non-English cloning quality have not been validated.

Existing hosted preset packages still require a separately supplied encoder and the current model-spec override, or local conversion with the encoder included. This PR does not advertise an unpublished hosted package.

Model documentation · Validation report, source pins, build/run commands, and artifact paths

01_reference_video_speaker.mp4
02_cloned_video_voice.mp4

@0xShug0
0xShug0 merged commit 353bf8c into 0xShug0:main Nov 13, 2026
7 checks passed
@0xShug0

0xShug0 commented Nov 13, 2026

Copy link
Copy Markdown
Owner

@mirek190 Thanks! PR merged.

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.

2 participants