A lightweight FastAPI-based REST API that exposes the open-source F5-TTS voice synthesis model.
Generate speech, stream audio, and clone voices with simple API calls.
- 🎧 Text-to-Speech (
/tts,/tts-fast) - 🔊 Real-time audio streaming (
/tts-stream,/tts-stream-chunked) - ⚙️ Configurable speed, steps, silence removal, and CFG
- 🧩 Easy to integrate in any web or SaaS app
git clone https://github.com/SWivid/F5-TTS.git
cd F5-TTSCopy or download app.py from this repo into the root of your F5-TTS folder.
pip install -r requirements.txtuvicorn app:app --host 0.0.0.0 --port 8000Then open in browser:
👉 http://localhost:8000/docs
import requests
url = "http://localhost:8000/tts"
files = {"ref_audio": open("ref.wav", "rb")}
data = {"gen_text": "Hello world, this is F5-TTS in action!"}
res = requests.post(url, files=files, data=data)
open("output.wav", "wb").write(res.content)import fs from "fs";
import FormData from "form-data";
import axios from "axios";
const runTTS = async () => {
const formData = new FormData();
formData.append("ref_audio", fs.createReadStream("ref.wav"));
formData.append("gen_text", "Hello world, this is F5-TTS from Node.js!");
const response = await axios.post("http://localhost:8000/tts", formData, {
headers: formData.getHeaders(),
responseType: "arraybuffer",
});
fs.writeFileSync("output.wav", response.data);
console.log("✅ Audio saved as output.wav");
};
runTTS().catch(console.error);| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Model/device info |
POST |
/tts |
High-quality text-to-speech |
POST |
/tts-fast |
Fast inference (lower quality) |
POST |
/tts-stream |
Real-time WAV streaming |
POST |
/tts-stream-chunked |
Chunked MP3 streaming |
GET |
/ |
Root status |
GET |
/mock-audio.mp3 |
Sample mock audio (for dev) |
- Uses pretrained model:
SWivid/F5-TTS/F5TTS_v1_Base - Auto-detects GPU (CUDA) if available
- Output files saved to
/generatedfolder
Noman Nazir — Linkedin
AI-Powered Software & SaaS Solutions
MIT License — Feel free to use, modify, and contribute!