# Qwen3-TTS 声音克隆

阿里巴巴的 Qwen3-TTS 是一款先进的文本到语音模型，支持 **10+ 种语言** 并且仅需 3 秒音频即可进行语音克隆。它具备自然语言情感控制（“愉快地说话”、“轻声耳语”）、97ms 延迟的流式输出，以及两种模型尺寸（0.6B 和 1.7B）。在 Apache 2.0 下发布，是最强大的开源 TTS 系统之一。

## 主要特性

* **10+ 种语言**：英语、中文、日语、韩语、法语、德语、西班牙语等
* **3 秒语音克隆**：从短音频样本克隆任何声音
* **自然情感控制**：使用普通文本指令控制风格
* **流式支持**：97ms 首个 token 延迟 — 非常适合实时应用
* **两种规模**：0.6B（4GB 显存）和 1.7B（8GB 显存）
* **可微调**：提供基础模型以便自定义训练
* **Apache 2.0 许可证**：完全商业使用

## 1024x1024

| A100                    | 参数量  | 显存  | 质量 | 性能 | 最适合        |
| ----------------------- | ---- | --- | -- | -- | ---------- |
| Qwen3-TTS-0.6B-Instruct | 0.6B | 4GB | 良好 | 快速 | 实时、经济型 GPU |
| Qwen3-TTS-1.7B-Instruct | 1.7B | 8GB | 最佳 | 中等 | 生产质量       |
| Qwen3-TTS-0.6B-Base     | 0.6B | 4GB | —  | —  | 微调         |
| Qwen3-TTS-1.7B-Base     | 1.7B | 8GB | —  | —  | 微调         |

## 要求

| 组件     | 0.6B         | 1.7B          |
| ------ | ------------ | ------------- |
| GPU    | RTX 3060 6GB | RTX 3080 10GB |
| 显存     | 4GB          | 8GB           |
| 内存     | 8GB          | 16GB          |
| 磁盘     | 5GB          | 10GB          |
| Python | 3.10+        | 3.10+         |

**推荐的 Clore.ai GPU**：0.6B 使用 RTX 3060（$0.15–0.3/天），1.7B 使用 RTX 3080（$0.2–0.5/天）

## 安装

```bash
pip install transformers torch torchaudio soundfile
```

## 快速开始 — 语音克隆

```python
import torch
import torchaudio
from transformers import AutoModelForCausalLM, AutoProcessor

model_name = "Qwen/Qwen3-TTS-12Hz-1.7B-Instruct"
processor = AutoProcessor.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float16,
    device_map="auto"
)

# 加载参考语音（任意声音 3 秒以上）
reference_audio, sr = torchaudio.load("reference_voice.wav")

# 生成克隆该声音的语音
text = "Welcome to Clore.ai, the decentralized GPU rental marketplace."
inputs = processor(
    text=text,
    audio=reference_audio,
    sampling_rate=sr,
    return_tensors="pt"
).to("cuda")

with torch.no_grad():
    output = model.generate(**inputs, max_new_tokens=2048)

# 解码并保存
audio = processor.decode(output[0])
torchaudio.save("output.wav", audio.unsqueeze(0), 24000)
```

## 情感控制

```python
# 使用自然语言指令控制情感
prompts = [
    ("愉快且充满活力地说话", "好消息！我们刚刚上线了新功能！"),
    ("轻声而温柔地耳语", "让我告诉你一个关于 GPU 价格的秘密..."),
    ("专业且清晰地说话", "季度业绩显示收入增长了 40%。"),
    ("兴奋地说话", "你不会相信基准测试的结果！"),
]

用于 prompts 中的 style, text：
    inputs = processor(
        text=text,
        style_prompt=style,
        audio=reference_audio,
        sampling_rate=sr,
        return_tensors="pt"
    ).to("cuda")
    
    output = model.generate(**inputs, max_new_tokens=2048)
    audio = processor.decode(output[0])
    torchaudio.save(f"output_{style[:10]}.wav", audio.unsqueeze(0), 24000)
```

## 多语言生成

```python
# 以不同语言生成（相同的声音！）
texts = {
    "en": "Hello, welcome to the GPU marketplace.",
    "zh": "你好，欢迎来到GPU市场。",
    "ja": "こんにちは、GPUマーケットプレイスへようこそ。",
    "ko": "안녕하세요, GPU 마켓플레이스에 오신 것을 환영합니다.",
    "fr": "Bonjour, bienvenue sur le marché GPU.",
    "de": "Hallo, willkommen auf dem GPU-Marktplatz.",
}

for lang, text in texts.items():
    inputs = processor(
        text=text, audio=reference_audio, sampling_rate=sr,
        language=lang, return_tensors="pt"
    ).to("cuda")
    output = model.generate(**inputs, max_new_tokens=2048)
    audio = processor.decode(output[0])
    torchaudio.save(f"output_{lang}.wav", audio.unsqueeze(0), 24000)
```

## 与其他 TTS 模型的比较

| 特性   | Qwen3-TTS  | Zonos      | Dia        | Kokoro     | XTTS |
| ---- | ---------- | ---------- | ---------- | ---------- | ---- |
| 语言   | 10+        | 1 (EN)     | 1 (EN)     | 1 (EN)     | 17   |
| 语音克隆 | 3 秒        | 2-30 秒     | 否          | 否          | 6 秒  |
| 流式传输 | ✅（97ms）    | ❌          | ❌          | ❌          | ✅    |
| 情感控制 | ✅ 自然       | ❌          | ✅ 自动       | ❌          | ❌    |
| 多说话人 | ❌          | ❌          | ✅          | ❌          | ❌    |
| 最小显存 | 4GB        | 8GB        | 8GB        | 2GB        | 6GB  |
| 许可   | Apache 2.0 | Apache 2.0 | Apache 2.0 | Apache 2.0 | AGPL |

## 给 Clore.ai 用户的提示

* **在 RTX 3060 上的 0.6B**：每天 $0.15 的最佳经济选项 — 足以应对大多数 TTS 任务
* **批量处理**：在一次会话中生成所有音频片段以最大化租用时间
* **缓存参考音频**：将你的声音参考保存在持久存储上
* **用于实时的流式传输**：在聊天机器人/助手应用中使用流式 API
* **为自定义声音进行微调**：租用 RTX 4090 几小时对基础模型进行你的语音数据微调

## # 使用固定种子以获得一致结果

| 问题        | 解决方案                                     |
| --------- | ---------------------------------------- |
| 1.7B 显存不足 | 切换到 0.6B 或使用 `torch_dtype=torch.float16` |
| 语音克隆听起来不对 | 使用 5-10 秒的干净音频（无背景噪声）                    |
| 错误的语言输出   | 明确传递 `language` 参数                       |
| 首次生成缓慢    | 正常 — 模型在首次调用时加载，后续调用很快                   |

## 延伸阅读

* [HuggingFace 模型](https://huggingface.co/Qwen/Qwen3-TTS-12Hz-1.7B-Instruct)
* [Qwen3-TTS 文档](https://qwen.readthedocs.io/)
* [语音克隆指南](https://medium.com/@zh.milo/qwen3-tts-the-complete-2026-guide)


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
