写在前面:本博客仅作记录学习之用,部分图片来自网络,如需引用请注明出处,同时如有侵犯您的权益,请联系删除!
文章目录
前言
声音克隆,即通过人工智能深度模拟特定个体的音色、语调与情感表达,实现高度逼真的语音再造。其诞生源于人类对语音合成技术的极致追求:从20世纪80年代的拼接合成法,到深度学习时代基于端到端神经网络(如WaveNet、Tacotron)的突破,技术已能捕捉微至声纹震颤的声学特征。这项前沿技术正颠覆传统应用场景——从影视配音的“数字替身”到虚拟主播的情感交互,从个性化导航语音到医疗领域的失声患者复声,其商业价值与社会意义并蓄。
Spark-TTS
论文名: Spark-TTS: An Efficient LLM-Based Text-to-Speech Model with Single-Stream Decoupled Speech Tokens
论文速递: 点我转跳哦
代码通道: GitHub
安装
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
运行
- 下载模型
创建一个python文件。内容如下:
from huggingface_hub import snapshot_download
snapshot_download("SparkAudio/Spark-TTS-0.5B", local_dir="pretrained_models/Spark-TTS-0.5B")
运行该文件即可,如遇huggingface_hub.errors
错误,可参考后文的解决办法。
或者使用Git克隆。如下:
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
- 克隆声音
直接在可视化界面中展示:
python webui.py --device 0
上传或者录制一段声音,进行声音克隆,支持中文。
错误及解决方法
huggingface_hub.errors
报错信息
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache.
解决办法:
在yourpath\envs\sparktts\Lib\site-packages\huggingface_hub\__init__.py
添加os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
;修改后内容如下:
import importlib
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com" ## 这是添加的
import sys
from typing import TYPE_CHECKING
localhost is not accessible
报错信息:
When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.
解决办法:
关闭代理(梯子)并在webui.py
=>demo.launch
添加share=True,
如下:
# Launch Gradio with the specified server name and port
demo.launch(
share=True,
server_name=args.server_name,
server_port=args.server_port
)
http://0.0.0.0:7860无法转跳
报错信息:
http://0.0.0.0:7860无法访问
回环地址无法成功识别,默认0.0.0.0,local host一般是127.0.0.1
,指定端口即可。
如下:
parser.add_argument(
"--server_name",
type=str,
default="127.0.0.1",
help="Server host/IP for Gradio app."
)
总结
总结: 本文主要讲解了从克隆Spark-TTS库到进行声音克隆的过程,包括安装依赖、下载权重、UI界面及问题解决等。
互动
你觉得声音克隆的伦理方面争议严重吗?
欢迎在评论区解答上述问题,分享你的经验和疑问!
当然,也欢迎一键三连给我鼓励和支持:👍点赞 📁 关注 💬评论。
致谢
欲尽善本文,因所视短浅,怎奈所书皆是瞽言蒭议。行文至此,诚向予助与余者致以谢意。
参考
[1] 【已解决 huggingface_hub.errors.LocalEntryNotFoundError:】
[2] 报错解决:“ ValueError: When localhost is not accessible, a shareable link must be created. Please set
往期回顾
![]() 👆 DeepSeek本地化部署保姆级教程👆 | ![]() 👆 EfficientTrain++帮你降低网络训练的成本👆 | ![]() 👆 PyCharm环境下Git与Gitee联动👆 |
![]() 👆 Ping通但SSH连接失败的解决办法👆 | ![]() 👆 轻量化设计如何提高模型的推理速度👆 | ![]() 👆 正则化与正则剪枝👆 |