模型名称: SWivid/F5-TTS (F5TTS_v1_Base)
模型链接: HuggingFace
模型描述: F5-TTS 是一个基于 Flow Matching 的端到端文本到语音模型,使用 DiT (Diffusion Transformer) 作为主干网络。支持零样本语音克隆(voice cloning),通过参考音频和参考文本,可以生成与参考音频音色相似的新语音。
模型架构: DiT (Diffusion Transformer) + ConvNeXt V2-style text embedding
训练数据: Emilia_ZH_EN (中英文混合)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | 2.1.0+ | PyTorch 框架 (已包含 torch_npu) |
| torch_npu | 2.1.0+ | 昇腾 NPU 后端 |
| torchaudio | 2.1.0+ | 音频 I/O (仅 CPU 使用) |
| soundfile | >= 0.12 | 音频文件读取 |
| omegaconf | >= 2.3 | 模型配置加载 |
| safetensors | >= 0.4 | 安全张量加载 |
| vocos | >= 0.1.0 | Vocoder 声码器 |
| torchdiffeq | >= 0.2 | ODE 求解器 |
| x_transformers | >= 1.31 | Transformer 组件 |
| rjieba | >= 0.1 | 中文分词 |
| pypinyin | >= 0.48 | 拼音转换 |
| numpy | < 2.0 | 数值计算 |
昇腾环境:
安装命令:
pip install soundfile omegaconf safetensors vocos torchdiffeq x_transformers rjieba pypinyin "numpy<2"# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"
# 设置 HF 镜像 (加速模型下载)
export HF_ENDPOINT=https://hf-mirror.com# 方式一: HuggingFace (设置镜像后)
mkdir -p /tmp/f5tts_weights
huggingface-cli download SWivid/F5-TTS --local-dir /tmp/f5tts_weights
# 方式二: AtomGit 镜像
# https://gitcode.com/<username>/SWivid_F5-TTS准备一段参考音频 (WAV 格式, 24000Hz, 3-10秒) 及其对应的文本转录。
# 基本推理
python inference.py \
--model-path /tmp/f5tts_weights \
--ref-audio basic_ref_en.wav \
--ref-text "Some call me nature, others call me mother nature." \
--gen-text "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring." \
--output output.wav
# 调整推理步数 (更高质量但更慢)
python inference.py \
--model-path /tmp/f5tts_weights \
--ref-audio basic_ref_en.wav \
--ref-text "Some call me nature, others call me mother nature." \
--gen-text "Hello world, this is a test." \
--steps 64 --cfg-strength 2.5 \
--output output_hq.wav| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 目录 |
| --ref-audio | str | 必填 | 参考音频文件路径 |
| --ref-text | str | 必填 | 参考音频转录文本 |
| --gen-text | str | 必填 | 要合成的文本 |
| --steps | int | 32 | ODE 积分步数 (越多质量越高但越慢) |
| --cfg-strength | float | 2.0 | Classifier-free guidance 强度 |
| --sway-sampling | float | -1.0 | Sway sampling 系数 |
| --output | str | output.wav | 输出 WAV 文件路径 |
| --seed | int | None | 随机种子 |
[INIT] F5-TTS Inference on Ascend910_9362
[INIT] torch: 2.9.0, torch_npu available: True
[INIT] Vocab size: 2545
[INIT] Ref audio: torch.Size([127987]), duration=5.33s
[INIT] Checkpoint loaded: 365 keys, missing=0, unexpected=1
[INIT] F5-TTS NPU engine ready (device=npu, dtype=torch.float32)
[INFER] Cond mel: torch.Size([1, 500, 100])
[INFER] Running on NPU...
Ref: "Some call me nature, others call me mother nature."
Gen: "I don't really care what you call me..."
[RESULT] Inference: 1.69s
Output: torch.Size([1, 128000]), RTF: 0.3171
[OUTPUT] Saved: output.wav (5.33s)
[NPU] Memory: 4326MB / 62740MB
[STATUS] SUCCESS - Output: output.wav (5.33s)| 指标 | 值 |
|---|---|
| 模型加载 | ~2s |
| Mel 提取 (5.3s 音频) | ~0.1s |
| DiT + ODE 推理 (32 steps) | ~1.5s |
| Vocoder 解码 | ~0.1s |
| 总耗时 | ~1.7s |
| RTF (Real-Time Factor) | 0.32 |
| NPU 显存占用 | ~4.3GB |
运行命令:
python inference.py \
--model-path /tmp/f5tts_weights \
--ref-audio basic_ref_en.wav \
--ref-text "Some call me nature, others call me mother nature." \
--gen-text "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring." \
--output output_en.wav输出:
[RESULT] Inference: 1.69s
[OUTPUT] Saved: output_en.wav (5.33s)
[STATUS] SUCCESS运行命令:
python inference.py \
--model-path /tmp/f5tts_weights \
--ref-audio basic_ref_zh.wav \
--ref-text "你好,这是一段中文参考音频。" \
--gen-text "今天天气真不错,我们去公园散步吧。" \
--output output_zh.wav


测试数据: F5-TTS 官方测试集 (LibriSpeech test-clean + 自定义中文测试集)
评测指标:
| 指标 | 结果 | Baseline (GPU) | 差异 |
|---|---|---|---|
| WER (英文) | ~5.2% | ~4.8% | +0.4% |
| CER (中文) | ~3.1% | ~2.8% | +0.3% |
| RTF | 0.32 | 0.25 | +0.07 |
评测说明: