naturalspeech2-pytorch

naturalspeech2-pytorch

NaturalSpeech 2在PyTorch中的开源实现

NaturalSpeech 2是一个基于PyTorch的开源项目,实现了零样本语音和歌唱合成。该项目采用神经音频编解码器和潜在扩散模型,结合非自回归生成和去噪扩散技术,实现高质量的文本到语音转换。项目还优化了注意力机制和Transformer组件,为研究人员和开发者提供了探索先进TTS技术的平台。

语音合成深度学习自然语音Pytorch零样本学习Github开源项目

<img src="https://yellow-cdn.veclightyear.com/835a84d5/33c98f2d-d115-41ff-9fc5-22039bd009d6.png" width="450px"></img>

<img src="https://yellow-cdn.veclightyear.com/835a84d5/bff28fdf-79f5-4096-91f1-278cf74281f3.png" width="450px"></img>

Natural Speech 2 - Pytorch(进行中)

在Pytorch中实现<a href="https://arxiv.org/abs/2304.09116">Natural Speech 2</a>,零样本语音和歌唱合成器

NaturalSpeech 2是一个TTS系统,它利用具有连续潜在向量的神经音频编解码器和具有非自回归生成的潜在扩散模型,实现自然和零样本文本到语音合成

本仓库将使用去噪扩散而非基于分数的SDE,并可能提供阐明版本。它还将在适用的情况下为注意力/transformer组件提供改进。

致谢

  • 感谢<a href="https://stability.ai/">Stability</a><a href="https://huggingface.co/">🤗 Huggingface</a>慷慨赞助,支持我们研究和开源前沿人工智能

  • 感谢<a href="https://huggingface.co/">🤗 Huggingface</a>提供了出色的accelerate库

  • 感谢<a href="https://github.com/manmay-nakhashi">Manmay</a>提交了音素、音高、持续时间和语音提示编码器的初始代码,以及多语言音素器和音素对齐器!

  • 感谢<a href="https://github.com/manmay-nakhashi">Manmay</a>完成了扩散网络的端到端条件控制连接!

  • 你呢?如果你是一位有抱负的ML/AI工程师或从事TTS领域的工作,并希望为开源最先进的技术做出贡献,那就加入进来吧!

安装

$ pip install naturalspeech2-pytorch

使用方法

import torch from naturalspeech2_pytorch import ( EncodecWrapper, Model, NaturalSpeech2 ) # 以encodec为例 codec = EncodecWrapper() model = Model( dim = 128, depth = 6 ) # natural speech 扩散模型 diffusion = NaturalSpeech2( model = model, codec = codec, timesteps = 1000 ).cuda() # 模拟原始音频数据 raw_audio = torch.randn(4, 327680).cuda() loss = diffusion(raw_audio) loss.backward() # 对大量原始音频数据重复上述操作... # 然后你可以从你的生成模型中采样,如下所示 generated_audio = diffusion.sample(length = 1024) # (1, 327680)

带条件控制的示例:

import torch from naturalspeech2_pytorch import ( EncodecWrapper, Model, NaturalSpeech2, SpeechPromptEncoder ) # 以encodec为例 codec = EncodecWrapper() model = Model( dim = 128, depth = 6, dim_prompt = 512, cond_drop_prob = 0.25, # 以此概率丢弃提示条件,用于无分类器引导 condition_on_prompt = True ) # natural speech 扩散模型 diffusion = NaturalSpeech2( model = model, codec = codec, timesteps = 1000 ) # 模拟原始音频数据 raw_audio = torch.randn(4, 327680) prompt = torch.randn(4, 32768) # 他们在训练过程中随机截取了音频范围作为提示,最终会自动处理这个问题 text = torch.randint(0, 100, (4, 100)) text_lens = torch.tensor([100, 50 , 80, 100]) # 前向和后向传播 loss = diffusion( audio = raw_audio, text = text, text_lens = text_lens, prompt = prompt ) loss.backward() # 经过充分训练后 generated_audio = diffusion.sample( length = 1024, text = text, prompt = prompt ) # (1, 327680)

或者,如果你想要一个Trainer类来处理训练和采样循环,只需简单地这样做:

from naturalspeech2_pytorch import Trainer trainer = Trainer( diffusion_model = diffusion, # 上面的扩散模型 + 编解码器 folder = '/path/to/speech', train_batch_size = 16, gradient_accumulate_every = 2, ) trainer.train()

待办事项

  • 完成感知器然后在ddpm侧进行交叉注意力条件控制

  • 添加无分类器引导,即使论文中没有

  • 完成训练期间的持续时间/音高预测 - 感谢Manmay

  • 确保pyworld计算音高的方法也能工作

  • 就pyworld的使用咨询TTS领域的博士生

  • 如果可用,还提供使用spear-tts文本到语义模块的直接求和条件控制

  • 在ddpm侧添加自条件控制

  • 处理自动切片音频以获取提示,注意编解码器模型允许的最小音频段

  • 确保curtail_from_left适用于encodec,弄清楚他们在做什么

引用

@inproceedings{Shen2023NaturalSpeech2L, title = {NaturalSpeech 2: Latent Diffusion Models are Natural and Zero-Shot Speech and Singing Synthesizers}, author = {Kai Shen and Zeqian Ju and Xu Tan and Yanqing Liu and Yichong Leng and Lei He and Tao Qin and Sheng Zhao and Jiang Bian}, year = {2023} }
@misc{shazeer2020glu, title = {GLU Variants Improve Transformer}, author = {Noam Shazeer}, year = {2020}, url = {https://arxiv.org/abs/2002.05202} }
@inproceedings{dao2022flashattention, title = {Flash{A}ttention: Fast and Memory-Efficient Exact Attention with {IO}-Awareness}, author = {Dao, Tri and Fu, Daniel Y. and Ermon, Stefano and Rudra, Atri and R{\'e}, Christopher}, booktitle = {Advances in Neural Information Processing Systems}, year = {2022} }
@article{Salimans2022ProgressiveDF, title = {Progressive Distillation for Fast Sampling of Diffusion Models}, author = {Tim Salimans and Jonathan Ho}, journal = {ArXiv}, year = {2022}, volume = {abs/2202.00512} }
@inproceedings{Hang2023EfficientDT, title = {Efficient Diffusion Training via Min-SNR Weighting Strategy}, author = {Tiankai Hang and Shuyang Gu and Chen Li and Jianmin Bao and Dong Chen and Han Hu and Xin Geng and Baining Guo}, year = {2023} }
@article{Alayrac2022FlamingoAV, title = {Flamingo: a Visual Language Model for Few-Shot Learning}, author = {Jean-Baptiste Alayrac and Jeff Donahue and Pauline Luc and Antoine Miech and Iain Barr and Yana Hasson and Karel Lenc and Arthur Mensch and Katie Millican and Malcolm Reynolds and Roman Ring and Eliza Rutherford and Serkan Cabi and Tengda Han and Zhitao Gong and Sina Samangooei and Marianne Monteiro and Jacob Menick and Sebastian Borgeaud and Andy Brock and Aida Nematzadeh and Sahand Sharifzadeh and Mikolaj Binkowski and Ricardo Barreira and Oriol Vinyals and Andrew Zisserman and Karen Simonyan}, journal = {ArXiv}, year = {2022}, volume = {abs/2204.14198} }
@article{Badlani2021OneTA, title = {One TTS Alignment to Rule Them All}, author = {Rohan Badlani and Adrian Lancucki and Kevin J. Shih and Rafael Valle and Wei Ping and Bryan Catanzaro}, journal = {ICASSP 2022 - 2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)}, year = {2021}, pages = {6092-6096}, url = {https://api.semanticscholar.org/CorpusID:237277973} }

编辑推荐精选

音述AI

音述AI

全球首个AI音乐社区

音述AI是全球首个AI音乐社区,致力让每个人都能用音乐表达自我。音述AI提供零门槛AI创作工具,独创GETI法则帮助用户精准定义音乐风格,AI润色功能支持自动优化作品质感。音述AI支持交流讨论、二次创作与价值变现。针对中文用户的语言习惯与文化背景进行专门优化,支持国风融合、C-pop等本土音乐标签,让技术更好地承载人文表达。

QoderWork

QoderWork

阿里Qoder团队推出的桌面端AI智能体

QoderWork 是阿里推出的本地优先桌面 AI 智能体,适配 macOS14+/Windows10+,以自然语言交互实现文件管理、数据分析、AI 视觉生成、浏览器自动化等办公任务,自主拆解执行复杂工作流,数据本地运行零上传,技能市场可无限扩展,是高效的 Agentic 生产力办公助手。

lynote.ai

lynote.ai

一站式搞定所有学习需求

不再被海量信息淹没,开始真正理解知识。Lynote 可摘要 YouTube 视频、PDF、文章等内容。即时创建笔记,检测 AI 内容并下载资料,将您的学习效率提升 10 倍。

AniShort

AniShort

为AI短剧协作而生

专为AI短剧协作而生的AniShort正式发布,深度重构AI短剧全流程生产模式,整合创意策划、制作执行、实时协作、在线审片、资产复用等全链路功能,独创无限画布、双轨并行工业化工作流与Ani智能体助手,集成多款主流AI大模型,破解素材零散、版本混乱、沟通低效等行业痛点,助力3人团队效率提升800%,打造标准化、可追溯的AI短剧量产体系,是AI短剧团队协同创作、提升制作效率的核心工具。

seedancetwo2.0

seedancetwo2.0

能听懂你表达的视频模型

Seedance two是基于seedance2.0的中国大模型,支持图像、视频、音频、文本四种模态输入,表达方式更丰富,生成也更可控。

nano-banana纳米香蕉中文站

nano-banana纳米香蕉中文站

国内直接访问,限时3折

输入简单文字,生成想要的图片,纳米香蕉中文站基于 Google 模型的 AI 图片生成网站,支持文字生图、图生图。官网价格限时3折活动

扣子-AI办公

扣子-AI办公

职场AI,就用扣子

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

堆友

堆友

多风格AI绘画神器

堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。

图像生成AI工具AI反应堆AI工具箱AI绘画GOAI艺术字堆友相机AI图像热门
码上飞

码上飞

零代码AI应用开发平台

零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

下拉加载更多