文生音乐模型人人可发单曲,DiffRhythm本地部署全实录
ztj100 2025-05-26 20:19 17 浏览 0 评论
一、前言
DiffRhythm(中文:谛韵,Dì Yùn)是第一个开源的基于扩散的音乐生成模型,能够创建完整的歌曲。该名称结合了 “Diff” (引用其扩散架构) 和 “Rhythm” (突出其对音乐和歌曲创作的关注)。中文名称 谛韵 (Dì Yùn) 在发音上反映了 “DiffRhythm”,其中 “谛” (专心聆听) 象征听觉感知,“韵” (旋律魅力) 代表音乐性。
主要有下面两个模型,base可以生成1分35秒的音乐,full版可以生成长音乐,按需选择,本次测试使用base版。
模型名称 | 下载地址 |
DiffRhythm-base (1 分 35 秒) | https://huggingface.co/ASLP-lab/DiffRhythm-base |
DiffRhythm-full (4 分 45 秒) | https://huggingface.co/ASLP-lab/DiffRhythm-full |
没有梯子把前端的域名换为https://hf-mirror.com
软硬件环境 :
名称 | 参数 |
显卡 | RTX 3090 24GB |
内存 | 64GB DDR5 |
系统 | windows11 wsl2 ubuntu24 |
二、部署
下载DiffRhythm
cd /data/
sudo git clone https://github.com/ASLP-lab/DiffRhythm.git
cd DiffRhythm
安装espeek-ng组件
## espeak-ng
# For Debian-like distribution (e.g. Ubuntu, Mint, etc.)
sudo apt-get install espeak-ng
# For RedHat-like distribution (e.g. CentOS, Fedora, etc.)
sudo yum install espeak-ng
# For MacOS
brew install espeak-ng
创建python运行虚拟环境,安装依赖
## 这里使用conda创建,如果不支持可以单独配置一下
conda create -n diffrhythm python=3.10
conda activate diffrhythm
#安装所需要的依赖,指定国内源就会秒成功
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
下载DiffRhythm-base模型
cd /data/DiffRhythm
sudo git clone https://hf-mirror.com/ASLP-lab/DiffRhythm-base ASLP-lab/DiffRhythm-base
生成音乐
python infer/infer.py --lrc-path infer/example/eg_cn.lrc --ref-audio-path infer/example/eg_cn.wav --audio-length 95 --repo_id ASLP-lab/DiffRhythm-base --output-dir infer/example/output --chunked
首先运行会很慢,要下载需要下载pytorch,还有可能报错,比如缺少模块,我这里缺少py3langid,使用下面命令安装即可。
pip install py3langid -i https://pypi.tuna.tsinghua.edu.cn/simple
还有可能无法下载,因为网络问题,报错如下:关键错是:network is unreachable
python infer/infer.py --lrc-path infer/example/eg_cn.lrc --ref-audio-path infer/example/eg_cn.wav --audio-length 95 --repo_id ASLP-lab/DiffRhythm-base --output-dir infer/example/output --chunked
Current working directory: /data/DiffRhythm-main
Traceback (most recent call last):
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/connection.py", line 198, in _new_conn
sock = connection.create_connection(
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
OSError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
response = self._make_request(
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 488, in _make_request
raise new_e
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 464, in _make_request
self._validate_conn(conn)
File "/home/chuan/miniconda3/envs/diffrhythm/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1093, in _validate_conn
conn.connect()
可以临时设置一下环境变量:
export HF_ENDPOINT=https://hf-mirror.com
#然后再执行生成音乐脚本
python infer/infer.py --lrc-path infer/example/eg_cn.lrc --ref-audio-path infer/example/eg_cn.wav --audio-length 95 --repo_id ASLP-lab/DiffRhythm-base --output-dir infer/example/output --chunked
参数解释:
--lrc-path lrc歌词的完整地址,你可以从网上下载lrc歌词或者使用模型生成lrc歌曲,放到指定的目录即可,这里有很多歌词https://www.wagequ.com/
--ref-audio-path 引用参考的音乐,生成的音乐会与这个参数音乐在旋律上有很大相同之处,具体自己可以测试,这个参考音乐可以从网上下载,我找到一个网站在这里分享一下。https://www.xmwav.com/
--audio-length 音乐的长度,base模型最大支持95秒,full最大支持285秒
--repo_id 指定模型,当前使用是base模型
--output-dir 生成的音乐输出的目录,在这个目录里会生成一个output.wav的文件,下载就可以播放了
在这里可以试用:
https://huggingface.co/spaces/ASLP-lab/DiffRhythm
如下我放了一个《下一个天亮》的歌词
三、后话
1、看试用地址里高级设置还能设置输出格式如mp3,还能配置seed、diffusion steps、CFG Strength等。
2、现在还不支持docker部署,从作者的TODO可以看出以后也会支持
TODOs
- Dynamic length control
- Vocals only
- Song extension
- Support Colab.
- Support Docker.
- Release DiffRhythm-full.
- Release training code.
- Support local deployment.
- Release paper to Arxiv.
- Online serving on Hugging Face Space.
创作不易 点赞 关注 收藏
相关推荐
- 10条军规:电商API从数据泄露到高可用的全链路防护
-
电商API接口避坑指南:数据安全、版本兼容与成本控制的10个教训在电商行业数字化转型中,API接口已成为连接平台、商家、用户与第三方服务的核心枢纽。然而,从数据泄露到版本冲突,从成本超支到系统崩溃,A...
- Python 文件处理在实际项目中的困难与应对策略
-
在Python项目开发,文件处理是一项基础且关键的任务。然而,在实际项目中,Python文件处理往往会面临各种各样的困难和挑战,从文件格式兼容性、编码问题,到性能瓶颈、并发访问冲突等。本文将深入...
- The Future of Manufacturing with Custom CNC Parts
-
ThefutureofmanufacturingisincreasinglybeingshapedbytheintegrationofcustomCNC(ComputerNumericalContro...
- Innovative Solutions in Custom CNC Machining
-
Inrecentyears,thelandscapeofcustomCNCmachininghasevolvedrapidly,drivenbyincreasingdemandsforprecisio...
- C#.NET serilog 详解(c# repository)
-
简介Serilog是...
- Custom CNC Machining for Small Batch Production
-
Inmodernmanufacturing,producingsmallbatchesofcustomizedpartshasbecomeanincreasinglycommondemandacros...
- Custom CNC Machining for Customized Solutions
-
Thedemandforcustomizedsolutionsinmanufacturinghasgrownsignificantly,drivenbydiverseindustryneedsandt...
- Revolutionizing Manufacturing with Custom CNC Parts
-
Understandinghowmanufacturingisevolving,especiallythroughtheuseofcustomCNCparts,canseemcomplex.Thisa...
- Breaking Boundaries with Custom CNC Parts
-
BreakingboundarieswithcustomCNCpartsinvolvesexploringhowadvancedmanufacturingtechniquesaretransformi...
- Custom CNC Parts for Aerospace Industry
-
Intherealmofaerospacemanufacturing,precisionandreliabilityareparamount.Thecomponentsthatmakeupaircra...
- Cnc machining for custom parts and components
-
UnderstandingCNCmachiningforcustompartsandcomponentsinvolvesexploringitsprocesses,advantages,andcomm...
- 洞察宇宙(十八):深入理解C语言内存管理
-
分享乐趣,传播快乐,增长见识,留下美好。亲爱的您,这里是LearingYard学苑!今天小编为大家带来“深入理解C语言内存管理”...
- The Art of Crafting Custom CNC Parts
-
UnderstandingtheprocessofcreatingcustomCNCpartscanoftenbeconfusingforbeginnersandevensomeexperienced...
- Tailored Custom CNC Solutions for Automotive
-
Intheautomotiveindustry,precisionandefficiencyarecrucialforproducinghigh-qualityvehiclecomponents.Ta...
- 关于WEB服务器(.NET)一些经验累积(一)
-
以前做过技术支持,把一些遇到的问题累积保存起来,现在发出了。1.问题:未能加载文件或程序集“System.EnterpriseServices.Wrapper.dll”或它的某一个依赖项。拒绝访问。解...
你 发表评论:
欢迎- 一周热门
- 最近发表
-
- 10条军规:电商API从数据泄露到高可用的全链路防护
- Python 文件处理在实际项目中的困难与应对策略
- The Future of Manufacturing with Custom CNC Parts
- Innovative Solutions in Custom CNC Machining
- C#.NET serilog 详解(c# repository)
- Custom CNC Machining for Small Batch Production
- Custom CNC Machining for Customized Solutions
- Revolutionizing Manufacturing with Custom CNC Parts
- Breaking Boundaries with Custom CNC Parts
- Custom CNC Parts for Aerospace Industry
- 标签列表
-
- idea eval reset (50)
- vue dispatch (70)
- update canceled (42)
- order by asc (53)
- spring gateway (67)
- 简单代码编程 贪吃蛇 (40)
- transforms.resize (33)
- redisson trylock (35)
- 卸载node (35)
- np.reshape (33)
- torch.arange (34)
- npm 源 (35)
- vue3 deep (35)
- win10 ssh (35)
- vue foreach (34)
- idea设置编码为utf8 (35)
- vue 数组添加元素 (34)
- std find (34)
- tablefield注解用途 (35)
- python str转json (34)
- java websocket客户端 (34)
- tensor.view (34)
- java jackson (34)
- vmware17pro最新密钥 (34)
- mysql单表最大数据量 (35)