images for https://github.com/breakstring/Spark-TTS
3.1K
Official PyTorch code for inference of
Spark-TTS: An Efficient LLM-Based Text-to-Speech Model with Single-Stream Decoupled Speech Tokens
Spark-TTS is an advanced text-to-speech system that uses the power of large language models (LLM) for highly accurate and natural-sounding voice synthesis. It is designed to be efficient, flexible, and powerful for both research and production use.
Inference Overview of Voice Cloning![]() |
Inference Overview of Controlled Generation![]() |
Clone and Install
Here are instructions for installing on Linux. If you're on Windows, please refer to the Windows Installation Guide.
(Thanks to @AcTePuKc for the detailed Windows instructions!)
git clone https://github.com/SparkAudio/Spark-TTS.git
cd Spark-TTS
conda create -n sparktts -y python=3.12
conda activate sparktts
pip install -r requirements.txt
# If you are in mainland China, you can set the mirror as follows:
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
Model Download
Download via python:
from huggingface_hub import snapshot_download
snapshot_download("SparkAudio/Spark-TTS-0.5B", local_dir="pretrained_models/Spark-TTS-0.5B")
Download via git clone:
mkdir -p pretrained_models
# Make sure you have git-lfs installed (https://git-lfs.com)
git lfs install
git clone https://huggingface.co/SparkAudio/Spark-TTS-0.5B pretrained_models/Spark-TTS-0.5B
Basic Usage
You can simply run the demo with the following commands:
cd example
bash infer.sh
Alternatively, you can directly execute the following command in the command line to perform inference:
python -m cli.inference \
--text "text to synthesis." \
--device 0 \
--save_dir "path/to/save/audio" \
--model_dir pretrained_models/Spark-TTS-0.5B \
--prompt_text "transcript of the prompt audio" \
--prompt_speech_path "path/to/prompt_audio"
Web UI Usage
You can start the UI interface by running python webui.py --device 0, which allows you to perform Voice Cloning and Voice Creation. Voice Cloning supports uploading reference audio or directly recording the audio.
| Voice Cloning | Voice Creation |
|---|---|
![]() | ![]() |
Optional Methods
For additional CLI and Web UI methods, including alternative implementations and extended functionalities, you can refer to:
API Service
Spark-TTS provides a FastAPI-based web API service for seamless integration with other applications.
Running the API service in conda environment:
# Make sure you're in the Spark-TTS conda environment
conda activate sparktts
# Execute from the project root directory
./api/run_api.sh
The API will be available at http://localhost:7860 by default.
Docker support: You can build and run the Spark-TTS API using the provided build script:
# Build Docker images (both full and lite versions)
chmod +x docker_builder.sh
./docker_builder.sh
# Run the API service in the background
docker compose up -d api
# OR for the lite version with mounted models
docker compose up -d api-lite
# Run the WebUI service in the background
docker compose up -d webui
# OR for the lite version with mounted models
docker compose up -d webui-lite
# To check running containers
docker compose ps
# To stop services
docker compose down
Note: If you encounter YAML errors like
mapping key "<<" already defined, it might be due to compatibility issues with YAML merge keys in your Docker Compose version. You can either:
- Update Docker to the latest version
- Modify the docker-compose.yml file to use a different syntax for environment variable inheritance
- Use the Docker CLI directly:
docker run -p 7860:7860 --gpus all spark-tts:latest-full
For more customization options, see the environment variables in the docker-compose.yml file.
Client Example: The repository includes an example client script that demonstrates how to interact with the API:
# Note: The example client requires librosa, which is not in requirements.txt
pip install librosa
# Basic usage
python api/example_client.py --text "Text to synthesize"
# Voice cloning with reference audio
python api/example_client.py --text "This is voice cloning" --prompt_audio example/prompt_audio.wav
# Voice creation with parameters
python api/example_client.py --text "This is voice creation" --gender female --pitch high --speed moderate
For more detailed information about the API service, including all available endpoints and parameters, please refer to the API README.
Here are some demos generated by Spark-TTS using zero-shot voice cloning. For more demos, visit our demo page.
|
Donald Trump |
Zhongli (Genshin Impact) |
|
陈鲁豫 Chen Luyu |
杨澜 Yang Lan |
|
余承东 Richard Yu |
马云 Jack Ma |
|
刘德华 Andy Lau |
徐志胜 Xu Zhisheng |
|
哪吒 Nezha |
李靖 Li Jing |
@misc{wang2025sparktts,
title={Spark-TTS: An Efficient LLM-Based Text-to-Speech Model with Single-Stream Decoupled Speech Tokens},
author={Xinsheng Wang and Mingqi Jiang and Ziyang Ma and Ziyu Zhang and Songxiang Liu and Linqin Li and Zheng Liang and Qixi Zheng and Rui Wang and Xiaoqin Feng and Weizhen Bian and Zhen Ye and Sitong Cheng and Ruibin Yuan and Zhixian Zhao and Xinfa Zhu and Jiahao Pan and Liumeng Xue and Pengcheng Zhu and Yunlin Chen and Zhifei Li and Xie Chen and Lei Xie and Yike Guo and Wei Xue},
year={2025},
eprint={2503.01710},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2503.01710},
}
This project provides a zero-shot voice cloning TTS model intended for academic research, educational purposes, and legitimate applications, such as personalized speech synthesis, assistive technologies, and linguistic research.
Please note:
Do not use this model for unauthorized voice cloning, impersonation, fraud, scams, deepfakes, or any illegal activities.
Ensure compliance with local laws and regulations when using this model and uphold ethical standards.
The developers assume no liability for any misuse of this model.
We advocate for the responsible development and use of AI and encourage the community to uphold safety and ethical principles in AI research and applications. If you have any concerns regarding ethics or misuse, please contact us.
Content type
Image
Digest
sha256:2d8eae6e9…
Size
9.3 GB
Last updated
over 1 year ago
docker pull breakstring/spark-tts