ohhoohho/F5-TTS
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

F5-TTS — Ascend NPU Deployment

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

Overview

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:

  • Zero-shot voice cloning from a short reference audio
  • Flow-matching based generation with ODE solver (euler/midpoint)
  • Classifier-free guidance (CFG) for improved quality
  • Multi-batch generation for long text

Environment

Hardware

ComponentSpec
NPUAscend 910B (62GB HBM)
OSLinux (aarch64)
CANN8.5.1
torch_npu2.9.0.post1

Dependencies

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 matplotlib

Or install via requirements.txt:

pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

Model Weights

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

Checkpoint files

Model VariantFileSize
F5TTS_v1_BaseF5TTS_v1_Base/model_1250000.safetensors~1.26 GB
F5TTS_BaseF5TTS_Base/model_1200000.safetensors~1.26 GB
F5TTS_Base (bigvgan)F5TTS_Base_bigvgan/model_1250000.pt~1.26 GB
Vocos vocodercharactr/vocos-mel-24khz~35 MB

Usage

Basic inference

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:0

With bundled sample audio

The 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:0

Advanced options

python3 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
ArgumentDefaultDescription
--ref_audiosample refReference audio for voice cloning
--ref_textauto-transcribeReference audio transcript
--gen_textsample textText to synthesize
--outputoutput.wavOutput audio file path
--modelF5TTS_v1_BaseModel variant
--steps32Number of ODE steps (16=fast, 32=quality)
--cfg2.0CFG strength (1.0=no guidance, 2.0=default)
--deviceautoDevice: npu:0, npu:1, cpu
--seedrandomRandom seed for reproducibility
--remove_silenceoffTrim silence from output

NPU Adaptation Details

Changes from original CUDA implementation

  1. Device detection: Replaced torch.cuda.is_available() → torch.npu.is_available()
  2. Cache cleanup: torch.cuda.empty_cache() → torch.npu.empty_cache()
  3. Device mapping: All model tensors moved to NPU via .to(device) where device = "npu:0"
  4. Dtype handling: Model uses float32 on NPU (no float16 auto-detect for NPU)
  5. Loading: Weights loaded on CPU first, then moved to NPU to avoid OOM

Verification

# 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.wav

Project Structure

F5-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

References

  • F5-TTS Paper
  • Original Repository
  • HuggingFace Model
  • Ascend NPU / torch_npu