
GitHub:https://github.com/SparkAudio/Spark-TTS
Spark-TTS是一个先进的文本到语音系统,它利用大型语言模型(LLM)的强大功能进行高度准确和自然的语音合成;旨在高效、灵活、强大地用于研究和生产用途。
一、介绍
Spark TTS完全基于Qwen2.5构建,无需额外的生成模型,它不依赖于单独的模型来生成声学特征,而是直接从LLM预测的代码中重建音频。这种方法简化了流程,提高了效率并降低了复杂性;支持零样本语音克隆,它可以直接复制说话者的语音。这是跨语言和代码转换场景的理想选择,允许语言和语音之间的无缝转换,而不需要对每种语言进行单独的培训;支持中文和英文两种语言,使模型能够以高自然度和准确性合成多种语言的语音;支持通过调整性别、音高和语速等参数来创建虚拟说话者。
二、安装
2.1 克隆项目
bash
git clone https://github.com/SparkAudio/Spark-TTS.git
cd Spark-TTS
2.2 构建环境依赖
bash
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
PS:官方推荐python3.12,但是我这边使用3.12环境一直安装失败,所以我选择3.11.11,和我一样问题的同学可以尝试一下降低python版本 ;
2.3 下载预训练模型
bash
mkdir pretrained_models && cd pretrained_models
# 安装大文件拉取工具
git lfs install
# 从Modelscpoe上下载模型
git clone https://www.modelscope.cn/SparkAudio/Spark-TTS-0.5B.git
三、运行
3.1 终端运行
python
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"
上面是在终端的运行代码,项目中给出了一个运行事例,我们结合这个运行事例来具体看一下每个参数代表的含义,下面就是example/infer.sh的文件内容:
bash
#!/bin/bash
# Copyright (c) 2025 SparkAudio
# 2025 Xinsheng Wang (w.xinshawn@gmail.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Get the absolute path of the script's directory
script_dir=$(dirname "$(realpath "$0")")
# Get the root directory
root_dir=$(dirname "$script_dir")
# Set default parameters
device=0
save_dir='example/results'
model_dir="pretrained_models/Spark-TTS-0.5B"
text="身临其境,换新体验。塑造开源语音合成新范式,让智能语音更自然。"
prompt_text="吃燕窝就选燕之屋,本节目由26年专注高品质燕窝的燕之屋冠名播出。豆奶牛奶换着喝,营养更均衡,本节目由豆本豆豆奶特约播出。"
prompt_speech_path="example/prompt_audio.wav"
# Change directory to the root directory
cd "$root_dir" || exit
source sparktts/utils/parse_options.sh
# Run inference
python -m cli.inference \
--text "${text}" \
--device "${device}" \
--save_dir "${save_dir}" \
--model_dir "${model_dir}" \
--prompt_text "${prompt_text}" \
--prompt_speech_path "${prompt_speech_path}"
|--------------------|--------------|
| 传参 | 含义 |
| text | 需要克隆语音所对应的文本 |
| device | 指定显卡编号 |
| save_dir | 克隆语音的保存路径 |
| model_dir | 大模型的保存路径 |
| prompt_text | 样本语音的文本信息 |
| prompt_speech_path | 样本语音的保存路径 |
3.2 WebUI
3.2.1 启动
看到如下界面表示启动成功,在本地通过浏览器访问红框的网址;
bash
# 在终端运行:
python webui.py --device 0
3.2.2 克隆
看到如下界面,黄框是语音克隆功能区:

序号一:上传本地待克隆的语音样本(好像不支持m4a格式,最好上传wav格式);
序号二:可以在线录制需要克隆的人的声音(1、2选择一个就可以);
序号三:添加需要克隆语音的文本,即命令行运行中的'text'参数;
序号四:上传或者录音的语音所对应的文本信息;
序号五:生成克隆语音的展示区;
序号六:上述1-4信息填写完成后点击开始克隆;
3.2.3 语音创作
看到如下界面,黄框是语音创作功能区:

序号一:可以选择生成语音的性别;
序号二:调整生成语音的音调;
序号三:调整生成语音的语速;
序号四:输入生成语音的文本信息;
序号五:点击开始创作,生成结果会展示在下方;
四、总结
整体体验感觉推理速度还是比较快的,但是在功能性上还是在效果上都有所欠缺;语音处理功能相较于之前测试的FunASR显得就比较单一;在克隆的效果上相较于之前测试的StepAudio也略有逊色;大家可以尝试一下,进行一下比较~