Skip to content
ETH-DISCOPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

LaVoco

Autoregressive zero-shot voice conversion.

Give LaVoco a source clip and a short reference clip of a new speaker, and it re-speaks the source content in the reference voice. The target speaker is never seen during training and only one short reference clip is needed.

Trained weights live at disco-eth/lavoco. Audio samples are on the project page.

Quickstart

With the environment installed and two clips ready (a source.wav to convert and a reference.wav of the voice you want), one command does it:

python inference.py \
    --model_dir disco-eth/lavoco \
    --source_audio source.wav \
    --reference_audio reference.wav \
    --output_audio converted.wav

The model downloads from HuggingFace on first run. If the repo is private, add --hf_token $HF_TOKEN. Audio can be any sample rate, it is resampled to 16 kHz.

How it works

LaVoco is built on a LLASA language-model backbone.

  • Source content comes from a frozen Whisper encoder. These features carry what is said and how it is said, without the source speaker timbre.
  • A small trainable projection maps the Whisper features into the LLASA embedding space.
  • The reference and target audio are tokenized with XCodec2. The reference tokens tell the model how the target voice sounds.
  • The model generates XCodec2 tokens for the target speaker, and XCodec2 decodes those back into a waveform.

The training sequence looks like this:

"Convert " [Whisper content] " into speech using this speaker: "
    <U_START> [reference XCodec2 tokens] <U_END>
    <G_START> [target XCodec2 tokens] <G_END>

The loss is applied only on the target tokens.

Layout

train.py                    model definition and training loop
inference.py                convert a single utterance
data/prepare_dataset.py     cut reference and target, encode with XCodec2, push to the Hub
data/seedvc_augment.py      build timbre-augmented targets with Seed-VC
data/whisper_embeddings.py  helper for extracting Whisper content features
scripts/train.sh            multi-GPU training launcher
scripts/inference.sh        one-line inference wrapper

Install

pip install -r requirements.txt

Flash Attention is optional and only helps on supported GPUs. Install it separately with pip install flash-attn --no-build-isolation.

Set your tokens in the environment rather than in the code.

export HF_TOKEN=...        # needed to pull private repos or push models
export WANDB_API_KEY=...   # optional, for training logs

Data

The training targets use a timbre-augmentation trick. Each utterance is converted into a random reference voice with Seed-VC, which strips the original speaker timbre while keeping the content. The model then learns to put a chosen timbre back.

  1. Build the augmented targets. This needs a local checkout of Seed-VC.

    python data/seedvc_augment.py \
        --seedvc-root ../seed-vc \
        --input-dir path/to/utterances \
        --ref-dir path/to/reference_voices \
        --output-dir path/to/augmented
  2. Cut each clip into a reference and a target span, encode everything with XCodec2, and push the result to a HuggingFace dataset.

    python data/prepare_dataset.py \
        --source_dataset your-name/your-audio \
        --output_repo your-name/lavoco-train \
        --seedvc_root ../seed-vc

Train

Edit the config block at the top of scripts/train.sh, then run it.

bash scripts/train.sh

The script uses Accelerate for data parallel training across the visible GPUs and pushes checkpoints to the target HuggingFace repo. You can also call train.py directly and pass the same flags.

Convert a voice

bash scripts/inference.sh source.wav reference.wav out.wav

Or call the script directly for more control over sampling.

python inference.py \
    --model_dir disco-eth/lavoco \
    --source_audio source.wav \
    --reference_audio reference.wav \
    --output_audio out.wav \
    --temperature 1.0 \
    --top_p 0.9 \
    --repetition_penalty 1.2

The reference clip can be short. A few seconds of clean speech is enough.

Models used

  • LLASA backbone: HKUSTAudio/Llasa-1B
  • Content encoder: openai/whisper-small
  • Audio codec: HKUSTAudio/xcodec2

License

Apache 2.0. See LICENSE.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages