Research-grade framework for adding speech generation to pretrained LLMs via neural audio codec tokens.
Text → LLM → Speech Adapter → Mimi Codec Tokens → Mimi Decoder → Audio
Instead of a traditional TTS pipeline (Text → TTS → Audio), the LLM learns speech as a new output modality through lightweight adapter layers — without full model fine-tuning.
Can a pretrained text LLM learn speech generation as an additional modality through lightweight adaptation layers?
| Component | Status | Trainable |
|---|---|---|
| Mimi Encoder | Frozen | ❌ |
| LLM Backbone (Qwen/Llama/Gemma) | Frozen (+ optional LoRA) | Optional |
| Speech Adapter (Linear/MLP/Transformer) | Trainable | ✅ |
| Mimi Decoder | Frozen | ❌ |
| Codec | Use Case | Token Type |
|---|---|---|
| Mimi (default) | Streaming, real-time, speech LLMs | Discrete RVQ |
| DAC | High-quality offline TTS | Discrete RVQ |
| DAC-VAE | Future: highest quality | Continuous (Phase 2) |
Note on DAC-VAE: Meta's DAC-VAE offers the highest reconstruction quality (used in SAM-Audio) but produces continuous latents, requiring a regression head rather than cross-entropy. Mimi is the default for autoregressive LLM training; swap to DAC via config for quality benchmarks.
# Install uv: https://docs.astral.sh/uv/
uv syncPyTorch is installed from the CUDA 12.6 index (see pyproject.toml).
# Download LibriSpeech parquet locally (Windows-safe)
uv run python scripts/preprocess/download_datasets.py --dataset librispeech --split train.360
# Encode to JSONL from local parquet
uv run python scripts/preprocess/prepare_librispeech.py -
8D27
-split train.360 --skip-download# Default: MLP adapter
uv run python scripts/train.py --config configs/default.yaml
# Compare adapter variants
uv run python scripts/train.py --config configs/adapters/linear.yaml
uv run python scripts/train.py --config configs/adapters/mlp.yaml
uv run python scripts/train.py --config configs/adapters/transformer.yaml
# Multi-GPU
uv run accelerate launch --num_processes 4 scripts/train.py --config configs/default.yaml
# DeepSpeed ZeRO-2
uv run deepspeed scripts/train.py --config configs/default.yaml \
--deepspeed configs/deepspeed_zero2.jsonuv run python scripts/evaluate.py \
--config configs/default.yaml \
--checkpoint outputs/checkpoints/default/epoch_10 \
--max-samples 50# Single utterance
uv run python scripts/inference.py \
--config configs/default.yaml \
--checkpoint outputs/checkpoints/default/epoch_10 \
--text "Hello, this is speech from a language model."
# API server
uv run python scripts/inference.py \
--config configs/default.yaml \
--checkpoint outputs/checkpoints/default/epoch_10 \
--serve --port 8000llmtts/
├── docs/ # Literature review, architecture, training strategy
├── src/llmtts/
│ ├── codecs/ # Mimi, DAC (codec-agnostic interface)
│ ├── adapters/ # Linear, MLP, Transformer variants
│ ├── models/ # SpeechLLM, backbone wrappers
│ ├── data/ # Dataset + collator
│ ├── training/ # Trainer, LoRA, distributed
│ ├── evaluation/ # WER, CER, reports
│ └── inference/ # Generator, streaming, FastAPI
├── scripts/
│ ├── train.py
│ ├── evaluate.py
│ ├── inference.py
│ └── preprocess/ # Download + encode datasets
├── configs/ # YAML configs + experiment matrix
├── docker/ # Reproducible container
└── tests/
| Variant | Config | Description |
|---|---|---|
| A: Linear | configs/adapters/linear.yaml |
hidden → Linear → codec vocab |
| B: MLP | configs/adapters/mlp.yaml |
hidden → Linear → GELU → Linear |
| C: Transformer | configs/adapters/transformer.yaml |
Small transformer + projection |
docker compose up train # Training
docker compose up infer # Inference server on :8000Training logs to Weights & Biases by default. Disable with:
export WANDB_DISABLED=1The modular design supports:
- Speech understanding (codec → LLM input)
- Speech-to-speech dialogue
- Full duplex conversation (Moshi-style)
- Emotion / prosody control tokens
- Voice cloning via prompt tokens
- Cross-LLM portability (Qwen → Llama → Gemma)
Apache-2.0