voicebox-pytorch

voicebox-pytorch

新一代MetaAI文本到语音模型Voicebox的Pytorch实现

该项目实现了MetaAI的最新文本到语音模型Voicebox,利用旋转嵌入和自适应归一化技术提升模型效果。还融合了SpearTTS和Conditioned Flow Matching等技术,提高训练和采样效率。项目获得Imminent Grant资助,致力于推动开源文本到语音技术的发展,并感谢各大赞助商的支持。用户可以通过pip install命令轻松安装和使用该项目。

VoiceboxPytorchText-to-SpeechMetaAISpear-TTSGithub开源项目

<img src="https://yellow-cdn.veclightyear.com/35dd4d3f/77381b51-b605-41e2-a9c7-76c9ec359c7f.png" width="400px"></img>

Voicebox - Pytorch

在Pytorch中实现<a href="https://arxiv.org/abs/2306.15687">Voicebox</a>,来自MetaAI的新一代文本转语音模型。<a href="https://about.fb.com/news/2023/06/introducing-voicebox-ai-for-speech-generation/">新闻稿</a>

在这项工作中,我们将使用旋转嵌入。作者似乎没有意识到ALiBi不能简单地用于双向模型。

该论文还解决了时间嵌入错误地受到相对距离影响的问题(他们沿音频令牌的帧维度连接时间嵌入)。这个库将使用自适应归一化,正如在<a href="https://arxiv.org/abs/2211.07292">Paella</a>中成功应用的那样。

感谢

  • 感谢<a href="https://translated.com"><img style="vertical-align: middle;" src="https://yellow-cdn.veclightyear.com/35dd4d3f/75d53761-8018-4c3b-8ca1-53570fe306cd.png" height="20px" alt="Translated"><img></a>授予我<a href="https://imminent.translated.com/research-grants-ceremony-innovations-in-language-technology">Imminent Grant</a>,以推进开源码文本转语音解决方案的状态。本项目在这项资助下启动并将完成。

  • 感谢<a href="https://stability.ai/">StabilityAI</a>的慷慨赞助,以及我的其他赞助商,使我能够有独立性开发开源人工智能。

  • 感谢<a href="https://github.com/b-chiang">Bryan Chiang</a>的持续代码审查,分享他在TTS方面的专业知识,并指引我到<a href="https://github.com/atong01/conditional-flow-matching">一个开源实现</a>的条件流匹配中。

  • 感谢<a href="https://github.com/manmay-nakhashi">Manmay</a>帮助这个库以对齐代码开始。

  • 感谢<a href="https://github.com/chenht2010">@chenht2010</a>发现旋转位置的一个bug,并验证库中的代码可以收敛。

  • 感谢<a href="https://github.com/lucasnewman">Lucas Newman</a>(再次)提交了所有用于Spear-TTS条件Voicebox训练的训练代码的pull request!

  • 感谢<a href="https://github.com/lucasnewman">Lucas Newman</a>展示了整个系统在Spear-TTS条件下运行正常。训练收敛效果比<a href="https://github.com/lucidrains/soundstorm-pytorch">Soundstorm</a>还要好。

安装

$ pip install voicebox-pytorch

使用

使用<a href="https://github.com/lucidrains/spear-tts-pytorch">SpearTTS</a>中的TextToSemantic模块进行训练和采样

import torch from voicebox_pytorch import ( VoiceBox, EncodecVoco, ConditionalFlowMatcherWrapper, HubertWithKmeans, TextToSemantic ) # https://github.com/facebookresearch/fairseq/tree/main/examples/hubert wav2vec = HubertWithKmeans( checkpoint_path = '/path/to/hubert/checkpoint.pt', kmeans_path = '/path/to/hubert/kmeans.bin' ) text_to_semantic = TextToSemantic( wav2vec = wav2vec, dim = 512, source_depth = 1, target_depth = 1, use_openai_tokenizer = True ) text_to_semantic.load('/path/to/trained/spear-tts/model.pt') model = VoiceBox( dim = 512, audio_enc_dec = EncodecVoco(), num_cond_tokens = 500, depth = 2, dim_head = 64, heads = 16 ) cfm_wrapper = ConditionalFlowMatcherWrapper( voicebox = model, text_to_semantic = text_to_semantic ) # 模拟数据 audio = torch.randn(2, 12000) # 训练 loss = cfm_wrapper(audio) loss.backward() # 经过大量训练之后 texts = [ '西班牙的雨水主要落在平原上', '她在海边卖海贝壳' ] cond = torch.randn(2, 12000) sampled = cfm_wrapper.sample(cond = cond, texts = texts) # (2, 1, <音频长度>)

对于无条件训练,VoiceBox上的condition_on_text必须设置为False

import torch from voicebox_pytorch import ( VoiceBox, ConditionalFlowMatcherWrapper ) model = VoiceBox( dim = 512, num_cond_tokens = 500, depth = 2, dim_head = 64, heads = 16, condition_on_text = False ) cfm_wrapper = ConditionalFlowMatcherWrapper( voicebox = model ) # 模拟数据 x = torch.randn(2, 1024, 512) # 训练 loss = cfm_wrapper(x) loss.backward() # 经过大量训练之后 cond = torch.randn(2, 1024, 512) sampled = cfm_wrapper.sample(cond = cond) # (2, 1024, 512)

待办事项

  • 阅读并内化原始流匹配论文

    • 基本损失
    • 使神经ODE在torchdyn中工作
  • 获取带有0.2-0.3的p_drop的基本掩码生成逻辑用于ICL

  • 处理p_drop,不同于voicebox和持续时间模型

  • 支持torchdiffeq和torchode

  • 切换到自适应rmsnorm用于时间调节

  • 添加encodec / voco作为起步

  • 设置原始音频的训练和采样,如果传入audio_enc_dec

  • 与对数mel频谱/encodec - vocos整合

  • spear-tts集成

  • 基本加速训练器 - 感谢@lucasnewman!

  • 清理NS2对齐器类,然后设置持续时间预测训练

  • 找出MelVoco编码的正确设置,因为重构的音频长度较长

  • 计算每帧对应的秒数,并在AudioEncoderDecoder上添加为属性 - 采样时允许指定秒数

引用

@article{Le2023VoiceboxTM, title = {Voicebox: Text-Guided Multilingual Universal Speech Generation at Scale}, author = {Matt Le and Apoorv Vyas and Bowen Shi and Brian Karrer and Leda Sari and Rashel Moritz and Mary Williamson and Vimal Manohar and Yossi Adi and Jay Mahadeokar and Wei-Ning Hsu}, journal = {ArXiv}, year = {2023}, volume = {abs/2306.15687}, url = {https://api.semanticscholar.org/CorpusID:259275061} }
@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} }
@misc{torchdiffeq, author = {Chen, Ricky T. Q.}, title = {torchdiffeq}, year = {2018}, url = {https://github.com/rtqichen/torchdiffeq}, }
@inproceedings{lienen2022torchode, title = {torchode: A Parallel {ODE} Solver for PyTorch}, author = {Marten Lienen and Stephan G{\"u}nnemann}, booktitle = {The Symbiosis of Deep Learning and Differential Equations II, NeurIPS}, year = {2022}, url = {https://openreview.net/forum?id=uiKVKTiUYB0} }
@article{siuzdak2023vocos, title = {Vocos: Closing the gap between time-domain and Fourier-based neural vocoders for high-quality audio synthesis}, author = {Siuzdak, Hubert}, journal = {arXiv preprint arXiv:2306.00814}, year = {2023} }
@misc{darcet2023vision, title = {Vision Transformers Need Registers}, author = {Timothée Darcet and Maxime Oquab and Julien Mairal and Piotr Bojanowski}, year = {2023}, eprint = {2309.16588}, archivePrefix = {arXiv}, primaryClass = {cs.CV} }
@inproceedings{Dehghani2023ScalingVT, title = {Scaling Vision Transformers to 22 Billion Parameters}, author = {Mostafa Dehghani and Josip Djolonga and Basil Mustafa and Piotr Padlewski and Jonathan Heek and Justin Gilmer and Andreas Steiner and Mathilde Caron and Robert Geirhos and Ibrahim M. Alabdulmohsin and Rodolphe Jenatton and Lucas Beyer and Michael Tschannen and Anurag Arnab and Xiao Wang and Carlos Riquelme and Matthias Minderer and Joan Puigcerver and Utku Evci and Manoj Kumar and Sjoerd van Steenkiste and Gamaleldin F. Elsayed and Aravindh Mahendran and Fisher Yu and Avital Oliver and Fantine Huot and Jasmijn Bastings and Mark Collier and Alexey A. Gritsenko and Vighnesh Birodkar and Cristina Nader Vasconcelos and Yi Tay and Thomas Mensink and Alexander Kolesnikov and Filip Paveti'c and Dustin Tran and Thomas Kipf and Mario Luvci'c and Xiaohua Zhai and Daniel Keysers and Jeremiah Harmsen and Neil Houlsby}, booktitle = {International Conference on Machine Learning}, year = {2023}, url = {https://api.semanticscholar.org/CorpusID:256808367} }
@inproceedings{Katsch2023GateLoopFD, title = {GateLoop: Fully Data-Controlled Linear Recurrence for Sequence Modeling}, author = {Tobias Katsch}, year = {2023}, url = {https://api.semanticscholar.org/CorpusID:265018962} }

编辑推荐精选

扣子-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工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具酷表ChatExcelAI智能客服AI营销产品使用教程
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

AI辅助写作AI工具AI论文工具论文写作智能生成大纲数据安全AI助手热门
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

AI办公办公工具AI工具博思AIPPTAI生成PPT智能排版海量精品模板AI创作热门
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

下拉加载更多