[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-yl4579--StyleTTS2":3,"tool-yl4579--StyleTTS2":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":78,"owner_twitter":78,"owner_website":78,"owner_url":81,"languages":82,"stars":91,"forks":92,"last_commit_at":93,"license":94,"difficulty_score":95,"env_os":96,"env_gpu":97,"env_ram":98,"env_deps":99,"category_tags":108,"github_topics":109,"view_count":23,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":122,"updated_at":123,"faqs":124,"releases":159},3973,"yl4579\u002FStyleTTS2","StyleTTS2","StyleTTS 2: Towards Human-Level Text-to-Speech through Style Diffusion and Adversarial Training with Large Speech Language Models","StyleTTS 2 是一款旨在实现“人类级别”合成效果的文生语音（TTS）开源模型。它主要解决了传统语音合成在自然度上略显机械、以及多说话人场景下难以灵活适应不同音色的痛点，让机器生成的语音在听感上几乎无法与真人录音区分。\n\n这款工具特别适合语音技术研究人员、AI 开发者以及需要高质量语音素材的内容创作者使用。其核心亮点在于创新性地结合了“风格扩散模型”与“对抗训练”技术：无需参考录音，它能通过扩散模型自动为文本匹配最合适的语气风格；同时利用 WavLM 等大型语音语言模型作为判别器，显著提升了语音的自然流畅度。实验数据显示，StyleTTS 2 在单说话人数据集上已超越真人录音水平，在多说话人及零样本音色适配任务中也表现卓越，是目前公开模型中的佼佼者。无论是希望深入探索前沿 TTS 算法的研究者，还是寻求极致语音体验的开发者，StyleTTS 2 都提供了强大的技术支持和便捷的微调方案。","# StyleTTS 2: Towards Human-Level Text-to-Speech through Style Diffusion and Adversarial Training with Large Speech Language Models\n\n### Yinghao Aaron Li, Cong Han, Vinay S. Raghavan, Gavin Mischler, Nima Mesgarani\n\n> In this paper, we present StyleTTS 2, a text-to-speech (TTS) model that leverages style diffusion and adversarial training with large speech language models (SLMs) to achieve human-level TTS synthesis. StyleTTS 2 differs from its predecessor by modeling styles as a latent random variable through diffusion models to generate the most suitable style for the text without requiring reference speech, achieving efficient latent diffusion while benefiting from the diverse speech synthesis offered by diffusion models. Furthermore, we employ large pre-trained SLMs, such as WavLM, as discriminators with our novel differentiable duration modeling for end-to-end training, resulting in improved speech naturalness. StyleTTS 2 surpasses human recordings on the single-speaker LJSpeech dataset and matches it on the multispeaker VCTK dataset as judged by native English speakers. Moreover, when trained on the LibriTTS dataset, our model outperforms previous publicly available models for zero-shot speaker adaptation. This work achieves the first human-level TTS synthesis on both single and multispeaker datasets, showcasing the potential of style diffusion and adversarial training with large SLMs.\n\nPaper: [https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.07691](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.07691)\n\nAudio samples: [https:\u002F\u002Fstyletts2.github.io\u002F](https:\u002F\u002Fstyletts2.github.io\u002F)\n\nOnline demo: [Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fstyletts2\u002Fstyletts2) (thank [@fakerybakery](https:\u002F\u002Fgithub.com\u002Ffakerybakery) for the wonderful online demo)\n\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002F) [![Discord](https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1197679063150637117?logo=discord&logoColor=white&label=Join%20our%20Community)](https:\u002F\u002Fdiscord.gg\u002Fha8sxdG2K4)\n\n## TODO\n- [x] Training and inference demo code for single-speaker models (LJSpeech)\n- [x] Test training code for multi-speaker models (VCTK and LibriTTS)\n- [x] Finish demo code for multispeaker model and upload pre-trained models\n- [x] Add a finetuning script for new speakers with base pre-trained multispeaker models\n- [ ] Fix DDP (accelerator) for `train_second.py` **(I have tried everything I could to fix this but had no success, so if you are willing to help, please see [#7](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F7))**\n\n## Pre-requisites\n1. Python >= 3.7\n2. Clone this repository:\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2.git\ncd StyleTTS2\n```\n3. Install python requirements: \n```bash\npip install -r requirements.txt\n```\nOn Windows add:\n```bash\npip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118 -U\n```\nAlso install phonemizer and espeak if you want to run the demo:\n```bash\npip install phonemizer\nsudo apt-get install espeak-ng\n```\n4. Download and extract the [LJSpeech dataset](https:\u002F\u002Fkeithito.com\u002FLJ-Speech-Dataset\u002F), unzip to the data folder and upsample the data to 24 kHz. The text aligner and pitch extractor are pre-trained on 24 kHz data, but you can easily change the preprocessing and re-train them using your own preprocessing. \nFor LibriTTS, you will need to combine train-clean-360 with train-clean-100 and rename the folder train-clean-460 (see [val_list_libritts.txt](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS\u002Fblob\u002Fmain\u002FData\u002Fval_list_libritts.txt) as an example).\n\n## Training\nFirst stage training:\n```bash\naccelerate launch train_first.py --config_path .\u002FConfigs\u002Fconfig.yml\n```\nSecond stage training **(DDP version not working, so the current version uses DP, again see [#7](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F7) if you want to help)**:\n```bash\npython train_second.py --config_path .\u002FConfigs\u002Fconfig.yml\n```\nYou can run both consecutively and it will train both the first and second stages. The model will be saved in the format \"epoch_1st_%05d.pth\" and \"epoch_2nd_%05d.pth\". Checkpoints and Tensorboard logs will be saved at `log_dir`. \n\nThe data list format needs to be `filename.wav|transcription|speaker`, see [val_list.txt](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FData\u002Fval_list.txt) as an example. The speaker labels are needed for multi-speaker models because we need to sample reference audio for style diffusion model training. \n\n### Important Configurations\nIn [config.yml](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FConfigs\u002Fconfig.yml), there are a few important configurations to take care of:\n- `OOD_data`: The path for out-of-distribution texts for SLM adversarial training. The format should be `text|anything`.\n- `min_length`: Minimum length of OOD texts for training. This is to make sure the synthesized speech has a minimum length.\n- `max_len`: Maximum length of audio for training. The unit is frame. Since the default hop size is 300, one frame is approximately `300 \u002F 24000` (0.0125) second. Lowering this if you encounter the out-of-memory issue. \n- `multispeaker`: Set to true if you want to train a multispeaker model. This is needed because the architecture of the denoiser is different for single and multispeaker models.\n- `batch_percentage`: This is to make sure during SLM adversarial training there are no out-of-memory (OOM) issues. If you encounter OOM problem, please set a lower number for this. \n\n### Pre-trained modules\nIn [Utils](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils) folder, there are three pre-trained models: \n- **[ASR](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FASR) folder**: It contains the pre-trained text aligner, which was pre-trained on English (LibriTTS), Japanese (JVS), and Chinese (AiShell) corpus. It works well for most other languages without fine-tuning, but you can always train your own text aligner with the code here: [yl4579\u002FAuxiliaryASR](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FAuxiliaryASR).\n- **[JDC](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FJDC) folder**: It contains the pre-trained pitch extractor, which was pre-trained on English (LibriTTS) corpus only. However, it works well for other languages too because F0 is independent of language. If you want to train on singing corpus, it is recommended to train a new pitch extractor with the code here: [yl4579\u002FPitchExtractor](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FPitchExtractor).\n- **[PLBERT](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FPLBERT) folder**: It contains the pre-trained [PL-BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F2301.08810) model, which was pre-trained on English (Wikipedia) corpus only. It probably does not work very well on other languages, so you will need to train a different PL-BERT for different languages using the repo here: [yl4579\u002FPL-BERT](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FPL-BERT). You can also use the [multilingual PL-BERT](https:\u002F\u002Fhuggingface.co\u002Fpapercup-ai\u002Fmultilingual-pl-bert) which supports 14 languages. \n\n### Common Issues\n- **Loss becomes NaN**: If it is the first stage, please make sure you do not use mixed precision, as it can cause loss becoming NaN for some particular datasets when the batch size is not set properly (need to be more than 16 to work well). For the second stage, please also experiment with different batch sizes, with higher batch sizes being more likely to cause NaN loss values. We recommend the batch size to be 16. You can refer to issues [#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F10) and [#11](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F11) for more details.\n- **Out of memory**: Please either use lower `batch_size` or `max_len`. You may refer to issue [#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F10) for more information.\n- **Non-English dataset**: You can train on any language you want, but you will need to use a pre-trained PL-BERT model for that language. We have a pre-trained [multilingual PL-BERT](https:\u002F\u002Fhuggingface.co\u002Fpapercup-ai\u002Fmultilingual-pl-bert) that supports 14 languages. You may refer to [yl4579\u002FStyleTTS#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS\u002Fissues\u002F10) and [#70](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F70) for some examples to train on Chinese datasets. \n\n## Finetuning\nThe script is modified from `train_second.py` which uses DP, as DDP does not work for `train_second.py`. Please see the bold section above if you are willing to help with this problem. \n```bash\npython train_finetune.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```\nPlease make sure you have the LibriTTS checkpoint downloaded and unzipped under the folder. The default configuration `config_ft.yml` finetunes on LJSpeech with 1 hour of speech data (around 1k samples) for 50 epochs. This took about 4 hours to finish on four NVidia A100. The quality is slightly worse (similar to NaturalSpeech on LJSpeech) than LJSpeech model trained from scratch with 24 hours of speech data, which took around 2.5 days to finish on four A100. The samples can be found at [#65 (comment)](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F65#discussioncomment-7668393). \n\nIf you are using a **single GPU** (because the script doesn't work with DDP) and want to save training speed and VRAM, you can do (thank [@korakoe](https:\u002F\u002Fgithub.com\u002Fkorakoe) for making the script at [#100](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fpull\u002F100)):\n```bash\naccelerate launch --mixed_precision=fp16 --num_processes=1 train_finetune_accelerate.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```\n[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Finetune_Demo.ipynb)\n\n### Common Issues\n[@Kreevoz](https:\u002F\u002Fgithub.com\u002FKreevoz) has made detailed notes on common issues in finetuning, with suggestions in maximizing audio quality: [#81](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F81). Some of these also apply to training from scratch. [@IIEleven11](https:\u002F\u002Fgithub.com\u002FIIEleven11) has also made a guideline for fine-tuning: [#128](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F128).\n\n- **Out of memory after `joint_epoch`**: This is likely because your GPU RAM is not big enough for SLM adversarial training run. You may skip that but the quality could be worse. Setting `joint_epoch` a larger number than `epochs` could skip the SLM advesariral training.\n\n## Inference\nPlease refer to [Inference_LJSpeech.ipynb](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FDemo\u002FInference_LJSpeech.ipynb) (single-speaker) and [Inference_LibriTTS.ipynb](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FDemo\u002FInference_LibriTTS.ipynb) (multi-speaker) for details. For LibriTTS, you will also need to download [reference_audio.zip](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Fresolve\u002Fmain\u002Freference_audio.zip) and unzip it under the `demo` before running the demo. \n\n- The pretrained StyleTTS 2 on LJSpeech corpus in 24 kHz can be downloaded at [https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LJSpeech\u002Ftree\u002Fmain](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LJSpeech\u002Ftree\u002Fmain).\n\n  [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LJSpeech.ipynb)\n\n- The pretrained StyleTTS 2 model on LibriTTS can be downloaded at [https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Ftree\u002Fmain](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Ftree\u002Fmain). \n\n  [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LibriTTS.ipynb)\n\n\nYou can import StyleTTS 2 and run it in your own code. However, the inference depends on a GPL-licensed package, so it is not included directly in this repository. A [GPL-licensed fork](https:\u002F\u002Fgithub.com\u002FNeuralVox\u002FStyleTTS2) has an importable script, as well as an experimental streaming API, etc. A [fully MIT-licensed package](https:\u002F\u002Fpypi.org\u002Fproject\u002Fstyletts2\u002F) that uses gruut (albeit lower quality due to mismatch between phonemizer and gruut) is also available.  \n\n***Before using these pre-trained models, you agree to inform the listeners that the speech samples are synthesized by the pre-trained models, unless you have the permission to use the voice you synthesize. That is, you agree to only use voices whose speakers grant the permission to have their voice cloned, either directly or by license before making synthesized voices public, or you have to publicly announce that these voices are synthesized if you do not have the permission to use these voices.*** \n\n### Common Issues\n- **High-pitched background noise**: This is caused by numerical float differences in older GPUs. For more details, please refer to issue [#13](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F13). Basically, you will need to use more modern GPUs or do inference on CPUs.\n- **Pre-trained model license**: You only need to abide by the above rules if you use **the pre-trained models** and the voices are **NOT** in the training set, i.e., your reference speakers are not from any open access dataset. For more details of rules to use the pre-trained models, please see [#37](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F37).\n\n## References\n- [archinetai\u002Faudio-diffusion-pytorch](https:\u002F\u002Fgithub.com\u002Farchinetai\u002Faudio-diffusion-pytorch)\n- [jik876\u002Fhifi-gan](https:\u002F\u002Fgithub.com\u002Fjik876\u002Fhifi-gan)\n- [rishikksh20\u002FiSTFTNet-pytorch](https:\u002F\u002Fgithub.com\u002Frishikksh20\u002FiSTFTNet-pytorch)\n- [nii-yamagishilab\u002Fproject-NN-Pytorch-scripts\u002Fproject\u002F01-nsf](https:\u002F\u002Fgithub.com\u002Fnii-yamagishilab\u002Fproject-NN-Pytorch-scripts\u002Ftree\u002Fmaster\u002Fproject\u002F01-nsf)\n\n## License\n\nCode: MIT License\n\nPre-Trained Models: Before using these pre-trained models, you agree to inform the listeners that the speech samples are synthesized by the pre-trained models, unless you have the permission to use the voice you synthesize. That is, you agree to only use voices whose speakers grant the permission to have their voice cloned, either directly or by license before making synthesized voices public, or you have to publicly announce that these voices are synthesized if you do not have the permission to use these voices.\n","# StyleTTS 2：通过风格扩散与对抗训练结合大型语音语言模型实现人类水平的文本到语音合成\n\n### 袁浩·李、韩聪、文尼·R·拉加万、加文·米施勒、尼玛·梅斯加拉尼\n\n> 在本文中，我们提出了StyleTTS 2，这是一种文本到语音（TTS）模型，它利用风格扩散和与大型语音语言模型（SLM）结合的对抗训练，以实现人类水平的TTS合成。StyleTTS 2与其前代模型的不同之处在于，它通过扩散模型将风格建模为一个潜在的随机变量，从而在无需参考语音的情况下生成最适合文本的风格，在享受扩散模型提供的多样化语音合成的同时，实现了高效的潜在扩散。此外，我们还使用了如WavLM等大型预训练SLM作为判别器，并结合我们新颖的可微分时长建模进行端到端训练，从而进一步提升了语音的自然度。StyleTTS 2在单说话人LJSpeech数据集上的表现超越了真人录音，而在多说话人VCTK数据集上则与真人录音相当，这一评价由以英语为母语的听者做出。更进一步地，在LibriTTS数据集上训练后，我们的模型在零样本说话人适配上优于此前公开可用的模型。这项工作首次在单说话人和多说话人数据集上均实现了人类水平的TTS合成，展示了风格扩散与大型SLM结合对抗训练的巨大潜力。\n\n论文：[https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.07691](https:\u002F\u002Farxiv.org\u002Fabs\u002F2306.07691)\n\n音频示例：[https:\u002F\u002Fstyletts2.github.io\u002F](https:\u002F\u002Fstyletts2.github.io\u002F)\n\n在线演示：[Hugging Face](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Fstyletts2\u002Fstyletts2)（感谢[@fakerybakery](https:\u002F\u002Fgithub.com\u002Ffakerybakery)提供的精彩在线演示）\n\n[![在Colab中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002F) [![Discord](https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1197679063150637117?logo=discord&logoColor=white&label=加入我们的社区)](https:\u002F\u002Fdiscord.gg\u002Fha8sxdG2K4)\n\n## 待办事项\n- [x] 单说话人模型（LJSpeech）的训练与推理演示代码\n- [x] 多说话人模型（VCTK和LibriTTS）的测试训练代码\n- [x] 完成多说话人模型的演示代码并上传预训练模型\n- [x] 添加基于基础多说话人预训练模型对新说话人的微调脚本\n- [ ] 修复`train_second.py`中的DDP（加速器）问题 **（我已经尝试了所有能想到的方法来解决这个问题，但仍未成功，因此如果您愿意帮忙，请参阅[#7](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F7))**\n\n## 前置条件\n1. Python >= 3.7\n2. 克隆本仓库：\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2.git\ncd StyleTTS2\n```\n3. 安装Python依赖：\n```bash\npip install -r requirements.txt\n```\n在Windows系统上还需添加：\n```bash\npip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118 -U\n```\n如果您想运行演示，还需要安装phonemizer和espeak：\n```bash\npip install phonemizer\nsudo apt-get install espeak-ng\n```\n4. 下载并解压[LJSpeech数据集](https:\u002F\u002Fkeithito.com\u002FLJ-Speech-Dataset\u002F)，解压到data文件夹，并将数据上采样至24 kHz。文本对齐器和音高提取器是在24 kHz数据上预训练的，但您可以轻松更改预处理方式并使用您自己的预处理流程重新训练它们。\n对于LibriTTS，您需要将train-clean-360与train-clean-100合并，并重命名为train-clean-460文件夹（请参阅[val_list_libritts.txt](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS\u002Fblob\u002Fmain\u002FData\u002Fval_list_libritts.txt)作为示例）。\n\n## 训练\n第一阶段训练：\n```bash\naccelerate launch train_first.py --config_path .\u002FConfigs\u002Fconfig.yml\n```\n第二阶段训练 **（DDP版本无法正常工作，因此当前版本使用DP，如果您想帮忙，请再次参阅[#7](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F7))**：\n```bash\npython train_second.py --config_path .\u002FConfigs\u002Fconfig.yml\n```\n您可以连续运行这两个命令，这样就能同时完成第一和第二阶段的训练。模型将以“epoch_1st_%05d.pth”和“epoch_2nd_%05d.pth”的格式保存。检查点和Tensorboard日志将保存在`log_dir`目录下。\n\n数据列表的格式应为“filename.wav|转录文本|说话人”，请参阅[val_list.txt](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FData\u002Fval_list.txt)作为示例。多说话人模型需要说话人标签，因为我们需要为风格扩散模型的训练采集参考音频。\n\n### 重要配置\n在[config.yml](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FConfigs\u002Fconfig.yml)中，有几项重要的配置需要注意：\n- `OOD_data`：用于SLM对抗训练的分布外文本路径。格式应为“文本|任意内容”。\n- `min_length`：用于训练的分布外文本的最小长度。这是为了确保合成的语音具有一定的最小长度。\n- `max_len`：用于训练的最大音频长度。单位为帧。由于默认的跳过步长为300，一帧大约是“300 \u002F 24000”（0.0125）秒。如果您遇到内存不足的问题，可以适当降低此值。\n- `multispeaker`：如果要训练多说话人模型，请将其设置为真。这是因为单说话人和多说话人模型的去噪器架构不同。\n- `batch_percentage`：此参数用于确保在SLM对抗训练过程中不会出现内存不足（OOM）的情况。如果您遇到OOM问题，请降低此数值。\n\n### 预训练模块\n在[Utils](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils)文件夹中，有三个预训练模型：\n- **[ASR](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FASR)文件夹**：其中包含预训练的文本对齐器，该模型已在英语（LibriTTS）、日语（JVS）和中文（AiShell）语料库上进行了预训练。它在大多数其他语言上无需微调即可良好工作，但您也可以使用此处的代码训练您自己的文本对齐器：[yl4579\u002FAuxiliaryASR](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FAuxiliaryASR)。\n- **[JDC](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FJDC)文件夹**：其中包含预训练的音高提取器，该模型仅在英语（LibriTTS）语料库上进行了预训练。然而，由于F0与语言无关，它在其他语言上也能很好地工作。如果您想在歌唱语料库上训练，建议使用此处的代码训练一个新的音高提取器：[yl4579\u002FPitchExtractor](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FPitchExtractor)。\n- **[PLBERT](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Ftree\u002Fmain\u002FUtils\u002FPLBERT)文件夹**：其中包含预训练的[PL-BERT](https:\u002F\u002Farxiv.org\u002Fabs\u002F2301.08810)模型，该模型仅在英语（维基百科）语料库上进行了预训练。它可能在其他语言上效果不佳，因此您需要使用此处的仓库为不同语言训练不同的PL-BERT：[yl4579\u002FPL-BERT](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FPL-BERT)。您也可以使用支持14种语言的[多语言PL-BERT](https:\u002F\u002Fhuggingface.co\u002Fpapercup-ai\u002Fmultilingual-pl-bert)。\n\n### 常见问题\n- **损失变为 NaN**：如果是第一阶段，请确保不要使用混合精度训练，因为在某些特定数据集上，当批量大小设置不当（需要大于 16 才能正常工作）时，可能会导致损失变为 NaN。对于第二阶段，也请尝试不同的批量大小，较大的批量大小更容易导致损失值为 NaN。我们建议将批量大小设置为 16。更多详情可参考议题 [#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F10) 和 [#11](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F11)。\n- **显存不足**：请降低 `batch_size` 或 `max_len`。更多信息可参考议题 [#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F10)。\n- **非英语数据集**：您可以使用任何语言进行训练，但需要使用该语言的预训练 PL-BERT 模型。我们提供了一个支持 14 种语言的多语言 PL-BERT 模型，可在 Hugging Face 上找到。关于如何使用中文数据集进行训练的示例，可参考 [yl4579\u002FStyleTTS#10](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS\u002Fissues\u002F10) 和 [#70](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F70)。\n\n## 微调\n该脚本基于使用 DP 的 `train_second.py` 修改而来，因为 DDP 在 `train_second.py` 中无法正常工作。如果您愿意帮助解决这个问题，请参阅上方加粗部分。\n```bash\npython train_finetune.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```\n请确保您已下载并解压 LibriTTS 检查点文件到指定文件夹中。默认配置 `config_ft.yml` 会在 LJSpeech 数据集上进行微调，使用约 1 小时的语音数据（约 1000 个样本），训练 50 个 epoch。在四块 NVidia A100 显卡上完成此任务大约需要 4 小时。其生成的音质略逊于从头开始训练、使用 24 小时语音数据的 LJSpeech 模型，后者在四块 A100 上大约需要 2.5 天才能完成。相关样本可在 [#65 (评论)](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F65#discussioncomment-7668393) 中查看。\n\n如果您使用的是**单 GPU**（因为该脚本不支持 DDP），并且希望节省训练时间和显存，可以按照以下方式操作（感谢 [@korakoe](https:\u002F\u002Fgithub.com\u002Fkorakoe) 在 [#100](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fpull\u002F100) 中提供的脚本）：\n```bash\naccelerate launch --mixed_precision=fp16 --num_processes=1 train_finetune_accelerate.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```\n[![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Finetune_Demo.ipynb)\n\n### 常见问题\n[@Kreevoz](https:\u002F\u002Fgithub.com\u002FKreevoz) 对微调中的常见问题进行了详细说明，并提出了提升音频质量的建议：[#81](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F81)。其中一些内容同样适用于从零开始训练。[@IIEleven11](https:\u002F\u002Fgithub.com\u002FIIEleven11) 也提供了一份微调指南：[#128](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fdiscussions\u002F128)。\n\n- **`joint_epoch` 后显存不足**：这很可能是由于您的 GPU 显存不足以运行 SLM 对抗训练。您可以跳过这一部分，但音质可能会有所下降。将 `joint_epoch` 设置为大于 `epochs` 的值，即可跳过 SLM 对抗训练。\n\n## 推理\n有关详细信息，请参阅 [Inference_LJSpeech.ipynb](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FDemo\u002FInference_LJSpeech.ipynb)（单说话人）和 [Inference_LibriTTS.ipynb](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FDemo\u002FInference_LibriTTS.ipynb)（多说话人）。对于 LibriTTS，您还需要下载 [reference_audio.zip](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Fresolve\u002Fmain\u002Freference_audio.zip)，并在运行演示之前将其解压到 `demo` 文件夹中。\n\n- 预训练的 StyleTTS 2 模型（LJSpeech 语料库，24 kHz）可在 [https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LJSpeech\u002Ftree\u002Fmain](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LJSpeech\u002Ftree\u002Fmain) 下载。\n\n  [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LJSpeech.ipynb)\n\n- 预训练的 StyleTTS 2 模型（LibriTTS）可在 [https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Ftree\u002Fmain](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Ftree\u002Fmain) 下载。\n\n  [![在 Colab 中打开](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LibriTTS.ipynb)\n\n您可以在自己的代码中导入 StyleTTS 2 并运行它。然而，推理过程依赖于 GPL 许可的软件包，因此未直接包含在本仓库中。一个 [GPL 许可的分支](https:\u002F\u002Fgithub.com\u002FNeuralVox\u002FStyleTTS2) 提供了可导入的脚本以及实验性的流式 API 等功能。此外，还有一个 [完全 MIT 许可的软件包](https:\u002F\u002Fpypi.org\u002Fproject\u002Fstyletts2\u002F)，它使用 gruut，尽管由于发音器与 gruut 之间的不匹配，音质稍低。\n\n***在使用这些预训练模型之前，您需同意告知听众，这些语音样本是由预训练模型合成的，除非您已获得被合成声音所有者的许可。也就是说，您必须仅使用那些已明确授权克隆其声音的说话人的语音，无论是通过直接许可还是通过授权协议，在公开合成语音之前；或者，如果您未获得此类许可，则必须公开声明这些语音是合成的。***\n\n### 常见问题\n- **背景噪音过高**：这是由旧款 GPU 中的浮点数差异引起的。更多详情请参阅议题 [#13](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F13)。通常情况下，您需要使用更新的 GPU 或在 CPU 上进行推理。\n- **预训练模型的许可**：只有在您使用**预训练模型**且所用语音**不在**训练集中时，才需要遵守上述规则，即您的参考说话人并非来自任何开放获取的数据集。有关使用预训练模型的具体规则，请参阅 [#37](https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F37)。\n\n## 参考文献\n- [archinetai\u002Faudio-diffusion-pytorch](https:\u002F\u002Fgithub.com\u002Farchinetai\u002Faudio-diffusion-pytorch)\n- [jik876\u002Fhifi-gan](https:\u002F\u002Fgithub.com\u002Fjik876\u002Fhifi-gan)\n- [rishikksh20\u002FiSTFTNet-pytorch](https:\u002F\u002Fgithub.com\u002Frishikksh20\u002FiSTFTNet-pytorch)\n- [nii-yamagishilab\u002Fproject-NN-Pytorch-scripts\u002Fproject\u002F01-nsf](https:\u002F\u002Fgithub.com\u002Fnii-yamagishilab\u002Fproject-NN-Pytorch-scripts\u002Ftree\u002Fmaster\u002Fproject\u002F01-nsf)\n\n## 许可证\n\n代码：MIT 许可证\n\n预训练模型：在使用这些预训练模型之前，您需同意告知听众，相关语音样本是由预训练模型合成的，除非您已获得被合成声音所有者的许可。换言之，您承诺仅使用那些其持有人已明确授权进行声音克隆的语音——无论是直接授权还是通过许可协议——方可公开发布合成语音；否则，您必须公开声明这些语音为合成音，若您未取得相应授权。","# StyleTTS 2 快速上手指南\n\nStyleTTS 2 是一款通过风格扩散和对抗训练实现人类级别语音合成（TTS）的开源模型。它支持单说话人和多说话人场景，并具备优秀的零样本说话人适应能力。\n\n## 环境准备\n\n### 系统要求\n- **Python**: >= 3.7\n- **GPU**: 推荐 NVIDIA GPU（用于加速训练和推理）\n- **操作系统**: Linux \u002F Windows \u002F macOS\n\n### 前置依赖\n在开始之前，请确保系统已安装以下基础工具：\n- `git`\n- `ffmpeg` (可选，用于音频处理)\n- `espeak-ng` (用于音素化，Linux 下需单独安装)\n\n**Linux 用户安装 espeak-ng:**\n```bash\nsudo apt-get install espeak-ng\n```\n\n## 安装步骤\n\n### 1. 克隆仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2.git\ncd StyleTTS2\n```\n\n### 2. 安装 Python 依赖\n安装基础依赖包：\n```bash\npip install -r requirements.txt\n```\n\n**Windows 用户注意：**\n如果您在 Windows 上运行，需要指定 PyTorch CUDA 版本进行安装（以 cu118 为例）：\n```bash\npip install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118 -U\n```\n\n**额外依赖：**\n如果需要运行演示代码，请确保安装了 `phonemizer`：\n```bash\npip install phonemizer\n```\n\n### 3. 准备数据\n模型默认使用 24kHz 采样率的数据。\n- **单说话人 (LJSpeech)**: 下载 [LJSpeech 数据集](https:\u002F\u002Fkeithito.com\u002FLJ-Speech-Dataset\u002F)，解压至 `data` 文件夹，并将音频重采样至 24 kHz。\n- **多说话人 (LibriTTS)**: 需合并 `train-clean-360` 和 `train-clean-100` 并重命名为 `train-clean-460`。\n\n## 基本使用\n\n对于大多数开发者，直接使用预训练模型进行推理是最快的上手方式。以下是基于 Google Colab 或本地环境的简单推理流程。\n\n### 方式一：使用 Google Colab 快速体验（推荐）\n无需本地配置环境，直接点击以下链接在云端运行：\n\n- **单说话人模型 (LJSpeech)**:\n  [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LJSpeech.ipynb)\n\n- **多说话人模型 (LibriTTS)**:\n  [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fyl4579\u002FStyleTTS2\u002Fblob\u002Fmain\u002FColab\u002FStyleTTS2_Demo_LibriTTS.ipynb)\n\n### 方式二：本地代码推理\n\n#### 1. 下载预训练模型\n从 Hugging Face 下载对应的模型权重：\n- **LJSpeech (单说话人)**: [下载链接](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LJSpeech\u002Ftree\u002Fmain)\n- **LibriTTS (多说话人)**: [下载链接](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Ftree\u002Fmain)\n  - *注意*: 使用 LibriTTS 模型时，还需下载 [reference_audio.zip](https:\u002F\u002Fhuggingface.co\u002Fyl4579\u002FStyleTTS2-LibriTTS\u002Fresolve\u002Fmain\u002Freference_audio.zip) 并解压到 `demo` 目录下作为参考音频。\n\n#### 2. 运行推理脚本\n项目提供了现成的 Jupyter Notebook 用于演示推理逻辑，您可以直接在本地 Jupyter 环境中打开并运行：\n\n- **单说话人推理**:\n  ```bash\n  # 在 Jupyter 中打开\n  Demo\u002FInference_LJSpeech.ipynb\n  ```\n\n- **多说话人推理**:\n  ```bash\n  # 在 Jupyter 中打开\n  Demo\u002FInference_LibriTTS.ipynb\n  ```\n\n#### 3. 集成到自己的代码中\n由于推理依赖 GPL 许可的第三方包，官方仓库未直接提供可导入的 Python 脚本。您可以参考以下方案：\n- 使用社区维护的完全 MIT 许可版本：\n  ```bash\n  pip install styletts2\n  ```\n- 或者参考 [NeuralVox\u002FStyleTTS2](https:\u002F\u002Fgithub.com\u002FNeuralVox\u002FStyleTTS2) 分支获取可导入脚本及流式 API 支持。\n\n### 简易微调（可选）\n如果您希望基于预训练的多说话人模型微调新的说话人声音，可以使用以下命令（需准备约 1 小时的新说话人音频数据）：\n\n```bash\npython train_finetune.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```\n\n*注：微调脚本目前仅支持 DP 模式（单卡或多卡非分布式），若需节省显存并加速，可使用 accelerate 启动：*\n```bash\naccelerate launch --mixed_precision=fp16 --num_processes=1 train_finetune_accelerate.py --config_path .\u002FConfigs\u002Fconfig_ft.yml\n```","一家专注于有声书制作的初创团队，正试图将大量公版经典小说快速转化为高质量的多人物对话音频，以降低成本并缩短上市周期。\n\n### 没有 StyleTTS2 时\n- **录音成本高昂**：必须聘请多位专业配音演员分角色录制，导致单本书的制作预算居高不下，且协调档期耗时漫长。\n- **情感表达僵硬**：传统 TTS 工具生成的语音机械感强，难以根据文本语境自动切换愤怒、悲伤或幽默等细腻语气，听众体验差。\n- **零样本适配困难**：若想模仿特定知名主播的音色，通常需要采集该人长达数小时的干音进行微调，数据门槛极高且效果往往不尽如人意。\n- **后期处理繁琐**：由于合成音质不自然，后期工程师需花费大量时间手动调整语调、停顿和呼吸声，严重拖慢交付进度。\n\n### 使用 StyleTTS2 后\n- **实现真人级合成**：StyleTTS2 利用风格扩散模型，无需参考音频即可为不同段落自动生成最贴合语境的说话风格，听感几乎与真人录音无异。\n- **高效零样本变声**：仅需几秒的目标人声样本，StyleTTS2 即可通过预训练的大规模语音语言模型（如 WavLM）精准复刻其音色与说话习惯，瞬间创建新角色。\n- **端到端自然度提升**：得益于对抗性训练和可微分时长建模，生成的语音在韵律、呼吸和连读上极其流畅，大幅减少了人工后期修音的工作量。\n- **规模化生产落地**：团队现在只需输入文本和角色设定，即可批量产出多角色互动的有声剧，将单本书的制作周期从数周压缩至数小时。\n\nStyleTTS2 通过突破性的风格扩散与对抗训练技术，真正实现了低成本、高自然度的“人类级别”语音合成，彻底重塑了音频内容的生产流程。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fyl4579_StyleTTS2_ba477ba6.png","yl4579","Aaron (Yinghao) Li","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fyl4579_11fe7b6e.png",null,"Columbia University","New York, US","https:\u002F\u002Fgithub.com\u002Fyl4579",[83,87],{"name":84,"color":85,"percentage":86},"Python","#3572A5",77.8,{"name":88,"color":89,"percentage":90},"Jupyter Notebook","#DA5B0B",22.2,6236,670,"2026-04-04T22:20:07","MIT",4,"Linux, Windows","需要 NVIDIA GPU (训练示例提及使用 4 张 A100)，需安装 CUDA 11.8 (Windows 明确指定 cu118)，显存需求取决于 batch_size 和 max_len，遇到 OOM 需降低这两个参数","未说明",{"notes":100,"python":101,"dependencies":102},"1. Windows 用户需手动安装特定 CUDA 版本的 torch 系列库。2. 运行演示需安装 phonemizer 及系统级依赖 espeak-ng (Linux: sudo apt-get install espeak-ng)。3. 第二阶段训练及微调脚本目前仅支持 DP (数据并行)，DDP (分布式数据并行) 存在已知问题尚未修复，单卡微调可使用 accelerate 开启 fp16 混合精度以节省显存。4. 训练数据需预处理为 24kHz。5. 非英语语言训练需替换对应的 PL-BERT 模型。",">=3.7",[103,104,105,106,107],"torch","torchvision","torchaudio","phonemizer","accelerate",[55,13,14],[110,111,112,113,114,115,116,117,118,119,120,121],"deep-learning","pytorch","speaker-adaptation","speech-synthesis","text-to-speech","tts","wavlm","diffusion-models","latent-diffusion","latent-diffusion-models","adversarial-training","gan","2026-03-27T02:49:30.150509","2026-04-06T05:17:36.503815",[125,130,134,139,144,149,154],{"id":126,"question_zh":127,"answer_zh":128,"source_url":129},18135,"微调单说话人数据集时，是否需要提供参考音频？如何配置？","如果是微调单说话人数据集，参考音频可以是任意的，不会影响合成的语音效果。您可以将配置文件中的多说话人标志（multispeaker flag）设置为 false，并且在微调时不加载扩散模型（diffusion model），前提是确认新数据集只包含一个说话人。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F1",{"id":131,"question_zh":132,"answer_zh":133,"source_url":129},18136,"微调 StyleTTS2 需要多少数据量才能达到较好效果？","数据量越多效果越好，但实测使用仅 10 分钟的音频进行微调也能正常工作。虽然自然度可能不如大量数据训练的效果，但声音的相似度会显著优于零样本（zero-shot）语音克隆。",{"id":135,"question_zh":136,"answer_zh":137,"source_url":138},18137,"在哪里可以找到基于 LibriTTS 训练的预训练模型？","基于 LibriTTS 训练的预训练模型链接现已更新在项目的 README 文件中，请直接查阅仓库首页的说明文档获取下载链接。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F20",{"id":140,"question_zh":141,"answer_zh":142,"source_url":143},18138,"第二阶段训练时出现 g_loss 为 None 或损失值为 NaN 怎么办？","这通常与配置或检查点有关。建议尝试直接从 Hugging Face 提供的预训练检查点开始第二阶段训练，这样可以避免从头训练第一阶段可能产生的问题。注意：Hugging Face 上的检查点（约 700MB）未保存判别器（discriminator），而从头训练的检查点（约 1.7GB）包含判别器。如果从头训练，请确保第一阶段训练正常且超参数（如 batch_size, max_len）设置合理，避免初始步骤就出现 NaN。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F11",{"id":145,"question_zh":146,"answer_zh":147,"source_url":148},18139,"是否支持训练中文模型或中英文混合输入？拼音声调如何处理？","支持训练中文模型。关于拼音声调的处理策略：可以使用相同的音素单元（如带声调的拼音 sheng1 mu3 yun4 mu3）训练所有文本相关模型（Text Encoder 和 PL-BERT），输入长度与输出长度一致（例如 'ni3 hao3' 解析为 'n i3 h ao3'，长度为 4）。但在训练 ASR（自动语音识别）模块时，建议使用不带声调的音素。PL-BERT 的标签构建逻辑可参考 plbert 仓库中的 dataloader.py 文件。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F70",{"id":150,"question_zh":151,"answer_zh":152,"source_url":153},18140,"如何在 macOS 上安装 espeak-ng 以用于 phonemizer？","在 macOS 上安装 espeak-ng 可能会遇到困难（例如 MacPorts 安装失败）。建议的解决方案是在虚拟机（VM）中进行开发环境搭建，或者在具有完整依赖支持的 Linux 环境中运行。如果必须在本地运行，需确保系统层面正确安装了 espeak-ng 库并被 phonemizer 正确识别。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F50",{"id":155,"question_zh":156,"answer_zh":157,"source_url":158},18141,"第二阶段训练时遇到 CUDA 显存不足（Out of Memory）错误如何解决？","如果遇到显存不足，首先检查 GPU 指定是否正确。有时即使设置了 device_id，代码仍可能运行在其他 GPU 上。建议使用环境变量强制指定显卡，例如在命令行前加上 `CUDA_VISIBLE_DEVICES=7`（替换为您的空闲 GPU ID），并在代码中确认设备设置。此外，可以尝试减小 batch_size 或 max_len 参数来降低显存占用。","https:\u002F\u002Fgithub.com\u002Fyl4579\u002FStyleTTS2\u002Fissues\u002F256",[]]