F5-TTS:采用 ConvNeXt V2 的扩散 Transformer,训练和推理速度更快。
E2 TTS:Flat-UNet Transformer,最接近原论文的复现。
Sway Sampling:推理时的流步长采样策略,显著提升性能。
# 创建一个 python_version>=3.10 的 conda 环境(也可以使用 virtualenv)
conda create -n f5-tts python=3.11
conda activate f5-tts
# 如果尚未安装 FFmpeg,请安装
conda install ffmpeg
1. 作为 pip 包安装(如果仅用于推理)
bash pip install f5-tts2. 本地可编辑安装(如果还要进行训练、微调)
```bash
git clone https://github.com/SWivid/F5-TTS.git
cd F5-TTSgit submodule update --init --recursive # (可选,如果使用 bigvgan 作为声码器)
pip install -e .
```
# 从 Dockerfile 构建
docker build -t f5tts:v1 .
# 从 GitHub Container Registry 运行
docker container run --rm -it --gpus=all --mount 'type=volume,source=f5-tts,target=/root/.cache/huggingface/hub/' -p 7860:7860 ghcr.io/swivid/f5-tts:main
# 快速启动,如果你只想运行 Web 界面(而非 CLI)
docker container run --rm -it --gpus=all --mount 'type=volume,source=f5-tts,target=/root/.cache/huggingface/hub/' -p 7860:7860 ghcr.io/swivid/f5-tts:main f5-tts_infer-gradio --host 0.0.0.0
使用 Triton 和 TensorRT-LLM 的部署方案。
在单个 L20 GPU 上进行解码,使用 26 组不同的 prompt_audio 和 target_text 配对,16 NFE。
| 模型 | 并发数 | 平均延迟 | RTF | 模式 |
|---|---|---|---|---|
| F5-TTS Base (Vocos) | 2 | 253 ms | 0.0394 | 客户端-服务器 |
| F5-TTS Base (Vocos) | 1 (Batch_size) | - | 0.0402 | 离线 TRT-LLM |
| F5-TTS Base (Vocos) | 1 (Batch_size) | - | 0.1467 | 离线 Pytorch |
更多信息请参阅详细说明。
当前支持的功能:
# 启动 Gradio 应用(Web 界面)
f5-tts_infer-gradio
# 指定端口/主机
f5-tts_infer-gradio --port 7860 --host 0.0.0.0
# 启动一个分享链接
f5-tts_infer-gradio --share
services:
f5-tts:
image: ghcr.io/swivid/f5-tts:main
ports:
- "7860:7860"
environment:
GRADIO_SERVER_PORT: 7860
entrypoint: ["f5-tts_infer-gradio", "--port", "7860", "--host", "0.0.0.0"]
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
volumes:
f5-tts:
driver: local
# 使用标志运行
# 将 --ref_text 设为 "" 将使用 ASR 模型转录(需要额外的 GPU 内存)
f5-tts_infer-cli --model F5TTS_v1_Base \
--ref_audio "provide_prompt_wav_path_here.wav" \
--ref_text "参考音频的内容、字幕或转录文本。" \
--gen_text "你想让 TTS 模型为你生成的一些文本。"
# 使用默认设置运行。src/f5_tts/infer/examples/basic/basic.toml
f5-tts_infer-cli
# 或者使用你自己的 .toml 文件
f5-tts_infer-cli -c custom.toml
# 多语音。参见 src/f5_tts/infer/README.md
f5-tts_infer-cli -c src/f5_tts/infer/examples/multi/story.toml
请参考训练与微调指南以获取最佳实践。
# 通过 Gradio Web 界面快速开始
f5-tts_finetune-gradio
更多说明请阅读训练与微调指南。
使用 pre-commit 确保代码质量(将自动运行代码检查器和格式化工具):
pip install pre-commit
pre-commit install
提交 Pull Request 前,在每次提交前运行:
pre-commit run --all-files
注意:为了适应张量表示法,某些模型组件对 E722 有代码检查例外。
如果我们的工作和代码库对你有用,请引用:
@article{chen-etal-2024-f5tts,
title={F5-TTS: A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching},
author={Yushen Chen and Zhikang Niu and Ziyang Ma and Keqi Deng and Chunhui Wang and Jian Zhao and Kai Yu and Xie Chen},
journal={arXiv preprint arXiv:2410.06885},
year={2024},
}
我们的代码根据 MIT 许可证发布。由于训练数据 Emilia 是一个野外数据集,预训练模型根据 CC-BY-NC 许可证授权。对此可能带来的不便,我们深表歉意。