> 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/kani-tts.md).

# Kani-TTS-2 声音克隆

在 Clore.ai GPU 上运行 Kani-TTS-2——一款超高效的 4 亿参数文字转语音模型，支持声音克隆

nineninesix.ai 的 Kani-TTS-2（于 2026 年 2 月 15 日发布）是一个 4 亿参数的开源文本转语音模型，仅需 **3GB 显存**。它基于 LiquidAI 的 LFM2 架构并结合 NVIDIA NanoCodec，将音频视为一种语言——可通过一段简短的参考音频实现零样本声音克隆，生成自然的语音。其体积不到竞品模型的一半，计算开销也只是其中一小部分，因此 Kani-TTS-2 非常适合在低成本硬件上用于实时对话式 AI、有声书生成和声音克隆。

**HuggingFace：** [nineninesix/kani-tts-2-en](https://huggingface.co/nineninesix/kani-tts-2-en) **GitHub：** [nineninesix-ai/kani-tts-2](https://github.com/nineninesix-ai/kani-tts-2) **PyPI：** [kani-tts-2](https://pypi.org/project/kani-tts-2/) **许可证：** Apache 2.0

## 主要特性

* **4 亿参数，3GB 显存** — 几乎可在任何现代 GPU 上运行，包括 RTX 3060
* **零样本声音克隆** — 可从 3–30 秒的参考音频样本克隆任意声音
* **说话人嵌入** — 基于 WavLM 的 128 维说话人表示，可实现精确的声音控制
* **最长可达 40 秒的连续音频** — 适合更长的段落和对话
* **实时或更快** — 在 RTX 5080 上 RTF 约为 0.2，即使在入门级 GPU 上也能实时运行
* **Apache 2.0** — 完全开放，可用于个人和商业用途
* **包含预训练框架** — 可从零开始在任意语言上训练你自己的 TTS 模型

## 与其他 TTS 模型的比较

| 模型             | 参数     | 最低显存 | 声音克隆   | 语言       | 许可证          |
| -------------- | ------ | ---- | ------ | -------- | ------------ |
| **Kani-TTS-2** | 4 亿    | 3GB  | ✅ 零样本  | 英语（可扩展）  | Apache 2.0   |
| Kokoro         | 8200 万 | 2GB  | ❌ 预设声音 | 英语、日语、中文 | Apache 2.0   |
| Zonos          | 4 亿    | 8GB  | ✅      | 多 GPU    | Apache 2.0   |
| ChatTTS        | 3 亿    | 4GB  | ❌ 随机种子 | 中文、英语    | AGPL 3.0     |
| Chatterbox     | 5 亿    | 6GB  | ✅      | 英语       | Apache 2.0   |
| XTTS（Coqui）    | 4.67 亿 | 6GB  | ✅      | 多 GPU    | MPL 2.0      |
| F5-TTS         | 335M   | 4GB  | ✅      | 多 GPU    | CC-BY-NC 4.0 |

## 需求

{% hint style="warning" %}
**Clore.ai 市场上未列出多 GPU 的 80GB 级机型。** 目前列出的最大配置是 4× RTX PRO 6000 Blackwell（每张 96GB，共 380GB）以及 8–11× RTX 5090（每张 32GB）。A100 / H200 / B200 容量可按 [裸机](https://clore.ai/bare-metal) 需求提供。部署前请查看 [GPU 价格与可用性](/guides/guides_v2-zh/ru-men-zhi-nan/pricing.md) 。
{% endhint %}

| 组件     | 最低             | 推荐           |
| ------ | -------------- | ------------ |
| GPU    | 任何配备 3GB 显存的设备 | RTX 3060 或更高 |
| 显存     | 3GB            | 6GB          |
| 内存     | 8GB            | 16GB         |
| 磁盘     | 2GB            | 5GB          |
| Python | 3.9+           | 3.11+        |
| CUDA   | 12.8+          | 12.8+        |

**Clore.ai 推荐：** RTX 3060（$0.03–0.07/小时）绰绰有余。即使是 Clore.ai 上最便宜的 GPU 实例，也能轻松运行 Kani-TTS-2。对于批量处理（有声书、数据集），RTX 4090（$0.14–0.42/小时）能提供出色的吞吐量。

## 安装

```bash
# 安装包
pip install kani-tts-2

# 重要：安装兼容的 transformers 版本（LFM2 架构所需）
pip install -U "transformers==4.56.0"

# 可选：安装 soundfile 以保存音频
pip install soundfile
```

## 快速开始

三行即可生成语音：

```python
from kani_tts import KaniTTS

# 使用英文模型初始化
model = KaniTTS('nineninesix/kani-tts-2-en')

# 生成语音
audio, text = model("你好！欢迎使用 Kani TTS 2，新一代高效文本转语音。")

# 保存到文件
model.save_audio(audio, "output.wav")
```

## 使用示例

### 1. 基础文本转语音

```python
from kani_tts import KaniTTS

model = KaniTTS('nineninesix/kani-tts-2-en')

# 使用自定义参数生成
audio, text = model(
    "敏捷的棕色狐狸跳过了懒狗。 "
    "这句话包含英语字母表中的每个字母。",
    temperature=0.7,
    top_p=0.9,
    repetition_penalty=1.1
)

model.save_audio(audio, "pangram.wav")
print(f"生成了 {len(audio) / 22000:.1f} 秒的音频")
```

### 2. 声音克隆

从一段简短的参考音频样本中克隆任意声音：

```python
from kani_tts import KaniTTS, SpeakerEmbedder

# 初始化模型
model = KaniTTS('nineninesix/kani-tts-2-en')
embedder = SpeakerEmbedder()

# 从参考音频中提取说话人嵌入（建议 3–30 秒）
speaker_embedding = embedder.embed_audio_file("reference_voice.wav")

# 以克隆的声音生成语音
audio, text = model(
    "这是一个使用 Kani TTS 2 进行声音克隆的演示。 "
    "你听到的声音应该与参考音频样本一致。",
    speaker_emb=speaker_embedding
)

model.save_audio(audio, "cloned_output.wav")
```

### 3. 有声书批量生成

高效生成多个章节：

```python
from kani_tts import KaniTTS, SpeakerEmbedder
import soundfile as sf

model = KaniTTS('nineninesix/kani-tts-2-en')
embedder = SpeakerEmbedder()

# 使用旁白声音
narrator_emb = embedder.embed_audio_file("narrator_sample.wav")

chapters = [
    "第一章。那是四月里一个晴朗而寒冷的日子，钟声正敲响十三下。",
    "第二章。走廊里弥漫着煮卷心菜和旧破席垫的气味。",
    "第三章。即使隔着紧闭的窗玻璃，外面的世界看起来也很寒冷。",
]

for i, chapter_text in enumerate(chapters):
    audio, _ = model(chapter_text, speaker_emb=narrator_emb)
    model.save_audio(audio, f"chapter_{i+1}.wav")
    print(f"生成了第 {i+1} 章")
```

### 4. 兼容 OpenAI 的流式 API

对于实时应用，请使用兼容 OpenAI 的服务器：

```bash
# 克隆服务器
git clone https://github.com/nineninesix-ai/kani-tts-2-openai-server.git
cd kani-tts-2-openai-server

# 安装依赖
pip install -r requirements.txt

# 启动服务器
python server.py --model nineninesix/kani-tts-2-en --host 0.0.0.0 --port 8080
```

然后可将其与任何 OpenAI TTS 客户端一起使用：

```python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080/v1", api_key="not-needed")

response = client.audio.speech.create(
    model="kani-tts-2-en",
    voice="default",
    input="你好，来自兼容 OpenAI 的 Kani TTS 服务器！"
)

response.stream_to_file("streamed_output.wav")
```

## 给 Clore.ai 用户的建议

1. **这是运行成本最低的模型** — 只需 3GB 显存，Kani-TTS-2 几乎可在 Clore.ai 上任何 GPU 实例上运行。对于生产级 TTS，RTX 3060（$0.03–0.07/小时）已经绰绰有余。
2. **与语言模型结合使用** — 租用一个 GPU 实例，同时运行一个小型 LLM（例如 Mistral 3 8B）和 Kani-TTS-2，即可构建完整的语音助手。它们会共享 GPU，而且还有余量。
3. **预先计算说话人嵌入** — 只需提取一次说话人嵌入并保存起来。这样可以避免在每次请求时都加载 WavLM 嵌入模型。
4. **使用兼容 OpenAI 的服务器** — 该 `kani-tts-2-openai-server` 提供了可直接替换 OpenAI TTS API 的方案，便于与现有应用集成。
5. **在自定义语言上训练** — Kani-TTS-2 包含完整的预训练框架（[kani-tts-2-pretrain](https://github.com/nineninesix-ai/kani-tts-2-pretrain)）。在你自己的语言数据集上微调模型——只需 8 张 H100 运行约 6 小时。

## 故障排查

| 问题                      | 解决方案                                                           |
| ----------------------- | -------------------------------------------------------------- |
| `ImportError：无法导入 LFM2` | 安装正确的 transformers 版本： `pip install -U "transformers==4.56.0"` |
| 音频质量差 / 机械感强            | 增大 `temperature` 设为 0.8–0.9；确保用于克隆的参考音频干净（没有背景噪声）              |
| 声音克隆与参考音频不像             | 使用 5–15 秒清晰、单一说话人的音频。避免参考音频中包含音乐或背景噪声                          |
| `CUDA 内存不足`             | 在 3GB 模型下不应该发生——检查是否有其他进程正在占用 GPU 内存（`nvidia-smi`)             |
| 音频在句中被截断                | Kani-TTS-2 最长支持约 40 秒。将更长的文本拆分为句子并将输出拼接起来                      |
| 在 CPU 上很慢               | 强烈建议使用 GPU 推理。即使是基础 GPU，也比 CPU 快 10–50 倍                       |

## 延伸阅读

* [GitHub — kani-tts-2](https://github.com/nineninesix-ai/kani-tts-2) — PyPI 包、使用文档、高级示例
* [HuggingFace — kani-tts-2-en](https://huggingface.co/nineninesix/kani-tts-2-en) — 英文模型权重
* [预训练框架](https://github.com/nineninesix-ai/kani-tts-2-pretrain) — 从零开始训练你自己的 TTS 模型
* [兼容 OpenAI 的服务器](https://github.com/nineninesix-ai/kani-tts-2-openai-server) — OpenAI TTS API 的直接替代方案
* [说话人嵌入模型](https://huggingface.co/nineninesix/speaker-emb-tbr) — 基于 WavLM 的声音嵌入器
* [MarkTechPost 概述](https://www.marktechpost.com/2026/02/15/meet-kani-tts-2-a-400m-param-open-source-text-to-speech-model-that-runs-in-3gb-vram-with-voice-cloning-support/) — 社区报道


---

# 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/kani-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.
