F5-TTS: A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching
Paper: 2410.06885
Original: SWivid/F5-TTS
NPU Adaptation: ohhoohho/F5-TTS
F5-TTS is a text-to-speech (TTS) model based on flow matching with a DiT (Diffusion Transformer) backbone. It generates natural speech from text with a reference audio prompt (voice cloning / zero-shot TTS).
Model architecture: DiT (dim=1024, depth=22, heads=16) + CFM (Conditional Flow Matching) + Vocos vocoder
Key features:
| Component | Spec |
|---|---|
| NPU | Ascend 910B (62GB HBM) |
| OS | Linux (aarch64) |
| CANN | 8.5.1 |
| torch_npu | 2.9.0.post1 |
pip install torch torchaudio torch_npu
pip install transformers accelerate
pip install librispeech soundfile pydub
pip install vocos x-transformers einops safetensors
pip install cached-path hydra-core omegaconf
pip install tqdm matplotlibOr install via requirements.txt:
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/Download from HuggingFace mirror or gitcode:
# Option 1: HF mirror (recommended)
export HF_ENDPOINT=https://hf-mirror.com
python3 -c "
from huggingface_hub import snapshot_download
snapshot_download(repo_id='SWivid/F5-TTS',
allow_patterns=['F5TTS_v1_Base/*'],
local_dir='./weights/F5-TTS',
local_dir_use_symlinks=False)
"
# Option 2: gitcode
git clone https://gitcode.com/hf_mirrors/SWivid/F5-TTS.git ./weights/F5-TTS-git| Model Variant | File | Size |
|---|---|---|
| F5TTS_v1_Base | F5TTS_v1_Base/model_1250000.safetensors | ~1.26 GB |
| F5TTS_Base | F5TTS_Base/model_1200000.safetensors | ~1.26 GB |
| F5TTS_Base (bigvgan) | F5TTS_Base_bigvgan/model_1250000.pt | ~1.26 GB |
| Vocos vocoder | charactr/vocos-mel-24khz | ~35 MB |
python3 inference.py \
--ref_audio "path/to/reference.wav" \
--ref_text "Transcript of the reference audio." \
--gen_text "Text you want to synthesize." \
--output "output.wav" \
--device npu:0The f5-tts package includes sample reference audio:
python3 inference.py \
--gen_text "Hello, this is a test of F5-TTS running on Ascend NPU." \
--output "output.wav" \
--device npu:0python3 inference.py \
--ref_audio "speaker.wav" \
--ref_text "This is the speaker's voice." \
--gen_text "Generated speech content here." \
--output "result.wav" \
--model "F5TTS_v1_Base" \
--steps 32 \
--cfg 2.0 \
--device npu:0 \
--seed 42 \
--remove_silence| Argument | Default | Description |
|---|---|---|
--ref_audio | sample ref | Reference audio for voice cloning |
--ref_text | auto-transcribe | Reference audio transcript |
--gen_text | sample text | Text to synthesize |
--output | output.wav | Output audio file path |
--model | F5TTS_v1_Base | Model variant |
--steps | 32 | Number of ODE steps (16=fast, 32=quality) |
--cfg | 2.0 | CFG strength (1.0=no guidance, 2.0=default) |
--device | auto | Device: npu:0, npu:1, cpu |
--seed | random | Random seed for reproducibility |
--remove_silence | off | Trim silence from output |
torch.cuda.is_available() → torch.npu.is_available()torch.cuda.empty_cache() → torch.npu.empty_cache().to(device) where device = "npu:0"float32 on NPU (no float16 auto-detect for NPU)# Check NPU device
python3 -c "import torch; print(torch.npu.is_available()); print(torch.npu.device_count())"
# Run inference test
python3 inference.py --device npu:0 --gen_text "Testing F5-TTS on Ascend NPU." --output test_npu.wavF5-TTS/
├── inference.py # NPU-adapted inference script
├── README.md # This file
├── requirements.txt # Environment dependencies
└── assets/ # Screenshots
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png