Dia TTS (Nari Labs)
Generate multi-speaker dialog with emotion using Dia TTS by Nari Labs
Last updated
Was this helpful?
Was this helpful?
# Option 1: pip install
pip install dia-tts
# Option 2: From source
git clone https://github.com/nari-labs/dia.git
cd dia
pip install -e .from dia import Dia
# Load model
model = Dia.from_pretrained("nari-labs/Dia-1.6B")
# Generate multi-speaker conversation
# [S1] = Speaker 1, [S2] = Speaker 2
text = """[S1] Hey, have you tried the new GPU rental platform?
[S2] You mean Clore? Yeah, I rented an RTX 4090 yesterday.
[S1] How was it?
[S2] (laughs) Honestly? Way cheaper than I expected. Like two bucks a day.
[S1] No way. That's... that's actually insane."""
audio = model.generate(text)
# Save to file
import soundfile as sf
sf.write("dialog.wav", audio, samplerate=24000)# Dia automatically handles natural speech patterns
text = """[S1] I just got the results back...
[S2] And? Don't keep me in suspense!
[S1] (sighs) We passed. We actually passed all the tests.
[S2] (laughs) I told you! I told you we'd make it!
[S1] I can't believe it... (laughs) okay, okay, let's celebrate."""
audio = model.generate(text, temperature=0.8)
sf.write("emotional_dialog.wav", audio, samplerate=24000)# Works for single speaker too
text = "[S1] Welcome to the Clore AI documentation. In this guide, we'll walk through setting up your first GPU rental and deploying a machine learning model."
audio = model.generate(text)
sf.write("narration.wav", audio, samplerate=24000)# Launch interactive demo
python -m dia.app --port 7860 --share
# Or manually:
import gradio as gr
from dia import Dia
model = Dia.from_pretrained("nari-labs/Dia-1.6B")
def generate_speech(text):
audio = model.generate(text)
return (24000, audio)
demo = gr.Interface(
fn=generate_speech,
inputs=gr.Textbox(label="Dialog (use [S1], [S2] tags)", lines=10),
outputs=gr.Audio(label="Generated Speech"),
title="Dia TTS — Multi-Speaker Dialog"
)
demo.launch(server_port=7860)