├── .gitignore ├── LICENSE ├── README.md ├── README_zh.md ├── fine_tune_indextts.ipynb ├── preprocess_mel_dataset.ipynb └── samples ├── Female-1_SeriouslygigglesThatsthecutestt.wav ├── Female-1_真的吗giggles这也太可爱了吧.wav ├── Male-1_Wha—CutegigglesYouthinkImcute.wav └── Male-1_哎呀忘了他还在那等我们呢giggles我们两个动作得快点了.wav /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # UV 98 | # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | #uv.lock 102 | 103 | # poetry 104 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 105 | # This is especially recommended for binary packages to ensure reproducibility, and is more 106 | # commonly ignored for libraries. 107 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 108 | #poetry.lock 109 | 110 | # pdm 111 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 112 | #pdm.lock 113 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 114 | # in version control. 115 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 116 | .pdm.toml 117 | .pdm-python 118 | .pdm-build/ 119 | 120 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 121 | __pypackages__/ 122 | 123 | # Celery stuff 124 | celerybeat-schedule 125 | celerybeat.pid 126 | 127 | # SageMath parsed files 128 | *.sage.py 129 | 130 | # Environments 131 | .env 132 | .venv 133 | env/ 134 | venv/ 135 | ENV/ 136 | env.bak/ 137 | venv.bak/ 138 | 139 | # Spyder project settings 140 | .spyderproject 141 | .spyproject 142 | 143 | # Rope project settings 144 | .ropeproject 145 | 146 | # mkdocs documentation 147 | /site 148 | 149 | # mypy 150 | .mypy_cache/ 151 | .dmypy.json 152 | dmypy.json 153 | 154 | # Pyre type checker 155 | .pyre/ 156 | 157 | # pytype static type analyzer 158 | .pytype/ 159 | 160 | # Cython debug symbols 161 | cython_debug/ 162 | 163 | # PyCharm 164 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 165 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 166 | # and can be added to the global gitignore or merged into this file. For a more nuclear 167 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 168 | #.idea/ 169 | 170 | # Abstra 171 | # Abstra is an AI-powered process automation framework. 172 | # Ignore directories containing user credentials, local state, and settings. 173 | # Learn more at https://abstra.io/docs 174 | .abstra/ 175 | 176 | # Visual Studio Code 177 | # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore 178 | # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore 179 | # and can be added to the global gitignore or merged into this file. However, if you prefer, 180 | # you could uncomment the following to ignore the enitre vscode folder 181 | # .vscode/ 182 | 183 | # Ruff stuff: 184 | .ruff_cache/ 185 | 186 | # PyPI configuration file 187 | .pypirc 188 | 189 | # Cursor 190 | # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to 191 | # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data 192 | # refer to https://docs.cursor.com/context/ignore-files 193 | .cursorignore 194 | .cursorindexingignore -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Yrom Wang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IndexTTS Fine-tuning Demo 2 | 3 | [中文说明](README_zh.md) 4 | 5 | This project is a demonstration of fine-tuning [IndexTTS](https://github.com/index-tts/index-tts) to generate speech with addtional special tags (such as ``), enabling the synthesis of non-textual elements like laughter. 6 | 7 | ## Goals 8 | 9 | - Show you how to fine-tune IndexTTS's text Tokenizer (BPE) and AR part (GPT2). 10 | - Support for addtional special tags like `` in text to generate laughter. 11 | 12 | ### Fine-tuning Dataset 13 | 14 | [🤗 MrDragonFox/Elise](https://huggingface.co/datasets/MrDragonFox/Elise) ([Modelscope mirror](https://www.modelscope.cn/datasets/RealmSky/Elise)) 15 | 16 | 17 | ### Fine-tuning Experiment Results Example 18 | 19 | | Reference Audio | Text | Synthesized Speech | 20 | | --- | --- | --- | 21 | | [Female-1][Female_1]| Seriously? <giggles> That's the cutest thing I've ever heard! | [Synthesized Speech](samples/Female-1_SeriouslygigglesThatsthecutestt.wav) | 22 | | [Female-1][Female_1] | 真的吗? <giggles> 这也太可爱了吧!| [Synthesized Speech](samples/Female-1_真的吗giggles这也太可爱了吧.wav) | 23 | | [Male-1][Male_1]| Wha—? Cute? <giggles> You think I'm cute?! Well, uh, thanks, I guess? | [Synthesized Speech](samples/Male-1_Wha—CutegigglesYouthinkImcute.wav) | 24 | | [Male-1][Male_1]| 哎呀! 忘了他还在那等我们呢!<giggles> 我们两个动作得快点了!| [Synthesized Speech](samples/Male-1_哎呀忘了他还在那等我们呢giggles我们两个动作得快点了.wav) | 25 | 26 | 27 | ### IndexTTS Architecture Overview 28 | 29 | ```mermaid 30 | flowchart TD 31 | D("Reference Transcript") -->BPE[[**BPE**]] --> T(Text Token IDs) 32 | A("Reference Audio") --> M(Mel-Spectrogram) --> VAE[[*DiscreteVAE*]]--> B(Mel-Spec Code Ids) 33 | A -->CE[[*Conformer Encoder*]] --> Pe[[*Perceiver Resampler*]] --> CA(Audio Context Vector) -->|Conditioning| C 34 | B --> C 35 | T --> C[[**GPT2**]] 36 | C --> L("Latent Speech Representation") 37 | L --> V[["*BigVGAN* 38 | (Generator)"]] 39 | A --> SP[[*ECAPA-TDNN*]]--> S(Speaker Embedding) 40 | S --> V 41 | V -->|Synthesis| PCM("Waveform (PCM)") --> W("Synthesized Speech") 42 | ``` 43 | 44 | ### Modules Fine-tuned in This Project 45 | 46 | - **BPE**: Actually `sentencepiece`, this project show you how to adding new special tags such as `` to the text Tokenizer. See the [preprocess_mel_dataset.ipynb](preprocess_mel_dataset.ipynb) notebook for details. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/yrom/finetune-index-tts/blob/main/preprocess_mel_dataset.ipynb) 47 | - **GPT2**: The autoregressive model part, using the [🤗 peft](https://huggingface.co/docs/peft/v0.15.0/en/index) library for `LoRA` fine-tuning, supporting the generation of speech latents for text with special tags. See the [fine_tune_indextts.ipynb](fine_tune_indextts.ipynb) notebook for details. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/yrom/finetune-index-tts/blob/main/fine_tune_indextts.ipynb) 48 | 49 | 50 | 51 | ## Disclaimer 52 | 53 | The reference audio files and the datasets used in this project are granted under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) license. 54 | They are used for the research and demonstration purposes of this project only, and are not intended for any commercial use. 55 | The synthesized audio files generated by this project are also not intended for commercial use. 56 | 57 | [Female_1]: https://bytedancespeech.github.io/seedtts_tech_report/audios/SpeechFactorization_samples/prompt/prompt1/4813840990459345930.wav 58 | [Male_1]: https://bytedancespeech.github.io/seedtts_tech_report/audios/SpeechFactorization_samples/source/2188769758301752050.wav 59 | 60 | 61 | ## License 62 | 63 | This project is licensed under the [MIT License](LICENSE). 64 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | # IndexTTS 微调示例 2 | 3 | [English Version](README.md) 4 | 5 | 本项目是个示例项目,旨在对 [IndexTTS](https://github.com/index-tts/index-tts) 进行微调,使其能够识别并生成带有特殊标签(如 ``)的语音音频,实现如笑声等情感或非文本元素的合成。 6 | 7 | > [!NOTE] 8 | > 本项目仅为示例,实际应用中请根据具体需求进行调整和优化。 9 | > 微调详细思路可以查看我的blog:[《微调IndexTTS以输出可控情绪的语言音频》](https://yrom.net/blog/2025/06/15/finetune-indextts-to-generate-controllable-emotions-speech/) 10 | 11 | ## 项目目标 12 | 13 | - 示例如何对 IndexTTS 的文本 Tokenizer和自回归模型部分(GPT2)进行微调 14 | - 支持在文本中插入如 `` 等特殊标签,以生成对应的笑声或其他音效。 15 | 16 | ### 微调数据集 17 | 18 | [🤗 MrDragonFox/Elise](https://huggingface.co/datasets/MrDragonFox/Elise)(modelscope 的[镜像](https://www.modelscope.cn/datasets/RealmSky/Elise) ) 19 | 20 | ### 微调实验结果示例 21 | 22 | | 参考音频 | 文本 | 语音 | 23 | | --- | --- | --- | 24 | |[Female-1][Female_1]| Seriously? <giggles> That's the cutest thing I've ever heard! | [Synthesized Speech](samples/Female-1_SeriouslygigglesThatsthecutestt.wav) | 25 | | [Female-1][Female_1] | 真的吗? <giggles> 这也太可爱了吧!| [Synthesized Speech](samples/Female-1_真的吗giggles这也太可爱了吧.wav) | 26 | | [Male-1][Male_1]| Wha—? Cute? <giggles> You think I'm cute?! Well, uh, thanks, I guess? | [Synthesized Speech](samples/Male-1_Wha—CutegigglesYouthinkImcute.wav) | 27 | | [Male-1][Male_1]| 哎呀! 忘了他还在那等我们呢!<giggles> 我们两个动作得快点了!| [Synthesized Speech](samples/Male-1_哎呀忘了他还在那等我们呢giggles我们两个动作得快点了.wav) | 28 | 29 | ### IndexTTS 模型架构 30 | 31 | ```mermaid 32 | flowchart TD 33 | D("参考文本") -->BPE[[**BPE**]] --> T(文本 Token ID) 34 | A("参考语音") --> M(Mel-Spectrogram) --> VAE[[*DiscreteVAE*]]--> B(Mel-Spec 编码 ID) 35 | A -->CE[[*Conformer Encoder*]] --> Pe[[*Perceiver Resampler*]] --> CA(参考语音上下文向量) -->|上下文条件| C 36 | B --> C 37 | T --> C[[**GPT2**]] 38 | C --> L("目标语音的潜在表示 39 | *隐藏状态*") 40 | L --> V[["*BigVGAN* 41 | (Generator)"]] 42 | A --> SP[[*ECAPA-TDNN*]]--> S(说话人 Embedding) 43 | S --> V 44 | V -->|合成| PCM("音频波形 (PCM)") --> W("语音音频") 45 | ``` 46 | 47 | ### 本项目微调的模块 48 | 49 | - **BPE**: 实际为 `sentencepiece`,为它增加新的特殊标签 token,如 `` 具体过程请参见 [preprocess_mel_dataset.ipynb](preprocess_mel_dataset.ipynb) 笔记本。 50 | - **GPT2**: 自回归模型部分,使用 [🤗 peft](https://huggingface.co/docs/peft/v0.15.0/en/index) 库进行`LoRA`微调,支持生成带有特殊标签文本的语音 Latent,具体过程请参见 [fine_tune_indextts.ipynb](fine_tune_indextts.ipynb) 笔记本。 51 | 52 | 53 | ## Disclaimer 54 | 55 | The reference audio files and the datasets used in this project are granted under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) license. 56 | They are used for the research and demonstration purposes of this project only, and are not intended for any commercial use. 57 | The synthesized audio files generated by this project are also not intended for commercial use. 58 | 59 | [Female_1]: https://bytedancespeech.github.io/seedtts_tech_report/audios/SpeechFactorization_samples/prompt/prompt1/4813840990459345930.wav 60 | [Male_1]: https://bytedancespeech.github.io/seedtts_tech_report/audios/SpeechFactorization_samples/source/2188769758301752050.wav 61 | 62 | -------------------------------------------------------------------------------- /samples/Female-1_SeriouslygigglesThatsthecutestt.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrom/finetune-index-tts/ec9459ed9a932afee1eafc1adbcaafefcfb26147/samples/Female-1_SeriouslygigglesThatsthecutestt.wav -------------------------------------------------------------------------------- /samples/Female-1_真的吗giggles这也太可爱了吧.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrom/finetune-index-tts/ec9459ed9a932afee1eafc1adbcaafefcfb26147/samples/Female-1_真的吗giggles这也太可爱了吧.wav -------------------------------------------------------------------------------- /samples/Male-1_Wha—CutegigglesYouthinkImcute.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrom/finetune-index-tts/ec9459ed9a932afee1eafc1adbcaafefcfb26147/samples/Male-1_Wha—CutegigglesYouthinkImcute.wav -------------------------------------------------------------------------------- /samples/Male-1_哎呀忘了他还在那等我们呢giggles我们两个动作得快点了.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrom/finetune-index-tts/ec9459ed9a932afee1eafc1adbcaafefcfb26147/samples/Male-1_哎呀忘了他还在那等我们呢giggles我们两个动作得快点了.wav --------------------------------------------------------------------------------