> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/yin-pin-yu-yu-yin/dia-tts.md).

# Dia TTS（Nari Labs）

使用 Nari Labs 的 Dia TTS 生成带情感的多说话人对话

Dia by Nari Labs 是一款先进的文本转语音模型，专长于 **逼真的多说话人对话**。与一次只处理一个说话人的传统 TTS 不同，Dia 能生成包含情感、笑声、迟疑以及其他非语言线索的多说话人自然对话。该模型拥有 16 亿参数，可在任何 8GB 以上的 GPU 上运行。

## 主要特性

* **多说话人对话**：一次生成 2 位及以上说话人的对话
* **非语言线索**：笑声 `（笑）`，迟疑 `（叹气）`，停顿——自动嵌入
* **情感语音**：无需显式情感标签的自然语调
* **16 亿参数**：可装入 RTX 3070/3080（8-10GB 显存）
* **Apache 2.0 许可证**：可用于商业用途
* **HuggingFace 集成**：可与 Transformers 库配合使用

## 需求

| 组件     | 最低            | 推荐             |
| ------ | ------------- | -------------- |
| GPU    | RTX 3070（8GB） | RTX 3080（10GB） |
| 显存     | 8GB           | 10GB 以上        |
| 内存     | 16GB          | 32GB           |
| 磁盘     | 10GB          | 15GB           |
| Python | 3.9+          | 3.11           |

**推荐的 Clore.ai GPU**：RTX 3080 10GB（$0.05–0.19/小时）

## 安装

```bash
# 选项 1：pip 安装
pip install dia-tts

# 选项 2：从源码安装
git clone https://github.com/nari-labs/dia.git
cd dia
pip install -e .
```

## 快速开始

### 基础多说话人对话

```python
from dia import Dia

# 加载模型
model = Dia.from_pretrained("nari-labs/Dia-1.6B")

# 生成多说话人对话
# [S1] = 说话人 1，[S2] = 说话人 2
text = """[S1] 嘿，你试过新的 GPU 租赁平台吗？
[S2] 你是说 Clore 吗？对，我昨天租了一块 RTX 4090。
[S1] 感觉怎么样？
[S2]（笑）说实话？比我预期便宜多了。一天才两美元左右。
[S1] 不会吧。那……那真的太离谱了。"""

audio = model.generate(text)

# 保存到文件
import soundfile as sf
sf.write("dialog.wav", audio, samplerate=24000)
```

### 带有情感和非语言线索

```python
# Dia 会自动处理自然的语音模式
text = """[S1] 我刚拿到结果……
[S2] 然后呢？别吊我胃口！
[S1]（叹气）我们通过了。我们真的通过了所有测试。
[S2]（笑）我就知道！我就知道我们一定能成功！
[S1] 我简直不敢相信……（笑）好吧，好吧，我们去庆祝吧。"""

audio = model.generate(text, temperature=0.8)
sf.write("emotional_dialog.wav", audio, samplerate=24000)
```

### 单说话人

```python
# 也适用于单说话人
text = "[S1] 欢迎来到 Clore AI 文档。在本指南中，我们将演示如何设置你的第一个 GPU 租赁，并部署一个机器学习模型。"

audio = model.generate(text)
sf.write("narration.wav", audio, samplerate=24000)
```

## Gradio Web UI

```python
# 启动交互式演示
python -m dia.app --port 7860 --share

# 或者手动：
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="对话（使用 [S1]、[S2] 标签）", lines=10),
    outputs=gr.Audio(label="生成的语音"),
    title="Dia TTS — 多说话人对话"
)
demo.launch(server_port=7860)
```

## 应用场景

* **播客生成**：从脚本创建对话式播客
* **有声书对话**：用不同的声音生成角色对话
* **游戏对白**：带有自然语音模式的 NPC 对话
* **训练数据**：生成多样化语音数据集，用于 ASR 训练
* **聊天机器人声音**：带有情感回应的多轮对话

## 给 Clore.ai 用户的建议

* **RTX 3080 是理想选择**：10GB 显存可轻松运行 Dia，费用为 $0.05–0.19/小时
* **批量生成**：循环处理多个对话，以最大化你的租用时间
* **将模型保存到持久存储**：如果你的 Clore 实例有持久磁盘，可将模型缓存起来以避免重新下载
* **温度 0.7–0.9**：越低越一致，越高越有表现力/变化更多
* **仅支持英语**：Dia 目前专注于英语——多语言请查看 Qwen3-TTS 指南

## 故障排查

| 问题        | 解决方案                                                   |
| --------- | ------------------------------------------------------ |
| CUDA 内存不足 | 使用 `model.to("cuda", torch_dtype=torch.float16)` 用于半精度 |
| 说话人听起来相似  | 为每个说话人增加更多文本/上下文；尝试更高的温度                               |
| 非语言线索被忽略  | 确保格式正确： `（笑）`, `（叹气）` 用括号                              |
| 音频质量低     | 增大 `num_steps` 如果可用则使用该参数；确保 24kHz 采样率                 |

## 延伸阅读

* [Nari Labs GitHub](https://github.com/nari-labs/dia)
* [HuggingFace 模型](https://huggingface.co/nari-labs/Dia-1.6B)
* [对比：Dia 与 ElevenLabs](https://nari-labs.github.io/dia/) — 官方演示页面


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/yin-pin-yu-yu-yin/dia-tts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
