# Dia2

> Streaming dialogue TTS that starts speaking before the script is finished

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/nari-labs/dia2
- Canonical page: https://ai-tldr.dev/tools/dia2/

## In short

Dia2 is a streaming dialogue text-to-speech model from Nari Labs, the team behind Dia. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install dependencies.

## Overview

Dia2 is a streaming dialogue text-to-speech model from Nari Labs, the team behind Dia. Unlike a TTS model that needs the whole script up front, Dia2 can start generating audio as soon as the first few words arrive, which makes it suited to realtime conversational systems. Scripts use the same [S1] and [S2] speaker tags as Dia to produce a back-and-forth between two voices.

The repository ships inference code alongside two checkpoints on Hugging Face, Dia2-1B and Dia2-2B. You run it through a command-line interface, a Gradio app, or a small Python API (Dia2, GenerationConfig, SamplingConfig). Generation is capped at about two minutes of English audio per run, and the result includes the waveform, the audio tokens, and word timestamps.

Voices are not fixed: the project notes that quality and voices vary from one generation to the next because the model is not fine-tuned on a specific speaker. For stable output you condition on prefix audio for each speaker, which the CLI transcribes with Whisper. That same mechanism lets you feed in prior conversational context, such as an assistant's voice and a user's spoken turn, and generate the reply. The code and weights are Apache-2.0, with third-party assets such as Kyutai's Mimi codec keeping their own licenses.

## What it does

- Streaming generation that can begin from the first few words of input rather than the full text
- Two-speaker dialogue from transcripts tagged with [S1] and [S2]
- Audio conditioning via --prefix-speaker-1 and --prefix-speaker-2, with Whisper transcribing each prefix
- 1B and 2B checkpoints on Hugging Face (nari-labs/Dia2-1B, nari-labs/Dia2-2B)
- CLI, Gradio app and Python API, with CUDA graph support and bfloat16 by default
- Results include waveform, audio tokens and word timestamps at Mimi's ~12.5 Hz frame rate

## Getting started

Dia2 runs through uv and expects CUDA 12.8+ drivers; the CLI falls back to CPU when no CUDA device is found. The first run downloads the weights, tokenizer and Mimi codec.

1. Install dependencies

   Clone the repository and let uv set up the environment once.

```bash
git clone https://github.com/nari-labs/dia2.git
cd dia2
uv sync
```

2. Write a script

   Edit input.txt using [S1] and [S2] speaker tags for each turn. The bundled file opens like this:

```text
[S1] Um, like, I don't know, I've never actually, like, been on a real vacation, you know? [S2] Oh, seriously? That's wild. I've, uh, only been on, like, one trip myself, and it was kinda stressful.
```

3. Generate audio from the CLI

   Point the CLI at a checkpoint on Hugging Face and an output WAV path. Override the device or precision with --device / --dtype if needed.

```bash
uv run -m dia2.cli \
  --hf nari-labs/Dia2-2B \
  --input input.txt \
  --cfg 6.0 --temperature 0.8 \
  --cuda-graph --verbose \
  output.wav
```

4. Condition on speaker prefixes

   The README recommends prefix audio for stable voices. The repo includes example_prefix1.wav and example_prefix2.wav to try it.

```bash
uv run -m dia2.cli \
  --hf nari-labs/Dia2-2B \
  --input input.txt \
  --prefix-speaker-1 example_prefix1.wav \
  --prefix-speaker-2 example_prefix2.wav \
  --cuda-graph --verbose \
  output_conditioned.wav
```

5. Use it from Python or Gradio

   Call the Python API directly, or launch the bundled web UI with `uv run gradio_app.py`.

```python
from dia2 import Dia2, GenerationConfig, SamplingConfig

dia = Dia2.from_repo("nari-labs/Dia2-2B", device="cuda", dtype="bfloat16")
config = GenerationConfig(
    cfg_scale=2.0,
    audio=SamplingConfig(temperature=0.8, top_k=50),
    use_cuda_graph=True,
)
result = dia.generate("[S1] Hello Dia2!", config=config, output_wav="hello.wav", verbose=True)
```

## When to use it

- Building the speaking half of a realtime voice assistant that starts talking before the full reply text is ready
- Generating a spoken response conditioned on the previous turns of a conversation in a speech-to-speech pipeline
- Producing short two-speaker English dialogue clips from a tagged script
- Researching open streaming TTS with 1B and 2B checkpoints you can run locally
