williampike commited on
Commit
4d3248c
·
verified ·
1 Parent(s): 86a94cc

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +37 -35
  2. .github/workflows/docker-publish.yml +44 -0
  3. .gitignore +47 -0
  4. .python-version +1 -0
  5. DISCLAIMER +43 -0
  6. LICENSE +57 -0
  7. LICENSE_ZH.txt +52 -0
  8. MANIFEST.in +3 -0
  9. README.md +36 -0
  10. README_old.md +503 -0
  11. archive/README_INDEXTTS_1_5.md +247 -0
  12. assets/IndexTTS.png +3 -0
  13. assets/IndexTTS2-video-pic.png +3 -0
  14. assets/IndexTTS2.mp4 +3 -0
  15. assets/IndexTTS2.png +0 -0
  16. assets/IndexTTS2_banner.png +3 -0
  17. assets/img.png +0 -0
  18. assets/index_icon.png +0 -0
  19. checkpoints/config.yaml +120 -0
  20. checkpoints/qwen0.6bemo4-merge/Modelfile +11 -0
  21. checkpoints/qwen0.6bemo4-merge/added_tokens.json +28 -0
  22. checkpoints/qwen0.6bemo4-merge/chat_template.jinja +4 -0
  23. checkpoints/qwen0.6bemo4-merge/config.json +30 -0
  24. checkpoints/qwen0.6bemo4-merge/generation_config.json +6 -0
  25. checkpoints/qwen0.6bemo4-merge/merges.txt +0 -0
  26. checkpoints/qwen0.6bemo4-merge/model.safetensors +3 -0
  27. checkpoints/qwen0.6bemo4-merge/special_tokens_map.json +31 -0
  28. checkpoints/qwen0.6bemo4-merge/tokenizer.json +3 -0
  29. checkpoints/qwen0.6bemo4-merge/tokenizer_config.json +240 -0
  30. checkpoints/qwen0.6bemo4-merge/vocab.json +0 -0
  31. checkpoints/thai_gpt_v5/best_model_step65000.pth +3 -0
  32. checkpoints/thai_gpt_v5/best_model_step66000.pth +3 -0
  33. checkpoints/thai_gpt_v5/best_model_step67000.pth +3 -0
  34. checkpoints/thai_gpt_v5/latest.pth +3 -0
  35. checkpoints/thai_gpt_v5/logs/run_20260426_001816/events.out.tfevents.1777137496.DESKTOP-P89J176.29048.0 +3 -0
  36. checkpoints/thai_gpt_v5/logs/run_20260426_231721/events.out.tfevents.1777220241.DESKTOP-P89J176.30436.0 +3 -0
  37. checkpoints/thai_gpt_v5/logs/run_20260427_074202/events.out.tfevents.1777250522.DESKTOP-P89J176.13632.0 +3 -0
  38. checkpoints/thai_gpt_v5/model_step65000.pth +3 -0
  39. checkpoints/thai_gpt_v5/model_step66000.pth +3 -0
  40. checkpoints/thai_gpt_v5/model_step67000.pth +3 -0
  41. docs/README_zh.md +399 -0
  42. examples/cases.jsonl +12 -0
  43. examples/emo_hate.wav +3 -0
  44. examples/emo_sad.wav +3 -0
  45. examples/voice_01.wav +3 -0
  46. examples/voice_02.wav +3 -0
  47. examples/voice_03.wav +3 -0
  48. examples/voice_04.wav +3 -0
  49. extend_bpe.bat +7 -0
  50. indextts/BigVGAN/ECAPA_TDNN.py +656 -0
.gitattributes CHANGED
@@ -1,35 +1,37 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
1
+ examples/voice_02.wav filter=lfs diff=lfs merge=lfs -text
2
+ examples/voice_04.wav filter=lfs diff=lfs merge=lfs -text
3
+ examples/emo_sad.wav filter=lfs diff=lfs merge=lfs -text
4
+ examples/voice_03.wav filter=lfs diff=lfs merge=lfs -text
5
+ examples/voice_06.wav filter=lfs diff=lfs merge=lfs -text
6
+ examples/voice_08.wav filter=lfs diff=lfs merge=lfs -text
7
+ tests/sample_prompt.wav filter=lfs diff=lfs merge=lfs -text
8
+ examples/emo_hate.wav filter=lfs diff=lfs merge=lfs -text
9
+ examples/voice_01.wav filter=lfs diff=lfs merge=lfs -text
10
+ examples/voice_05.wav filter=lfs diff=lfs merge=lfs -text
11
+ examples/voice_09.wav filter=lfs diff=lfs merge=lfs -text
12
+ examples/voice_10.wav filter=lfs diff=lfs merge=lfs -text
13
+ examples/voice_12.wav filter=lfs diff=lfs merge=lfs -text
14
+ examples/voice_07.wav filter=lfs diff=lfs merge=lfs -text
15
+ examples/voice_11.wav filter=lfs diff=lfs merge=lfs -text
16
+ assets/IndexTTS.png filter=lfs diff=lfs merge=lfs -text
17
+ assets/IndexTTS2-video-pic.png filter=lfs diff=lfs merge=lfs -text
18
+ assets/IndexTTS2.mp4 filter=lfs diff=lfs merge=lfs -text
19
+ assets/IndexTTS2_banner.png filter=lfs diff=lfs merge=lfs -text
20
+ checkpoints/qwen0.6bemo4-merge/model.safetensors filter=lfs diff=lfs merge=lfs -text
21
+ checkpoints/qwen0.6bemo4-merge/tokenizer.json filter=lfs diff=lfs merge=lfs -text
22
+ checkpoints/thai_gpt_v5/best_model_step65000.pth filter=lfs diff=lfs merge=lfs -text
23
+ checkpoints/thai_gpt_v5/best_model_step66000.pth filter=lfs diff=lfs merge=lfs -text
24
+ checkpoints/thai_gpt_v5/best_model_step67000.pth filter=lfs diff=lfs merge=lfs -text
25
+ checkpoints/thai_gpt_v5/latest.pth filter=lfs diff=lfs merge=lfs -text
26
+ checkpoints/thai_gpt_v5/logs/run_20260426_001816/events.out.tfevents.1777137496.DESKTOP-P89J176.29048.0 filter=lfs diff=lfs merge=lfs -text
27
+ checkpoints/thai_gpt_v5/logs/run_20260426_231721/events.out.tfevents.1777220241.DESKTOP-P89J176.30436.0 filter=lfs diff=lfs merge=lfs -text
28
+ checkpoints/thai_gpt_v5/logs/run_20260427_074202/events.out.tfevents.1777250522.DESKTOP-P89J176.13632.0 filter=lfs diff=lfs merge=lfs -text
29
+ checkpoints/thai_gpt_v5/model_step65000.pth filter=lfs diff=lfs merge=lfs -text
30
+ checkpoints/thai_gpt_v5/model_step66000.pth filter=lfs diff=lfs merge=lfs -text
31
+ checkpoints/thai_gpt_v5/model_step67000.pth filter=lfs diff=lfs merge=lfs -text
32
+ indextts/utils/maskgct/models/codec/facodec/modules/JDC/bst.t7 filter=lfs diff=lfs merge=lfs -text
33
+ indextts/utils/maskgct/models/tts/maskgct/ckpt/wav2vec2bert_stats.pt filter=lfs diff=lfs merge=lfs -text
34
+ models/thailand4.pth filter=lfs diff=lfs merge=lfs -text
35
+ models/thaiseperate2.pt filter=lfs diff=lfs merge=lfs -text
36
+ models/thaiseperate2.pth filter=lfs diff=lfs merge=lfs -text
37
+ tiny.model filter=lfs diff=lfs merge=lfs -text
.github/workflows/docker-publish.yml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Publish Docker Image
2
+ on:
3
+ workflow_dispatch:
4
+
5
+ jobs:
6
+ build-amd64:
7
+ runs-on: ubuntu-22.04
8
+ strategy:
9
+ matrix:
10
+ include:
11
+ - cuda_version: 11.8
12
+ torch_version: 2.4.1
13
+ tag_prefix: pytorch2.4.1-cuda11.8
14
+ - cuda_version: 12.8
15
+ torch_version: 2.8.0
16
+ tag_prefix: pytorch2.8.0-cuda12.8
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Extract Docker Meta
22
+ id: meta
23
+ uses: docker/metadata-action@v5
24
+ with:
25
+ images: nanaoto/index-tts
26
+
27
+ - name: Set up Docker Buildx
28
+ uses: docker/setup-buildx-action@v3
29
+
30
+ - name: Build Docker Image
31
+ uses: docker/build-push-action@v5
32
+ with:
33
+ context: .
34
+ file: ./Dockerfile
35
+ push: false
36
+ platforms: linux/amd64
37
+ build-args: |
38
+ CUDA_VERSION=${{ matrix.cuda_version }}
39
+ TORCH_VERSION=${{ matrix.torch_version }}
40
+ tags: |
41
+ nanaoto/index-tts:${{ matrix.tag_prefix }}-${{ steps.meta.outputs.tags }}-amd64
42
+ nanaoto/index-tts:latest-${{ matrix.tag_prefix }}-amd64
43
+
44
+
.gitignore ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Development Tools.
2
+ .mypy_cache/
3
+ .ruff_cache/
4
+ __pycache__/
5
+ .idea/
6
+ .vscode/
7
+
8
+ # Environments.
9
+ .venv*/
10
+ venv*/
11
+ conda_env*/
12
+
13
+ # Python Bytecode.
14
+ *.py[cod]
15
+
16
+ # Distribution/Packaging.
17
+ /build/
18
+ /dist/
19
+ *.egg-info/
20
+ .pypirc
21
+
22
+ # Operating System Junk.
23
+ *.DS_Store
24
+ Thumbs.db
25
+ desktop.ini
26
+
27
+ # IndexTTS.
28
+ /cache/
29
+ /checkpoints/*
30
+ !/checkpoints/*.yaml
31
+ /outputs/
32
+ *processed_data/
33
+ DeepSpeed/
34
+ *datasets/
35
+ hf_cache/
36
+ *_dataset/
37
+ *trained_ckpts*
38
+ prompts/
39
+ *.whl
40
+
41
+ # Excluded for Hugging Face upload
42
+ /outputs/
43
+ /spare/
44
+ /omniman2/
45
+ /omniman2_data/
46
+ /dataset/
47
+ /dataset2/
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.10
DISCLAIMER ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ TTS语音合成技术免责声明
2
+
3
+ 1. 总则
4
+ 本声明适用于 Index-TTS(以下简称"本项目")的所有用户和使用者。使用本项目即表示您已阅读、理解并同意遵守本免责声明的全部内容。
5
+
6
+ 2. 使用限制
7
+ 2.1 本项目仅供用户进行技术研究、学习和合法的创意应用,不得用于任何违反法律法规的活动。
8
+
9
+ 2.2 用户不得使用本项目:
10
+ a) 合成政治人物、公众人物或任何未经授权的个人声音;
11
+ b) 创建诋毁、侮辱、歧视或损害他人名誉和权益的内容;
12
+ c) 进行欺诈、身份盗用或任何形式的违法活动;
13
+ d) 传播虚假信息或制造社会恐慌;
14
+ e) 侵犯他人知识产权、肖像权或隐私权;
15
+ f) 未经授权将合成声音用于商业目的;
16
+ g) 违反特定行业(如金融、医疗等)的法规要求;
17
+ h) 创建或使用涉及未成年人的不当声音内容;
18
+ i) 制作可能威胁国家安全的内容;
19
+ j) 违反任何地区关于深度伪造技术的法律法规。
20
+
21
+ 3. 知识产权与授权
22
+ 3.1 本项目以[开源许可证类型]许可证开源。
23
+ 3.2 用户在使用本项目过程中产生的所有内容及其法律责任由用户自行承担。
24
+
25
+ 4. 责任限制
26
+ 4.1 项目开发者不对用户使用本项目所产生的任何直接或间接后果承担责任。
27
+ 4.2 项目开发者不保证本项目的功能满足用户的所有需求,也不保证运行不会中断或出错。
28
+ 4.3 用户因使用本项目而产生的任何法律纠纷、损失或损害,项目开发者概不负责。
29
+
30
+ 5. 法律适用
31
+ 5.1 本免责声明受[国家/地区]法律管辖。
32
+ 5.2 如本声明的任何条款与适用法律相抵触,则以适用法律为准。
33
+
34
+ 6. 声明更新
35
+ 6.1 项目开发者保留随时更新本免责声明的权利,更新后的声明自发布之日起生效。
36
+ 6.2 用户应定期查阅本声明以了解任何变更。
37
+
38
+ 7. 其他条款
39
+ 7.1 用户在使用本项目前,应确保其使用行为符合所在地区的法律法规。
40
+ 7.2 如用户对本项目的使用引起任何法律纠纷,用户应积极配合相关调查并承担相应责任。
41
+
42
+ 最后更新日期:2025.3.17
43
+ 开发者:Bilibili Index Team
LICENSE ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bilibili Model Use License Agreement
2
+
3
+ By clicking “I agree” to this bilibili Model Use License Agreement (“this Agreement”) , or by otherwise using any portion or element of the Model or any Derivative Work, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately. If you do not agree to this Agreement, you must immediately cease all use and permanently delete the Model and any Derivative Works.
4
+
5
+ 1. Definitions
6
+ 1.1 “This Agreement”: means the bilibili Model Use License Agreement, including all of its terms and conditions.
7
+ 1.2 “We”, “us”, or “our”: means bilibili , the original right-holder of the Model.
8
+ 1.3 “You”: means any natural person or legal entity exercising rights granted by this Agreement and/or using the Model for any purpose and in any field of use.
9
+ 1.4 “Model”: means the artificial-intelligence model named “bilibili indextts2”, including but not limited to model weights and final code, in each case only to the extent that such components are published by us at https://github.com/index-tts/index-tts.
10
+ 1.5 “Derivative Work”: means any derivative of the Model, including without limitation:
11
+  (i) any modification of the Model, model outputs, or their derivatives;
12
+  (ii) any work based on the Model, model outputs, or their derivatives;
13
+  (iii) any other machine learning model which is created by re-training, fine-tuning, quantizing, LoRA, parameter-efficient fine-tuning, or any other method involving incremental weights or merged checkpoints, in each case based on the Model, model outputs, or their derivatives.
14
+ 1.6 “Use”: means downloading, copying, training, modifying, creating Derivative Works, distributing, publishing, running, fine-tuning, publicly displaying, communicating to the public, or otherwise exploiting the Model or any Derivative Work.
15
+
16
+ 2. Scope of License and Restrictions
17
+ 2.1 Subject to the terms and conditions of this Agreement, we grant you a worldwide, non-exclusive, non-transferable, royalty-free limited license to Use the Model or any Derivative Work based on the intellectual properties or other rights owned by Us embodied in the Model or any Derivative Work.
18
+ 2.2 If You intend to Use, or have already Used, the Model or any Derivative Work, and either (i) your or any of your Affiliates’ products or services had more than 100 million monthly active users in the immediately preceding calendar month, or (ii) your or any of your Affiliates’ annual revenue in the immediately preceding calendar year exceeded RMB 1 billion, You must request a separated license from us, which We may grant to You in our sole discretion. You are not authorized to exercise any of the rights under this Agreement unless and until We have expressly granted You such rights in writing.
19
+ 2.3 This Agreement is an open-source license for the Model in which we possess intellectual properties and other rights. It governs your Use of the Model only and does not limit any rights that we have regarding the Model.
20
+
21
+ 3. Disclaimer and Risk Allocation
22
+ 3.1 The Model and any outputs generated thereby are provided “AS IS,” without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, non-infringement, absence of errors or omissions, continuity, accuracy, reliability, or stability. You are solely responsible for determining the appropriateness of using or redistributing the Model and assume all risks associated with exercising any rights granted under this Agreement.
23
+ 3.2 You shall bear sole responsibility for any infringement, illegality, breach of contract, damages, fines, regulatory investigations, or other liabilities (including, without limitation, infringement of third-party patents, copyrights, trademarks, trade secrets, personality rights, data-protection rights, or any other rights) arising out of or related to your Use of the Model or any outputs generated thereby. We assume no joint, several, supplementary, or advance payment liability.
24
+ 3.3 Under no circumstances shall we be liable to you or any third party for any direct, indirect, incidental, special, punitive, or consequential damages (including, without limitation, loss of data, business interruption, or loss of profits) arising out of or related to the Use of the Model, even if we have been advised of the possibility of such damages.
25
+ 3.4 Additional Obligations for You and Downstream Recipients
26
+ a) You must ensure that any downstream recipient of the Model or any Derivative Work that you distribute complies with this Agreement, and you must impose appropriate contractual terms on such downstream recipients. If any downstream recipient breaches this Agreement, you shall be responsible for the consequences thereof.
27
+ b) You must retain all original copyright notices and a copy of this Agreement in every copy of the Model or any Derivative Work that you Use.
28
+ c) You may not Use the bilibili indextts2 or any Derivative Work to improve any AI model, except for the bilibili indextts2 itself, its Derivative Works,or non-commercial AI models.
29
+
30
+ 4. Compliance Obligations
31
+ 4.1 Usage Restrictions
32
+ a) If you distribute a Derivative Work, you must clearly state in the distribution page or accompanying documentation: “Any modifications made to the original model in this Derivative Work are not endorsed, warranted, or guaranteed by the original right-holder of the original model, and the original right-holder disclaims all liability related to this Derivative Work.”
33
+ b) If your Use of the Model or any Derivative Work incorporates any third-party data or weights, you must obtain all necessary authorizations on your own and bear full responsibility for compliance.
34
+ c) You may not Use the Model or any Derivative Work for any purpose that violates the laws or regulatory requirements of the jurisdiction where the outputs and/or the Model are generated or used (including, without limitation, generating false information, discriminatory content, or content that infringes privacy).
35
+ d) If the Model or any Derivative Work is capable of generating content, you must ensure that such content does not violate the laws or regulatory requirements of the applicable jurisdiction (including, without limitation, generating false information, discriminatory content, or content that infringes privacy).
36
+ 4.2 Prohibited High-Risk Use
37
+ You must ensure that the Model and any Derivative Work are not deployed, directly or indirectly, in high-risk scenarios such as medical diagnosis, autonomous driving, military applications, critical-infrastructure control, large-scale biometric surveillance, or automated decision-making (e.g., credit or employment evaluations). If you insist on such deployment, you must independently complete all compliance obligations under applicable laws and regulations (including but not limited to GDPR, CCPA, HIPAA, export-control laws, and AI-specific regulations), and we shall bear no liability for any consequences arising therefrom.
38
+ 4.3 Infringement Liability
39
+ Should any third party raise claims against you with respect to any Derivative Work you develop or your Use of the Model or any Derivative Work, you shall bear full and independent responsibility for defending against and resolving such claims. If your actions cause us to incur any third-party claims, administrative penalties, or other losses, you shall indemnify us for all losses we thereby suffer, including but not limited to attorney fees, litigation costs, damages, and fines, and shall take all necessary measures to eliminate any adverse impact on us.
40
+
41
+ 5. Reserved Rights
42
+ 5.1 We reserve the right to revoke the license granted to you under this Agreement in the event of your breach. Upon revocation, you must immediately cease all Use and permanently delete all copies of the Model and any Derivative Work. Sections 3 and 6 of this Agreement shall survive termination of this Agreement under this circumstance.
43
+ 5.2 Nothing in this Agreement grants you any right to use our trade names, trademarks, service marks, or product names, except as reasonably and customarily required to describe the origin of the Model or any Derivative Work—such as reproducing the content of a NOTICE file under Section 3.4 of this Agreement.
44
+ 5.3 If you or any of your Affiliates institutes or participates in any legal proceeding (including any cross-claim or counterclaim in a lawsuit) against us or any of our Affiliates, alleging that the Model or any output or any portion thereof infringes any intellectual property or other rights that you own or control, all licenses granted to you under this Agreement shall terminate automatically as of the date such proceeding is filed.
45
+
46
+ 6. Governing Law and Dispute Resolution
47
+ 6.1 This Agreement shall be governed by and construed in accordance with the laws of the People’s Republic of China.
48
+ 6.2 In the event of any dispute arising out of or in connection with this Agreement, the parties shall first attempt to resolve such dispute through friendly negotiation. If negotiation fails, the dispute shall be submitted to the Shanghai Arbitration Commission for arbitration in accordance with its then-effective arbitration rules. The arbitration award shall be final and binding on both parties. The prevailing party shall be entitled to recover reasonable costs, including notarization and investigation fees, arbitration costs, attorneys’ fees, and travel expenses.
49
+
50
+ 7. Severability
51
+ If any provision of this Agreement is held to be invalid or unenforceable, the remaining provisions shall remain in full force and effect. The invalid or unenforceable provision shall be replaced with a valid and enforceable provision that, to the maximum extent permitted by law, most closely reflects the original intent of the invalid or unenforceable provision.
52
+
53
+ 8. Version Updates
54
+ We may release new versions of the AI Model Use License Agreement. Any new version will apply only to Uses occurring after the date of its release. If you obtained the Model under an earlier version, the new version will not have retroactive effect; nevertheless, you are encouraged to adopt the new version voluntarily.
55
+
56
+ 9. Language Version
57
+ In the event of any discrepancy or conflict between the English-language version set forth above and the Chinese-language version of this bilibili Model Use License Agreement, the Chinese-language version shall prevail for all purposes and shall govern the rights and obligations of the parties.
LICENSE_ZH.txt ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bilibili模型使用许可协议
2
+
3
+ 若您点击同意《bilibili模型使用许可协议》(“本协议”),或使用我方模型或衍生品的任何部分或元素,即视为您已确认并接受本协议内容,本协议立即生效。若您不同意本协议,应立即停止使用并删除模型及衍生品。
4
+
5
+ 1.定义
6
+ 1.1 本协议:指《bilibili 模型使用许可协议》,包括本协议所规定的所有条款和条件。
7
+ 1.2 我方:指bilibili即模型的原始权利人。
8
+ 1.3 您:指行使本许可协议授予的权利和/或使用“模型”的自然人或法人实体。
9
+ 1.4 模型:指名为“bilibili indextts2”的AI模型,包括模型权重、最终代码等组件,具体范围以我方在https://github.com/index-tts/index-tts发布的组件为限。
10
+ 1.5 衍生品:指模型的衍生品,包括但不限于:(i)对模型、模型输出及其衍生品的修改;(ii)基于模型、模型输出及其衍生品的创作;(iii)对模型、模型输出及其衍生品再训练、微调、量化、LoRA、参数高效微调、以任何增量权重或合并的检查点等方式创建的任何模型。
11
+ 1.6 使用:指通过下载、复制、训练、修改、创作衍生品、分发、发布、运行、微调、公开展示、传播或以其他方式利用本模型或其衍生品的行为。
12
+
13
+ 2. 许可范围和限制
14
+ 2.1 根据本协议的条款与条件,基于对模型或其衍生品中包含的我方拥有的任何知识产权和其他权利,我方特此授予您一项全球范围、非独占、不可转让、免费的使用许可。
15
+ 2.2若您拟使用或者已使用我方模型或其衍生品,如果您或者您的关联方提供的产品或服务在前一自然月的月活跃用户数超过1亿,或者如果您或者您的关联方在上一自然年的年收入超过1亿人民币的,您必须向我方申请该模型或其衍生品的商业许可,我方可自行决定是否授予您该许可。您无权行使本协议项下的任何权利,除非我方另行明确授予您该等许可。
16
+ 2.3 本协议作为我方享有知识产权和其他权利的模型的开源许可协议,仅约束您对我方模型的使用行为,并不限制我方对该模型享有的任何权利。
17
+
18
+ 3. 免责声明与风险约定
19
+ 3.1 模型及其任何输出均“按原样”提供,我方及其关联方不提供任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性、不侵权、没有错误或疏漏、持续性、准确性、可靠性、稳定性的保证。您需自行负责判断使用或再分发本作品的适当性,并承担行使本许可证所授予权限相关的所有风险。
20
+ 3.2 您因使用模型或利用其输出内容而产生的任何侵权、违法、违约、赔偿、罚款、监管调查或其他法律责任(包括但不限于侵犯第三方专利、版权、商标、商业秘密、人格权、数据保护权等),均由您独自承担。我方不承担任何连带责任、补充责任或垫付责任。
21
+ 3.3 在任何情况下,我方对因使用本模型而产生的任何直接、间接、附带、特殊、惩罚性或后果性损失(包括但不限于数据丢失、业务中断、利润损失等)不承担责任,即使我方已被告知该等损失的可能性。
22
+ 3.4 对您和下游用户的其他约束
23
+ a)您应确保下游用户在使用您发布的本模型或您基于本模型开发的衍生品时,同样遵守本协议的相关规定,并通过合适的协议或条款对下游用户进行约束。若下游用户违反本协议规定,您需承担相应责任。
24
+ b)您需在您使用的本模型或您基于本模型开发的衍生品的所有副本中保留原始版权声明及本使用许可协议。
25
+ c)您不得使用bilibili indextts2或其衍生品来改进任何AI模型(bilibili indextts2或其衍生品、非商业用途的AI模型除外)。
26
+
27
+ 4. 合规义务
28
+ 4.1使用限制
29
+ a) 若您发布模型的衍生品,必须在发布页面或附随文档中清晰声明“该衍生品对原模型所作的任何改动与原模型原始权利人无关,原始权利人对该衍生品不背书、不担保、不承担责任”。
30
+ b) 若您使用模型或模型衍生品的过程中引入任何第三方数据或权重,您须自行取得合法授权并承担全部合规责任。
31
+ c) 不得将模型及模型衍生品用于违反输出地/使用地法律或监管要求的用途(包括但不限于生成虚假信息、歧视性内容、侵犯隐私等)。
32
+ d) 若模型或模型衍生品具备生成内容功能,您须确保其输出内容不违反输出地/使用地法律或监管要求的用途(包括但不限于生成虚假信息、歧视性内容、侵犯隐私等)。
33
+ 4.2 禁止高风险场景
34
+ 您须自行确保不在医疗诊断、自动驾驶、军事、关键基础设施控制、大规模生物识别监控、自动化决策(如信贷、就业评估)等高风险场景直接部署本模型及其衍生品。若您坚持部署���应自行完成符合适用法规(包括 GDPR、CCPA、HIPAA、出口管制、AI 特定法规等)的全部合规要求,我方对因此产生的任何后果概不负责。
35
+ 4.3 侵权责任
36
+ 如第三方就您开发的模型衍生品或您使用模型或其衍生品等行为主张权利,您应独立承担全部责任。若因您的行为导致我方遭受任何第三方索赔、行政处罚或其他损失,您应负责赔偿我方因此遭受的全部损失,包括但不限于律师费、诉讼费、赔偿金、罚款等,并采取一切必要措施消除对我方的负面影响。
37
+
38
+ 5. 保留权利
39
+ 5.1我方保留在您违反协议的情况下撤销本协议对您授权之权利。协议撤销后,您必须立即删除并停止使用材料。在本协议终止后,本协议第3条、第6条仍然有效。
40
+ 5.2 本许可证不授予使用我方的商号、商标、服务标记或产品名称的权限,除非在合理且惯例性地描述模型或衍生品的来源,例如本许可证3.4的规定,以及复制 NOTICE 文件内容时需要使用。
41
+ 5.3 若您或您的关联方对我方或我方任何关联实体提起诉讼或其他程序(包括诉讼中的交叉索赔或反诉),主张模型或其任何输出结果或其任何部分侵犯了您拥有或可许可的知识产权或其他权利,则本协议授予您的所有许可自该诉讼或程序提起之日起终止。
42
+
43
+ 6. 法律适用与争议解决
44
+ 6.1 本协议适用中华人民共和国法律法规。
45
+ 6.2 在本协议履行中,若发生争议,双方应本着友好协商的原则解决问题;如协商不成,双方均应将争议提交至上海仲裁委员会根据其仲裁规则进行仲裁,仲裁是一裁终局的,对双方均有约束力。由仲裁败诉方承担本次仲裁产生的公证调查费、仲裁费、律师费、差旅费等实际产生费用。
46
+
47
+ 7. 可分割性
48
+ 若本协议任何条款被认定为无效或不可执行,不影响其余条款之效力;无效部分应在法律允许的最大范围内按最接近原意的有效条款替代。
49
+
50
+ 8. 协议版本更新
51
+ 我方可发布新版 AI模型使用许可协议。新版仅适用于发布后新产生的使用行为,若您已按旧版获取模型,新版协议并无溯及力,但鼓励您主动更新。
52
+
MANIFEST.in ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ global-exclude *~ *.py[cod]
2
+ include *.cu *.cpp
3
+ include *.h *.hpp
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Index TTS Project
2
+
3
+ (เพิ่มคำอธิบายโปรเจกต์ที่นี่)
4
+
5
+ ## 🚀 วิธีดาวน์โหลดและติดตั้ง (Installation)
6
+
7
+ โปรเจกต์นี้ใช้ `uv` ในการจัดการสภาพแวดล้อมและแพ็กเกจ เพื่อให้ติดตั้งง่ายและแก้ปัญหาเวอร์ชันได้อย่างสมบูรณ์
8
+
9
+ ### 1. ดาวน์โหลดโปรเจกต์
10
+ ใช้คำสั่ง Git เพื่อดาวน์โหลดไฟล์ทั้งหมด:
11
+ ```bash
12
+ git clone https://huggingface.co/williampike/index-tts
13
+ cd index-tts
14
+ ```
15
+
16
+ ### 2. สร้าง Virtual Environment และติดตั้ง Dependencies
17
+ ตรวจสอบว่าในเครื่องมี `uv` แล้ว (หากยังไม่มี ให้รัน `pip install uv` ก่อน)
18
+ จากนั้นรันคำสั่งเหล่านี้เพื่อสร้าง Virtual Environment และติดตั้งแพ็กเกจ:
19
+ ```bash
20
+ # สร้าง virtual environment
21
+ uv venv
22
+
23
+ # ติดตั้งแพ็กเกจทั้งหมดตามที่ระบุไว้
24
+ uv pip install -e .
25
+ ```
26
+ *(เคล็ดลับ: คุณสามารถใช้แค่คำสั่ง `uv sync` เพื่อจัดการทุกอย่างในรวดเดียวได้เช่นกัน)*
27
+
28
+ ### 3. รันโปรแกรม
29
+ เมื่อติดตั้งเสร็จเรียบร้อยแล้ว ให้รันโปรแกรมด้วย `uv run` เพื่อเรียกใช้งานสภาพแวดล้อมที่ถูกต้อง:
30
+ ```bash
31
+ uv run webui.py
32
+ ```
33
+ *(ถ้าต้องการรันไฟล์อื่น เช่น `webui_parallel_thai.py` ก็สามารถเปลี่ยนชื่อไฟล์ในคำสั่งได้เลย)*
34
+
35
+ ---
36
+ รายละเอียดเพิ่มเติมเดี๋ยวเพิ่มทีหลัง
README_old.md ADDED
@@ -0,0 +1,503 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Unofficial IndexTTS v2 Training Repo
2
+ > Loop and trainer implemented using Codex CLI and guided prompts
3
+ - Train new languages by extending existing tokenizer
4
+ - tools\tokenizer\train_bpe.py and tools\tokenizer\extend_bpe.py
5
+ - Preprocess data to extract speaker embeddings for timbre, emotion, text, and mel tokens
6
+ - tools\preprocess_data.py and tools\preprocess_multiproc.py (multiproc is an attempt to make it run faster, there are issues with it though crashing)
7
+ - Create prompt/target pairs which is required for how IndexTTS2 trains in order to learn how to speak with speaker timbre while separating emotion (emotion has not yet been investigated)
8
+ - tools\generate_gpt_pairs.py
9
+ - Train/finetune the gpt model to learn to predict tokens for the language
10
+ - trainers\train_gpt_v2.py and train.bat
11
+
12
+ The code here works and Japanese was *mostly* correct shown here: https://www.youtube.com/watch?v=47V7lS-HUpo (this model was trained on 1100 hours of audio for about 1.5 epochs)
13
+
14
+ The latest updates are done with a focus on training a multilingual model which shows promise, while mostly retaining the base model abilities to speak English and Chinese. Emotion finetuning has not been investigated yet and it seems that full finetuning does not mess up the base emotion capabilities of the model.
15
+
16
+ <div align="center">
17
+ <img src='assets/index_icon.png' width="250"/>
18
+ </div>
19
+
20
+ <div align="center">
21
+ <a href="docs/README_zh.md" style="font-size: 24px">简体中文</a> |
22
+ <a href="README.md" style="font-size: 24px">English</a>
23
+ </div>
24
+
25
+ ## YouTube Installation Instructions
26
+
27
+ ```
28
+ git clone https://github.com/JarodMica/index-tts.git
29
+ cd index-tts
30
+ git switch youtube
31
+ uv sync
32
+ uv run huggingface-cli download IndexTeam/IndexTTS-2 --local-dir checkpoints
33
+ uv run .\webui_parallel.py
34
+ ```
35
+
36
+ ## 👉🏻 IndexTTS2 👈🏻
37
+
38
+ <center><h3>IndexTTS2: A Breakthrough in Emotionally Expressive and Duration-Controlled Auto-Regressive Zero-Shot Text-to-Speech</h3></center>
39
+
40
+ [![IndexTTS2](assets/IndexTTS2_banner.png)](assets/IndexTTS2_banner.png)
41
+
42
+
43
+ <div align="center">
44
+ <a href='https://arxiv.org/abs/2506.21619'>
45
+ <img src='https://img.shields.io/badge/ArXiv-2506.21619-red?logo=arxiv'/>
46
+ </a>
47
+ <br/>
48
+ <a href='https://github.com/index-tts/index-tts'>
49
+ <img src='https://img.shields.io/badge/GitHub-Code-orange?logo=github'/>
50
+ </a>
51
+ <a href='https://index-tts.github.io/index-tts2.github.io/'>
52
+ <img src='https://img.shields.io/badge/GitHub-Demo-orange?logo=github'/>
53
+ </a>
54
+ <br/>
55
+ <a href='https://huggingface.co/spaces/IndexTeam/IndexTTS-2-Demo'>
56
+ <img src='https://img.shields.io/badge/HuggingFace-Demo-blue?logo=huggingface'/>
57
+ </a>
58
+ <a href='https://huggingface.co/IndexTeam/IndexTTS-2'>
59
+ <img src='https://img.shields.io/badge/HuggingFace-Model-blue?logo=huggingface' />
60
+ </a>
61
+ <br/>
62
+ <a href='https://modelscope.cn/studios/IndexTeam/IndexTTS-2-Demo'>
63
+ <img src='https://img.shields.io/badge/ModelScope-Demo-purple?logo=modelscope'/>
64
+ </>
65
+ <a href='https://modelscope.cn/models/IndexTeam/IndexTTS-2'>
66
+ <img src='https://img.shields.io/badge/ModelScope-Model-purple?logo=modelscope'/>
67
+ </a>
68
+ </div>
69
+
70
+
71
+ ### Abstract
72
+
73
+ Existing autoregressive large-scale text-to-speech (TTS) models have advantages in speech naturalness, but their token-by-token generation mechanism makes it difficult to precisely control the duration of synthesized speech. This becomes a significant limitation in applications requiring strict audio-visual synchronization, such as video dubbing.
74
+
75
+ This paper introduces IndexTTS2, which proposes a novel, general, and autoregressive model-friendly method for speech duration control.
76
+
77
+ The method supports two generation modes: one explicitly specifies the number of generated tokens to precisely control speech duration; the other freely generates speech in an autoregressive manner without specifying the number of tokens, while faithfully reproducing the prosodic features of the input prompt.
78
+
79
+ Furthermore, IndexTTS2 achieves disentanglement between emotional expression and speaker identity, enabling independent control over timbre and emotion. In the zero-shot setting, the model can accurately reconstruct the target timbre (from the timbre prompt) while perfectly reproducing the specified emotional tone (from the style prompt).
80
+
81
+ To enhance speech clarity in highly emotional expressions, we incorporate GPT latent representations and design a novel three-stage training paradigm to improve the stability of the generated speech. Additionally, to lower the barrier for emotional control, we designed a soft instruction mechanism based on text descriptions by fine-tuning Qwen3, effectively guiding the generation of speech with the desired emotional orientation.
82
+
83
+ Finally, experimental results on multiple datasets show that IndexTTS2 outperforms state-of-the-art zero-shot TTS models in terms of word error rate, speaker similarity, and emotional fidelity. Audio samples are available at: <a href="https://index-tts.github.io/index-tts2.github.io/">IndexTTS2 demo page</a>.
84
+
85
+ **Tips:** Please contact the authors for more detailed information. For commercial usage and cooperation, please contact <u>indexspeech@bilibili.com</u>.
86
+
87
+
88
+ ### Feel IndexTTS2
89
+
90
+ <div align="center">
91
+
92
+ **IndexTTS2: The Future of Voice, Now Generating**
93
+
94
+ [![IndexTTS2 Demo](assets/IndexTTS2-video-pic.png)](https://www.bilibili.com/video/BV136a9zqEk5)
95
+
96
+ *Click the image to watch the IndexTTS2 introduction video.*
97
+
98
+ </div>
99
+
100
+
101
+ ### Contact
102
+
103
+ QQ Group:663272642(No.4) 1013410623(No.5) \
104
+ Discord:https://discord.gg/uT32E7KDmy \
105
+ Email:indexspeech@bilibili.com \
106
+ You are welcome to join our community! 🌏 \
107
+ 欢迎大家来交流讨论!
108
+
109
+ > [!CAUTION]
110
+ > Thank you for your support of the bilibili indextts project!
111
+ > Please note that the **only official channel** maintained by the core team is: [https://github.com/index-tts/index-tts](https://github.com/index-tts/index-tts).
112
+ > ***Any other websites or services are not official***, and we cannot guarantee their security, accuracy, or timeliness.
113
+ > For the latest updates, please always refer to this official repository.
114
+
115
+
116
+ ## 📣 Updates
117
+
118
+ - `2025/09/08` 🔥🔥🔥 We release **IndexTTS-2** to the world!
119
+ - The first autoregressive TTS model with precise synthesis duration control, supporting both controllable and uncontrollable modes. <i>This functionality is not yet enabled in this release.</i>
120
+ - The model achieves highly expressive emotional speech synthesis, with emotion-controllable capabilities enabled through multiple input modalities.
121
+ - `2025/05/14` 🔥🔥 We release **IndexTTS-1.5**, significantly improving the model's stability and its performance in the English language.
122
+ - `2025/03/25` 🔥 We release **IndexTTS-1.0** with model weights and inference code.
123
+ - `2025/02/12` 🔥 We submitted our paper to arXiv, and released our demos and test sets.
124
+
125
+
126
+ ## 🖥️ Neural Network Architecture
127
+
128
+ Architectural overview of IndexTTS2, our state-of-the art speech model:
129
+
130
+ <picture>
131
+ <img src="assets/IndexTTS2.png" width="800"/>
132
+ </picture>
133
+
134
+
135
+ The key contributions of **IndexTTS2** are summarized as follows:
136
+
137
+ - We propose a duration adaptation scheme for autoregressive TTS models. IndexTTS2 is the first autoregressive zero-shot TTS model to combine precise duration control with natural duration generation, and the method is scalable for any autoregressive large-scale TTS model.
138
+ - The emotional and speaker-related features are decoupled from the prompts, and a feature fusion strategy is designed to maintain semantic fluency and pronunciation clarity during emotionally rich expressions. Furthermore, a tool was developed for emotion control, utilizing natural language descriptions for the benefit of users.
139
+ - To address the lack of highly expressive speech data, we propose an effective training strategy, significantly enhancing the emotional expressiveness of zeroshot TTS to State-of-the-Art (SOTA) level.
140
+ - We will publicly release the code and pre-trained weights to facilitate future research and practical applications.
141
+
142
+
143
+ ## Model Download
144
+
145
+ | **HuggingFace** | **ModelScope** |
146
+ |----------------------------------------------------------|----------------------------------------------------------|
147
+ | [😁 IndexTTS-2](https://huggingface.co/IndexTeam/IndexTTS-2) | [IndexTTS-2](https://modelscope.cn/models/IndexTeam/IndexTTS-2) |
148
+ | [IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) |
149
+ | [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) |
150
+
151
+
152
+ ## Usage Instructions
153
+
154
+ ### ⚙️ Environment Setup
155
+
156
+ 1. Ensure that you have both [git](https://git-scm.com/downloads)
157
+ and [git-lfs](https://git-lfs.com/) on your system.
158
+
159
+ The Git-LFS plugin must also be enabled on your current user account:
160
+
161
+ ```bash
162
+ git lfs install
163
+ ```
164
+
165
+ 2. Download this repository:
166
+
167
+ ```bash
168
+ git clone https://github.com/index-tts/index-tts.git && cd index-tts
169
+ git lfs pull # download large repository files
170
+ ```
171
+
172
+ 3. Install the [uv package manager](https://docs.astral.sh/uv/getting-started/installation/).
173
+ It is *required* for a reliable, modern installation environment.
174
+
175
+ > [!TIP]
176
+ > **Quick & Easy Installation Method:**
177
+ >
178
+ > There are many convenient ways to install the `uv` command on your computer.
179
+ > Please check the link above to see all options. Alternatively, if you want
180
+ > a very quick and easy method, you can install it as follows:
181
+ >
182
+ > ```bash
183
+ > pip install -U uv
184
+ > ```
185
+
186
+ > [!WARNING]
187
+ > We **only** support the `uv` installation method. Other tools, such as `conda`
188
+ > or `pip`, don't provide any guarantees that they will install the correct
189
+ > dependency versions. You will almost certainly have *random bugs, error messages,*
190
+ > ***missing GPU acceleration**, and various other problems* if you don't use `uv`.
191
+ > Please *do not report any issues* if you use non-standard installations, since
192
+ > almost all such issues are invalid.
193
+ >
194
+ > Furthermore, `uv` is [up to 115x faster](https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md)
195
+ > than `pip`, which is another *great* reason to embrace the new industry-standard
196
+ > for Python project management.
197
+
198
+ 4. Install required dependencies:
199
+
200
+ We use `uv` to manage the project's dependency environment. The following command
201
+ will *automatically* create a `.venv` project-directory and then installs the correct
202
+ versions of Python and all required dependencies:
203
+
204
+ ```bash
205
+ uv sync --all-extras
206
+ ```
207
+
208
+ If the download is slow, please try a *local mirror*, for example any of these
209
+ local mirrors in China (choose one mirror from the list below):
210
+
211
+ ```bash
212
+ uv sync --all-extras --default-index "https://mirrors.aliyun.com/pypi/simple"
213
+
214
+ uv sync --all-extras --default-index "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
215
+ ```
216
+
217
+ > [!TIP]
218
+ > **Available Extra Features:**
219
+ >
220
+ > - `--all-extras`: Automatically adds *every* extra feature listed below. You can
221
+ > remove this flag if you want to customize your installation choices.
222
+ > - `--extra webui`: Adds WebUI support (recommended).
223
+ > - `--extra deepspeed`: Adds DeepSpeed support (may speed up inference on some
224
+ > systems).
225
+
226
+ > [!IMPORTANT]
227
+ > **Important (Windows):** The DeepSpeed library may be difficult to install for
228
+ > some Windows users. You can skip it by removing the `--all-extras` flag. If you
229
+ > want any of the other extra features above, you can manually add their specific
230
+ > feature flags instead.
231
+ >
232
+ > **Important (Linux/Windows):** If you see an error about CUDA during the installation,
233
+ > please ensure that you have installed NVIDIA's [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit)
234
+ > version **12.8** (or newer) on your system.
235
+
236
+ 5. Download the required models via [uv tool](https://docs.astral.sh/uv/guides/tools/#installing-tools):
237
+
238
+ Download via `huggingface-cli`:
239
+
240
+ ```bash
241
+ uv tool install "huggingface-hub[cli,hf_xet]"
242
+
243
+ hf download IndexTeam/IndexTTS-2 --local-dir=checkpoints
244
+ ```
245
+
246
+ Or download via `modelscope`:
247
+
248
+ ```bash
249
+ uv tool install "modelscope"
250
+
251
+ modelscope download --model IndexTeam/IndexTTS-2 --local_dir checkpoints
252
+ ```
253
+
254
+ > [!IMPORTANT]
255
+ > If the commands above aren't available, please carefully read the `uv tool`
256
+ > output. It will tell you how to add the tools to your system's path.
257
+
258
+ > [!NOTE]
259
+ > In addition to the above models, some small models will also be automatically
260
+ > downloaded when the project is run for the first time. If your network environment
261
+ > has slow access to HuggingFace, it is recommended to execute the following
262
+ > command before running the code:
263
+ >
264
+ > ```bash
265
+ > export HF_ENDPOINT="https://hf-mirror.com"
266
+ > ```
267
+
268
+
269
+ #### 🖥️ Checking PyTorch GPU Acceleration
270
+
271
+ If you need to diagnose your environment to see which GPUs are detected,
272
+ you can use our included utility to check your system:
273
+
274
+ ```bash
275
+ uv run tools/gpu_check.py
276
+ ```
277
+
278
+
279
+ ### 🔥 IndexTTS2 Quickstart
280
+
281
+ #### 🌐 Web Demo
282
+
283
+ ```bash
284
+ uv run webui.py
285
+ ```
286
+
287
+ Open your browser and visit `http://127.0.0.1:7860` to see the demo.
288
+
289
+ You can also adjust the settings to enable features such as FP16 inference (lower
290
+ VRAM usage), DeepSpeed acceleration, compiled CUDA kernels for speed, etc. All
291
+ available options can be seen via the following command:
292
+
293
+ ```bash
294
+ uv run webui.py -h
295
+ ```
296
+
297
+ Have fun!
298
+
299
+ > [!IMPORTANT]
300
+ > It can be very helpful to use **FP16** (half-precision) inference. It is faster
301
+ > and uses less VRAM, with a very small quality loss.
302
+ >
303
+ > **DeepSpeed** *may* also speed up inference on some systems, but it could also
304
+ > make it slower. The performance impact is highly dependent on your specific
305
+ > hardware, drivers and operating system. Please try with and without it,
306
+ > to discover what works best on your personal system.
307
+ >
308
+ > Lastly, be aware that *all* `uv` commands will **automatically activate** the correct
309
+ > per-project virtual environments. Do *not* manually activate any environments
310
+ > before running `uv` commands, since that could lead to dependency conflicts!
311
+
312
+
313
+ #### 📝 Using IndexTTS2 in Python
314
+
315
+ To run scripts, you *must* use the `uv run <file.py>` command to ensure that
316
+ the code runs inside your current "uv" environment. It *may* sometimes also be
317
+ necessary to add the current directory to your `PYTHONPATH`, to help it find
318
+ the IndexTTS modules.
319
+
320
+ Example of running a script via `uv`:
321
+
322
+ ```bash
323
+ PYTHONPATH="$PYTHONPATH:." uv run indextts/infer_v2.py
324
+ ```
325
+
326
+ Here are several examples of how to use IndexTTS2 in your own scripts:
327
+
328
+ 1. Synthesize new speech with a single reference audio file (voice cloning):
329
+
330
+ ```python
331
+ from indextts.infer_v2 import IndexTTS2
332
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
333
+ text = "Translate for me, what is a surprise!"
334
+ tts.infer(spk_audio_prompt='examples/voice_01.wav', text=text, output_path="gen.wav", verbose=True)
335
+ ```
336
+
337
+ 2. Using a separate, emotional reference audio file to condition the speech synthesis:
338
+
339
+ ```python
340
+ from indextts.infer_v2 import IndexTTS2
341
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
342
+ text = "酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。"
343
+ tts.infer(spk_audio_prompt='examples/voice_07.wav', text=text, output_path="gen.wav", emo_audio_prompt="examples/emo_sad.wav", verbose=True)
344
+ ```
345
+
346
+ 3. When an emotional reference audio file is specified, you can optionally set
347
+ the `emo_alpha` to adjust how much it affects the output.
348
+ Valid range is `0.0 - 1.0`, and the default value is `1.0` (100%):
349
+
350
+ ```python
351
+ from indextts.infer_v2 import IndexTTS2
352
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
353
+ text = "酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。"
354
+ tts.infer(spk_audio_prompt='examples/voice_07.wav', text=text, output_path="gen.wav", emo_audio_prompt="examples/emo_sad.wav", emo_alpha=0.9, verbose=True)
355
+ ```
356
+
357
+ 4. It's also possible to omit the emotional reference audio and instead provide
358
+ an 8-float list specifying the intensity of each emotion, in the following order:
359
+ `[happy, angry, sad, afraid, disgusted, melancholic, surprised, calm]`.
360
+ You can additionally use the `use_random` parameter to introduce stochasticity
361
+ during inference; the default is `False`, and setting it to `True` enables
362
+ randomness:
363
+
364
+ > [!NOTE]
365
+ > Enabling random sampling will reduce the voice cloning fidelity of the speech
366
+ > synthesis.
367
+
368
+ ```python
369
+ from indextts.infer_v2 import IndexTTS2
370
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
371
+ text = "哇塞!这个爆率也太高了!欧皇附体了!"
372
+ tts.infer(spk_audio_prompt='examples/voice_10.wav', text=text, output_path="gen.wav", emo_vector=[0, 0, 0, 0, 0, 0, 0.45, 0], use_random=False, verbose=True)
373
+ ```
374
+
375
+ 5. Alternatively, you can enable `use_emo_text` to guide the emotions based on
376
+ your provided `text` script. Your text script will then automatically
377
+ be converted into emotion vectors.
378
+ It's recommended to use `emo_alpha` around 0.6 (or lower) when using the text
379
+ emotion modes, for more natural sounding speech.
380
+ You can introduce randomness with `use_random` (default: `False`;
381
+ `True` enables randomness):
382
+
383
+ ```python
384
+ from indextts.infer_v2 import IndexTTS2
385
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
386
+ text = "快躲起来!是他要来了!他要来抓我们了!"
387
+ tts.infer(spk_audio_prompt='examples/voice_12.wav', text=text, output_path="gen.wav", emo_alpha=0.6, use_emo_text=True, use_random=False, verbose=True)
388
+ ```
389
+
390
+ 6. It's also possible to directly provide a specific text emotion description
391
+ via the `emo_text` parameter. Your emotion text will then automatically be
392
+ converted into emotion vectors. This gives you separate control of the text
393
+ script and the text emotion description:
394
+
395
+ ```python
396
+ from indextts.infer_v2 import IndexTTS2
397
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
398
+ text = "快躲起来!是他要来了!他要来抓我们了!"
399
+ emo_text = "你吓死我了!你是鬼吗?"
400
+ tts.infer(spk_audio_prompt='examples/voice_12.wav', text=text, output_path="gen.wav", emo_alpha=0.6, use_emo_text=True, emo_text=emo_text, use_random=False, verbose=True)
401
+ ```
402
+
403
+ > [!TIP]
404
+ > **Pinyin Usage Notes:**
405
+ >
406
+ > IndexTTS2 still supports mixed modeling of Chinese characters and Pinyin.
407
+ > When you need precise pronunciation control, please provide text with specific Pinyin annotations to activate the Pinyin control feature.
408
+ > Note that Pinyin control does not work for every possible consonant–vowel combination; only valid Chinese Pinyin cases are supported.
409
+ > For the full list of valid entries, please refer to `checkpoints/pinyin.vocab`.
410
+ >
411
+ > Example:
412
+ > ```
413
+ > 之前你做DE5很好,所以这一次也DEI3做DE2很好才XING2,如果这次目标完成得不错的话,我们就直接打DI1去银行取钱。
414
+ > ```
415
+
416
+ ### Legacy: IndexTTS1 User Guide
417
+
418
+ You can also use our previous IndexTTS1 model by importing a different module:
419
+
420
+ ```python
421
+ from indextts.infer import IndexTTS
422
+ tts = IndexTTS(model_dir="checkpoints",cfg_path="checkpoints/config.yaml")
423
+ voice = "examples/voice_07.wav"
424
+ text = "大家好,我现在正在bilibili 体验 ai 科技,说实话,来之前我绝对想不到!AI技术已经发展���这样匪夷所思的地步了!比如说,现在正在说话的其实是B站为我现场复刻的数字分身,简直就是平行宇宙的另一个我了。如果大家也想体验更多深入的AIGC功能,可以访问 bilibili studio,相信我,你们也会吃惊的。"
425
+ tts.infer(voice, text, 'gen.wav')
426
+ ```
427
+
428
+ For more detailed information, see [README_INDEXTTS_1_5](archive/README_INDEXTTS_1_5.md),
429
+ or visit the IndexTTS1 repository at <a href="https://github.com/index-tts/index-tts/tree/v1.5.0">index-tts:v1.5.0</a>.
430
+
431
+
432
+ ## Our Releases and Demos
433
+
434
+ ### IndexTTS2: [[Paper]](https://arxiv.org/abs/2506.21619); [[Demo]](https://index-tts.github.io/index-tts2.github.io/); [[ModelScope]](https://modelscope.cn/studios/IndexTeam/IndexTTS-2-Demo); [[HuggingFace]](https://huggingface.co/spaces/IndexTeam/IndexTTS-2-Demo)
435
+
436
+ ### IndexTTS1: [[Paper]](https://arxiv.org/abs/2502.05512); [[Demo]](https://index-tts.github.io/); [[ModelScope]](https://modelscope.cn/studios/IndexTeam/IndexTTS-Demo); [[HuggingFace]](https://huggingface.co/spaces/IndexTeam/IndexTTS)
437
+
438
+
439
+ ## Acknowledgements
440
+
441
+ 1. [tortoise-tts](https://github.com/neonbjb/tortoise-tts)
442
+ 2. [XTTSv2](https://github.com/coqui-ai/TTS)
443
+ 3. [BigVGAN](https://github.com/NVIDIA/BigVGAN)
444
+ 4. [wenet](https://github.com/wenet-e2e/wenet/tree/main)
445
+ 5. [icefall](https://github.com/k2-fsa/icefall)
446
+ 6. [maskgct](https://github.com/open-mmlab/Amphion/tree/main/models/tts/maskgct)
447
+ 7. [seed-vc](https://github.com/Plachtaa/seed-vc)
448
+
449
+ ## Contributors in Bilibili
450
+ We sincerely thank colleagues from different roles at Bilibili, whose combined efforts made the IndexTTS series possible.
451
+
452
+ ### Core Authors
453
+ - **Wei Deng** - Core author; Initiated the IndexTTS project, led the development of the IndexTTS1 data pipeline, model architecture design and training, as well as iterative optimization of the IndexTTS series of models, focusing on fundamental capability building and performance optimization.
454
+ - **Siyi Zhou** – Core author; in IndexTTS2, led model architecture design and training pipeline optimization, focusing on key features such as multilingual and emotional synthesis.
455
+ - **Jingchen Shu** - Core author; worked on overall architecture design, cross-lingual modeling solutions, and training strategy optimization, driving model iteration.
456
+ - **Xun Zhou** - Core author; worked on cross-lingual data processing and experiments, explored multilingual training strategies, and contributed to audio quality improvement and stability evaluation.
457
+ - **Jinchao Wang** - Core author; worked on model development and deployment, building the inference framework and supporting system integration.
458
+ - **Yiquan Zhou** - Core author; contributed to model experiments and validation, and proposed and implemented text-based emotion control.
459
+ - **Yi He** - Core author; contributed to model experiments and validation.
460
+ - **Lu Wang** – Core author; worked on data processing and model evaluation, supporting model training and performance verification.
461
+
462
+ ### Technical Contributors
463
+ - **Yining Wang** - Supporting contributor; contributed to open-source code implementation and maintenance, supporting feature adaptation and community release.
464
+ - **Yong Wu** - Supporting contributor; worked on data processing and experimental support, ensuring data quality and efficiency for model training and iteration.
465
+ - **Yaqin Huang** – Supporting contributor; contributed to systematic model evaluation and effect tracking, providing feedback to support iterative improvements.
466
+ - **Yunhan Xu** – Supporting contributor; provided guidance in recording and data collection, while also offering feedback from a product and operations perspective to improve usability and practical application.
467
+ - **Yuelang Sun** – Supporting contributor; provided professional support in audio recording and data collection, ensuring high-quality data for model training and evaluation.
468
+ - **Yihuang Liang** - Supporting contributor; worked on systematic model evaluation and project promotion, helping IndexTTS expand its reach and engagement.
469
+
470
+ ### Technical Guidance
471
+ - **Huyang Sun** - Provided strong support for the IndexTTS project, ensuring strategic alignment and resource backing.
472
+ - **Bin Xia** - Contributed to the review, optimization, and follow-up of technical solutions, focusing on ensuring model effectiveness.
473
+
474
+
475
+ ## 📚 Citation
476
+
477
+ 🌟 If you find our work helpful, please leave us a star and cite our paper.
478
+
479
+
480
+ IndexTTS2:
481
+
482
+ ```
483
+ @article{zhou2025indextts2,
484
+ title={IndexTTS2: A Breakthrough in Emotionally Expressive and Duration-Controlled Auto-Regressive Zero-Shot Text-to-Speech},
485
+ author={Siyi Zhou, Yiquan Zhou, Yi He, Xun Zhou, Jinchao Wang, Wei Deng, Jingchen Shu},
486
+ journal={arXiv preprint arXiv:2506.21619},
487
+ year={2025}
488
+ }
489
+ ```
490
+
491
+
492
+ IndexTTS:
493
+
494
+ ```
495
+ @article{deng2025indextts,
496
+ title={IndexTTS: An Industrial-Level Controllable and Efficient Zero-Shot Text-To-Speech System},
497
+ author={Wei Deng, Siyi Zhou, Jingchen Shu, Jinchao Wang, Lu Wang},
498
+ journal={arXiv preprint arXiv:2502.05512},
499
+ year={2025},
500
+ doi={10.48550/arXiv.2502.05512},
501
+ url={https://arxiv.org/abs/2502.05512}
502
+ }
503
+ ```
archive/README_INDEXTTS_1_5.md ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div align="center">
3
+ <img src='assets/index_icon.png' width="250"/>
4
+ </div>
5
+
6
+
7
+ <h2><center>IndexTTS: An Industrial-Level Controllable and Efficient Zero-Shot Text-To-Speech System</h2>
8
+
9
+ <p align="center">
10
+ <a href='https://arxiv.org/abs/2502.05512'><img src='https://img.shields.io/badge/ArXiv-2502.05512-red'></a>
11
+
12
+ ## 👉🏻 IndexTTS 👈🏻
13
+
14
+ [[HuggingFace Demo]](https://huggingface.co/spaces/IndexTeam/IndexTTS) [[ModelScope Demo]](https://modelscope.cn/studios/IndexTeam/IndexTTS-Demo) \
15
+ [[Paper]](https://arxiv.org/abs/2502.05512) [[Demos]](https://index-tts.github.io)
16
+
17
+ **IndexTTS** is a GPT-style text-to-speech (TTS) model mainly based on XTTS and Tortoise. It is capable of correcting the pronunciation of Chinese characters using pinyin and controlling pauses at any position through punctuation marks. We enhanced multiple modules of the system, including the improvement of speaker condition feature representation, and the integration of BigVGAN2 to optimize audio quality. Trained on tens of thousands of hours of data, our system achieves state-of-the-art performance, outperforming current popular TTS systems such as XTTS, CosyVoice2, Fish-Speech, and F5-TTS.
18
+ <span style="font-size:16px;">
19
+ Experience **IndexTTS**: Please contact <u>xuanwu@bilibili.com</u> for more detailed information. </span>
20
+ ### Contact
21
+ QQ群(二群):1048202584 \
22
+ Discord:https://discord.gg/uT32E7KDmy \
23
+ 简历:indexspeech@bilibili.com \
24
+ 欢迎大家来交流讨论!
25
+ ## 📣 Updates
26
+
27
+ - `2025/05/14` 🔥🔥 We release the **IndexTTS-1.5**, Significantly improve the model's stability and its performance in the English language.
28
+ - `2025/03/25` 🔥 We release IndexTTS-1.0 model parameters and inference code.
29
+ - `2025/02/12` 🔥 We submitted our paper on arXiv, and released our demos and test sets.
30
+
31
+ ## 🖥️ Method
32
+
33
+ The overview of IndexTTS is shown as follows.
34
+
35
+ <picture>
36
+ <img src="assets/IndexTTS.png" width="800"/>
37
+ </picture>
38
+
39
+
40
+ The main improvements and contributions are summarized as follows:
41
+ - In Chinese scenarios, we have introduced a character-pinyin hybrid modeling approach. This allows for quick correction of mispronounced characters.
42
+ - **IndexTTS** incorporate a conformer conditioning encoder and a BigVGAN2-based speechcode decoder. This improves training stability, voice timbre similarity, and sound quality.
43
+ - We release all test sets here, including those for polysyllabic words, subjective and objective test sets.
44
+
45
+
46
+
47
+ ## Model Download
48
+ | 🤗**HuggingFace** | **ModelScope** |
49
+ |----------------------------------------------------------|----------------------------------------------------------|
50
+ | [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) |
51
+ | [😁IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) |
52
+
53
+
54
+ ## 📑 Evaluation
55
+
56
+ **Word Error Rate (WER) Results for IndexTTS and Baseline Models on the** [**seed-test**](https://github.com/BytedanceSpeech/seed-tts-eval)
57
+
58
+ | **WER** | **test_zh** | **test_en** | **test_hard** |
59
+ |:----------------------:|:-----------:|:-----------:|:-------------:|
60
+ | **Human** | 1.26 | 2.14 | - |
61
+ | **SeedTTS** | 1.002 | 1.945 | **6.243** |
62
+ | **CosyVoice 2** | 1.45 | 2.57 | 6.83 |
63
+ | **F5TTS** | 1.56 | 1.83 | 8.67 |
64
+ | **FireRedTTS** | 1.51 | 3.82 | 17.45 |
65
+ | **MaskGCT** | 2.27 | 2.62 | 10.27 |
66
+ | **Spark-TTS** | 1.2 | 1.98 | - |
67
+ | **MegaTTS 3** | 1.36 | 1.82 | - |
68
+ | **IndexTTS** | 0.937 | 1.936 | 6.831 |
69
+ | **IndexTTS-1.5** | **0.821** | **1.606** | 6.565 |
70
+
71
+
72
+ **Word Error Rate (WER) Results for IndexTTS and Baseline Models on the other opensource test**
73
+
74
+
75
+ | **Model** | **aishell1_test** | **commonvoice_20_test_zh** | **commonvoice_20_test_en** | **librispeech_test_clean** | **avg** |
76
+ |:---------------:|:-----------------:|:--------------------------:|:--------------------------:|:--------------------------:|:--------:|
77
+ | **Human** | 2.0 | 9.5 | 10.0 | 2.4 | 5.1 |
78
+ | **CosyVoice 2** | 1.8 | 9.1 | 7.3 | 4.9 | 5.9 |
79
+ | **F5TTS** | 3.9 | 11.7 | 5.4 | 7.8 | 8.2 |
80
+ | **Fishspeech** | 2.4 | 11.4 | 8.8 | 8.0 | 8.3 |
81
+ | **FireRedTTS** | 2.2 | 11.0 | 16.3 | 5.7 | 7.7 |
82
+ | **XTTS** | 3.0 | 11.4 | 7.1 | 3.5 | 6.0 |
83
+ | **IndexTTS** | 1.3 | 7.0 | 5.3 | 2.1 | 3.7 |
84
+ | **IndexTTS-1.5** | **1.2** | **6.8** | **3.9** | **1.7** | **3.1** |
85
+
86
+
87
+ **Speaker Similarity (SS) Results for IndexTTS and Baseline Models**
88
+
89
+ | **Model** | **aishell1_test** | **commonvoice_20_test_zh** | **commonvoice_20_test_en** | **librispeech_test_clean** | **avg** |
90
+ |:---------------:|:-----------------:|:--------------------------:|:--------------------------:|:--------------------------:|:---------:|
91
+ | **Human** | 0.846 | 0.809 | 0.820 | 0.858 | 0.836 |
92
+ | **CosyVoice 2** | **0.796** | 0.743 | 0.742 | **0.837** | **0.788** |
93
+ | **F5TTS** | 0.743 | **0.747** | 0.746 | 0.828 | 0.779 |
94
+ | **Fishspeech** | 0.488 | 0.552 | 0.622 | 0.701 | 0.612 |
95
+ | **FireRedTTS** | 0.579 | 0.593 | 0.587 | 0.698 | 0.631 |
96
+ | **XTTS** | 0.573 | 0.586 | 0.648 | 0.761 | 0.663 |
97
+ | **IndexTTS** | 0.744 | 0.742 | **0.758** | 0.823 | 0.776 |
98
+ | **IndexTTS-1.5** | 0.741 | 0.722 | 0.753 | 0.819 | 0.771 |
99
+
100
+
101
+
102
+ **MOS Scores for Zero-Shot Cloned Voice**
103
+
104
+ | **Model** | **Prosody** | **Timbre** | **Quality** | **AVG** |
105
+ |-----------------|:-----------:|:----------:|:-----------:|:---------:|
106
+ | **CosyVoice 2** | 3.67 | 4.05 | 3.73 | 3.81 |
107
+ | **F5TTS** | 3.56 | 3.88 | 3.56 | 3.66 |
108
+ | **Fishspeech** | 3.40 | 3.63 | 3.69 | 3.57 |
109
+ | **FireRedTTS** | 3.79 | 3.72 | 3.60 | 3.70 |
110
+ | **XTTS** | 3.23 | 2.99 | 3.10 | 3.11 |
111
+ | **IndexTTS** | **3.79** | **4.20** | **4.05** | **4.01** |
112
+
113
+
114
+ ## Usage Instructions
115
+ ### Environment Setup
116
+ 1. Download this repository:
117
+ ```bash
118
+ git clone https://github.com/index-tts/index-tts.git
119
+ ```
120
+ 2. Install dependencies:
121
+
122
+ Create a new conda environment and install dependencies:
123
+
124
+ ```bash
125
+ conda create -n index-tts python=3.10
126
+ conda activate index-tts
127
+ apt-get install ffmpeg
128
+ # or use conda to install ffmpeg
129
+ conda install -c conda-forge ffmpeg
130
+ ```
131
+
132
+ Install [PyTorch](https://pytorch.org/get-started/locally/), e.g.:
133
+ ```bash
134
+ pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118
135
+ ```
136
+
137
+ > [!NOTE]
138
+ > If you are using Windows you may encounter [an error](https://github.com/index-tts/index-tts/issues/61) when installing `pynini`:
139
+ `ERROR: Failed building wheel for pynini`
140
+ > In this case, please install `pynini` via `conda`:
141
+ > ```bash
142
+ > # after conda activate index-tts
143
+ > conda install -c conda-forge pynini==2.1.6
144
+ > pip install WeTextProcessing --no-deps
145
+ > ```
146
+
147
+ Install `IndexTTS` as a package:
148
+ ```bash
149
+ cd index-tts
150
+ pip install -e .
151
+ ```
152
+
153
+ 3. Download models:
154
+
155
+ Download by `huggingface-cli`:
156
+
157
+ ```bash
158
+ huggingface-cli download IndexTeam/IndexTTS-1.5 \
159
+ config.yaml bigvgan_discriminator.pth bigvgan_generator.pth bpe.model dvae.pth gpt.pth unigram_12000.vocab \
160
+ --local-dir checkpoints
161
+ ```
162
+
163
+ Recommended for China users. 如果下载速度慢,可以使用镜像:
164
+ ```bash
165
+ export HF_ENDPOINT="https://hf-mirror.com"
166
+ ```
167
+
168
+ Or by `wget`:
169
+
170
+ ```bash
171
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/bigvgan_discriminator.pth -P checkpoints
172
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/bigvgan_generator.pth -P checkpoints
173
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/bpe.model -P checkpoints
174
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/dvae.pth -P checkpoints
175
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/gpt.pth -P checkpoints
176
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/unigram_12000.vocab -P checkpoints
177
+ wget https://huggingface.co/IndexTeam/IndexTTS-1.5/resolve/main/config.yaml -P checkpoints
178
+ ```
179
+
180
+ > [!NOTE]
181
+ > If you prefer to use the `IndexTTS-1.0` model, please replace `IndexTeam/IndexTTS-1.5` with `IndexTeam/IndexTTS` in the above commands.
182
+
183
+
184
+ 4. Run test script:
185
+
186
+
187
+ ```bash
188
+ # Please put your prompt audio in 'test_data' and rename it to 'input.wav'
189
+ python indextts/infer.py
190
+ ```
191
+
192
+ 5. Use as command line tool:
193
+
194
+ ```bash
195
+ # Make sure pytorch has been installed before running this command
196
+ indextts "大家好,我现在正在bilibili 体验 ai 科技,说实话,来之前我绝对想不到!AI技术已经发展到这样匪夷所思的地步了!" \
197
+ --voice reference_voice.wav \
198
+ --model_dir checkpoints \
199
+ --config checkpoints/config.yaml \
200
+ --output output.wav
201
+ ```
202
+
203
+ Use `--help` to see more options.
204
+ ```bash
205
+ indextts --help
206
+ ```
207
+
208
+ #### Web Demo
209
+ ```bash
210
+ pip install -e ".[webui]" --no-build-isolation
211
+ python webui.py
212
+
213
+ # use another model version:
214
+ python webui.py --model_dir IndexTTS-1.5
215
+ ```
216
+
217
+ Open your browser and visit `http://127.0.0.1:7860` to see the demo.
218
+
219
+
220
+ #### Sample Code
221
+ ```python
222
+ from indextts.infer import IndexTTS
223
+ tts = IndexTTS(model_dir="checkpoints",cfg_path="checkpoints/config.yaml")
224
+ voice="reference_voice.wav"
225
+ text="大家好,我现在正在bilibili 体验 ai 科技,说实话,来之前我绝对想不到!AI技术已经发展到这样匪夷所思的地步了!比如说,现在正在说话的其实是B站为我现场复刻的数字分身,简直就是平行宇宙的另一个我了。如果大家也想体验更多深入的AIGC功能,可以访问 bilibili studio,相信我,你们也会吃惊的。"
226
+ tts.infer(voice, text, output_path)
227
+ ```
228
+
229
+ ## Acknowledge
230
+ 1. [tortoise-tts](https://github.com/neonbjb/tortoise-tts)
231
+ 2. [XTTSv2](https://github.com/coqui-ai/TTS)
232
+ 3. [BigVGAN](https://github.com/NVIDIA/BigVGAN)
233
+ 4. [wenet](https://github.com/wenet-e2e/wenet/tree/main)
234
+ 5. [icefall](https://github.com/k2-fsa/icefall)
235
+
236
+ ## 📚 Citation
237
+
238
+ 🌟 If you find our work helpful, please leave us a star and cite our paper.
239
+
240
+ ```
241
+ @article{deng2025indextts,
242
+ title={IndexTTS: An Industrial-Level Controllable and Efficient Zero-Shot Text-To-Speech System},
243
+ author={Wei Deng, Siyi Zhou, Jingchen Shu, Jinchao Wang, Lu Wang},
244
+ journal={arXiv preprint arXiv:2502.05512},
245
+ year={2025}
246
+ }
247
+ ```
assets/IndexTTS.png ADDED

Git LFS Details

  • SHA256: c40c9c0b65922f6525d8aa7350dbd494e4e1ea5c17ba5151f3941f5e3a30e1eb
  • Pointer size: 131 Bytes
  • Size of remote file: 215 kB
assets/IndexTTS2-video-pic.png ADDED

Git LFS Details

  • SHA256: 5a69fc23580ed1f1d0dcd34105f32633756fea153fdfccdfdb27569fa8db4168
  • Pointer size: 131 Bytes
  • Size of remote file: 540 kB
assets/IndexTTS2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3045b3947ce5a61385d1ae7cd7b1ae9c3e171604b53a2f68222f69e51c9dc009
3
+ size 8944379
assets/IndexTTS2.png ADDED
assets/IndexTTS2_banner.png ADDED

Git LFS Details

  • SHA256: 29c8a215fd77be2778b091afe78f70fb235abdbc31c55fc032263797c3f13de6
  • Pointer size: 132 Bytes
  • Size of remote file: 3.07 MB
assets/img.png ADDED
assets/index_icon.png ADDED
checkpoints/config.yaml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dataset:
2
+ bpe_model: bpe.model
3
+ sample_rate: 24000
4
+ squeeze: false
5
+ mel:
6
+ sample_rate: 24000
7
+ n_fft: 1024
8
+ hop_length: 256
9
+ win_length: 1024
10
+ n_mels: 100
11
+ mel_fmin: 0
12
+ normalize: false
13
+
14
+ gpt:
15
+ model_dim: 1280
16
+ max_mel_tokens: 1815
17
+ max_text_tokens: 600
18
+ heads: 20
19
+ use_mel_codes_as_input: true
20
+ mel_length_compression: 1024
21
+ layers: 24
22
+ number_text_tokens: 12000
23
+ number_mel_codes: 8194
24
+ start_mel_token: 8192
25
+ stop_mel_token: 8193
26
+ start_text_token: 0
27
+ stop_text_token: 1
28
+ train_solo_embeddings: false
29
+ condition_type: "conformer_perceiver"
30
+ condition_module:
31
+ output_size: 512
32
+ linear_units: 2048
33
+ attention_heads: 8
34
+ num_blocks: 6
35
+ input_layer: "conv2d2"
36
+ perceiver_mult: 2
37
+ emo_condition_module:
38
+ output_size: 512
39
+ linear_units: 1024
40
+ attention_heads: 4
41
+ num_blocks: 4
42
+ input_layer: "conv2d2"
43
+ perceiver_mult: 2
44
+
45
+ semantic_codec:
46
+ codebook_size: 8192
47
+ hidden_size: 1024
48
+ codebook_dim: 8
49
+ vocos_dim: 384
50
+ vocos_intermediate_dim: 2048
51
+ vocos_num_layers: 12
52
+
53
+ s2mel:
54
+ preprocess_params:
55
+ sr: 22050
56
+ spect_params:
57
+ n_fft: 1024
58
+ win_length: 1024
59
+ hop_length: 256
60
+ n_mels: 80
61
+ fmin: 0
62
+ fmax: "None"
63
+
64
+ dit_type: "DiT"
65
+ reg_loss_type: "l1"
66
+ style_encoder:
67
+ dim: 192
68
+ length_regulator:
69
+ channels: 512
70
+ is_discrete: false
71
+ in_channels: 1024
72
+ content_codebook_size: 2048
73
+ sampling_ratios: [1, 1, 1, 1]
74
+ vector_quantize: false
75
+ n_codebooks: 1
76
+ quantizer_dropout: 0.0
77
+ f0_condition: false
78
+ n_f0_bins: 512
79
+ DiT:
80
+ hidden_dim: 512
81
+ num_heads: 8
82
+ depth: 13
83
+ class_dropout_prob: 0.1
84
+ block_size: 8192
85
+ in_channels: 80
86
+ style_condition: true
87
+ final_layer_type: 'wavenet'
88
+ target: 'mel'
89
+ content_dim: 512
90
+ content_codebook_size: 1024
91
+ content_type: 'discrete'
92
+ f0_condition: false
93
+ n_f0_bins: 512
94
+ content_codebooks: 1
95
+ is_causal: false
96
+ long_skip_connection: true
97
+ zero_prompt_speech_token: false
98
+ time_as_token: false
99
+ style_as_token: false
100
+ uvit_skip_connection: true
101
+ add_resblock_in_transformer: false
102
+ wavenet:
103
+ hidden_dim: 512
104
+ num_layers: 8
105
+ kernel_size: 5
106
+ dilation_rate: 1
107
+ p_dropout: 0.2
108
+ style_condition: true
109
+
110
+ gpt_checkpoint: gpt.pth
111
+ w2v_stat: wav2vec2bert_stats.pt
112
+ s2mel_checkpoint: s2mel.pth
113
+ emo_matrix: thai_feat2.pt
114
+ spk_matrix: thai_feat1.pt
115
+ emo_num: [15, 15, 15, 15, 15]
116
+ qwen_emo_path: qwen0.6bemo4-merge/
117
+ vocoder:
118
+ type: "bigvgan"
119
+ name: "nvidia/bigvgan_v2_22khz_80band_256x"
120
+ version: 2.0
checkpoints/qwen0.6bemo4-merge/Modelfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ollama modelfile auto-generated by llamafactory
2
+
3
+ FROM .
4
+
5
+ TEMPLATE """{{ if .System }}System: {{ .System }}<|endoftext|>
6
+ {{ end }}{{ range .Messages }}{{ if eq .Role "user" }}Human: {{ .Content }}<|endoftext|>
7
+ Assistant:{{ else if eq .Role "assistant" }}{{ .Content }}<|endoftext|>
8
+ {{ end }}{{ end }}"""
9
+
10
+ PARAMETER stop "<|endoftext|>"
11
+ PARAMETER num_ctx 4096
checkpoints/qwen0.6bemo4-merge/added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
checkpoints/qwen0.6bemo4-merge/chat_template.jinja ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% endif %}{% if system_message is defined %}{{ 'System: ' + system_message + '<|endoftext|>' + '
2
+ ' }}{% endif %}{% for message in loop_messages %}{% set content = message['content'] %}{% if message['role'] == 'user' %}{{ 'Human: ' + content + '<|endoftext|>' + '
3
+ Assistant:' }}{% elif message['role'] == 'assistant' %}{{ content + '<|endoftext|>' + '
4
+ ' }}{% endif %}{% endfor %}
checkpoints/qwen0.6bemo4-merge/config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151643,
9
+ "head_dim": 128,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 1024,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "max_position_embeddings": 32768,
15
+ "max_window_layers": 28,
16
+ "model_type": "qwen3",
17
+ "num_attention_heads": 16,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 8,
20
+ "rms_norm_eps": 1e-06,
21
+ "rope_scaling": null,
22
+ "rope_theta": 1000000,
23
+ "sliding_window": null,
24
+ "tie_word_embeddings": true,
25
+ "torch_dtype": "bfloat16",
26
+ "transformers_version": "4.52.1",
27
+ "use_cache": true,
28
+ "use_sliding_window": false,
29
+ "vocab_size": 151936
30
+ }
checkpoints/qwen0.6bemo4-merge/generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "eos_token_id": 151643,
4
+ "max_new_tokens": 2048,
5
+ "transformers_version": "4.52.1"
6
+ }
checkpoints/qwen0.6bemo4-merge/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/qwen0.6bemo4-merge/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11293257a8df593c154a8ecd5fc039f3076de35411e35f06d41b471e136f6641
3
+ size 1192135096
checkpoints/qwen0.6bemo4-merge/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
checkpoints/qwen0.6bemo4-merge/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4
3
+ size 11422654
checkpoints/qwen0.6bemo4-merge/tokenizer_config.json ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<tool_response>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": false
188
+ },
189
+ "151666": {
190
+ "content": "</tool_response>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": false
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ }
213
+ },
214
+ "additional_special_tokens": [
215
+ "<|im_start|>",
216
+ "<|im_end|>",
217
+ "<|object_ref_start|>",
218
+ "<|object_ref_end|>",
219
+ "<|box_start|>",
220
+ "<|box_end|>",
221
+ "<|quad_start|>",
222
+ "<|quad_end|>",
223
+ "<|vision_start|>",
224
+ "<|vision_end|>",
225
+ "<|vision_pad|>",
226
+ "<|image_pad|>",
227
+ "<|video_pad|>"
228
+ ],
229
+ "bos_token": null,
230
+ "clean_up_tokenization_spaces": false,
231
+ "eos_token": "<|endoftext|>",
232
+ "errors": "replace",
233
+ "extra_special_tokens": {},
234
+ "model_max_length": 131072,
235
+ "pad_token": "<|endoftext|>",
236
+ "padding_side": "left",
237
+ "split_special_tokens": false,
238
+ "tokenizer_class": "Qwen2Tokenizer",
239
+ "unk_token": null
240
+ }
checkpoints/qwen0.6bemo4-merge/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/thai_gpt_v5/best_model_step65000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2df3655ad5670714bb06eb3ad5052f2e21c8a7334f8c65f210fab4e7d9828b6
3
+ size 8316255029
checkpoints/thai_gpt_v5/best_model_step66000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7016c41f2986fb8572d263b2091f0db205aacc1a34a9b62dbdf18992e45392a8
3
+ size 8316255029
checkpoints/thai_gpt_v5/best_model_step67000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec7e8d437510fd799e73e38bae04e99456cd3cdd3f9db70c1a3213f75bbae3f0
3
+ size 8316255029
checkpoints/thai_gpt_v5/latest.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d7005f8621ba52370cafa21141ea194f91d7a66276cf9d208fd7be70847b62f
3
+ size 8316226849
checkpoints/thai_gpt_v5/logs/run_20260426_001816/events.out.tfevents.1777137496.DESKTOP-P89J176.29048.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd75f460fc68c502f5e7cdda2238b4a4bb33f3975b2b6b46212a172275dd0cda
3
+ size 8655533
checkpoints/thai_gpt_v5/logs/run_20260426_231721/events.out.tfevents.1777220241.DESKTOP-P89J176.30436.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd90e7ed45682feb5b15dd318cee0893e6ea2dcd36b05c8979bbab7d06162706
3
+ size 422354
checkpoints/thai_gpt_v5/logs/run_20260427_074202/events.out.tfevents.1777250522.DESKTOP-P89J176.13632.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b9de56d3c7e52125cc238d5c861e2a4dc3b70dd9f209b1883f0c755e2ab6ed2
3
+ size 5304496
checkpoints/thai_gpt_v5/model_step65000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77d9e8d152a14fbc8183efa8b6672c5499a66450cbd7a5f6591e84e1fe736c5c
3
+ size 8316247351
checkpoints/thai_gpt_v5/model_step66000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75cceb3f1cb5c84e255f44f81a67bce004b54cb4beaf7b2c5c874891d829be8f
3
+ size 8316247415
checkpoints/thai_gpt_v5/model_step67000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b416d7d51eb314378942f93f875104d38eacebf54446efa3efe7929dea4db440
3
+ size 8316247415
docs/README_zh.md ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div align="center">
3
+ <img src='../assets/index_icon.png' width="250"/>
4
+ </div>
5
+
6
+ <div align="center">
7
+ <a href="README_zh.md" style="font-size: 24px">简体中文</a> |
8
+ <a href="../README.md" style="font-size: 24px">English</a>
9
+ </div>
10
+
11
+ ## 👉🏻 IndexTTS2 👈🏻
12
+
13
+ <center><h3>IndexTTS2:情感表达与时长可控的自回归零样本语音合成突破</h3></center>
14
+
15
+ [![IndexTTS2](../assets/IndexTTS2_banner.png)](../assets/IndexTTS2_banner.png)
16
+
17
+ <div align="center">
18
+ <a href='https://arxiv.org/abs/2506.21619'>
19
+ <img src='https://img.shields.io/badge/ArXiv-2506.21619-red?logo=arxiv'/>
20
+ </a>
21
+ <br/>
22
+ <a href='https://github.com/index-tts/index-tts'>
23
+ <img src='https://img.shields.io/badge/GitHub-Code-orange?logo=github'/>
24
+ </a>
25
+ <a href='https://index-tts.github.io/index-tts2.github.io/'>
26
+ <img src='https://img.shields.io/badge/GitHub-Demo-orange?logo=github'/>
27
+ </a>
28
+ <br/>
29
+ <a href='https://huggingface.co/spaces/IndexTeam/IndexTTS-2-Demo'>
30
+ <img src='https://img.shields.io/badge/HuggingFace-Demo-blue?logo=huggingface'/>
31
+ </a>
32
+ <a href='https://huggingface.co/IndexTeam/IndexTTS-2'>
33
+ <img src='https://img.shields.io/badge/HuggingFace-Model-blue?logo=huggingface' />
34
+ </a>
35
+ <br/>
36
+ <a href='https://modelscope.cn/studios/IndexTeam/IndexTTS-2-Demo'>
37
+ <img src='https://img.shields.io/badge/ModelScope-Demo-purple?logo=modelscope'/>
38
+ </>
39
+ <a href='https://modelscope.cn/models/IndexTeam/IndexTTS-2'>
40
+ <img src='https://img.shields.io/badge/ModelScope-Model-purple?logo=modelscope'/>
41
+ </a>
42
+ </div>
43
+
44
+ ### 摘要
45
+
46
+ 现有自回归大规模文本转语音(TTS)模型在语音自然度方面具有优势,但其逐token生成机制难以精确控制合成语音的时长。这在需要严格视音频同步的应用(如视频配音)中成为显著限制。
47
+
48
+ 本文提出了IndexTTS2,创新性地提出了一种通用且适用于自回归模型的语音时长控制方法。
49
+
50
+ 该方法支持两种生成模式:一种可显式指定生成token数量以精确控制语音时长;另一种则自由自回归生成语音,同时忠实还原输入提示的韵律特征。
51
+
52
+ 此外,IndexTTS2实现了情感表达与说话人身份的解耦,可独立控制音色和情感。在零样本设置下,模型能准确复刻目标音色(来自音色提示),同时完美还原指定的情感语调(来自风格提示)。
53
+
54
+ 为提升高情感表达下的语音清晰度,我们引入GPT潜在表示,并设计了三阶段训练范式,提升生成语音的稳定性。为降低情感控制门槛,我们基于文本描述微调Qwen3,设计了软指令机制,有效引导语音生成所需情感。
55
+
56
+ 多数据集实验结果表明,IndexTTS2在词错误率、说话人相似度和情感保真度方面均超越现有零样本TTS模型。音频样例见:<a href="https://index-tts.github.io/index-tts2.github.io/">IndexTTS2演示页面</a>。
57
+
58
+ **Tips:** 如需更多信息请联系作者。商业合作请联系 <u>indexspeech@bilibili.com</u>。
59
+
60
+ ### IndexTTS2体验
61
+
62
+ <div align="center">
63
+
64
+ **IndexTTS2:语音未来,现已生成**
65
+
66
+ [![IndexTTS2 Demo](../assets/IndexTTS2-video-pic.png)](https://www.bilibili.com/video/BV136a9zqEk5)
67
+
68
+ *点击图片观看IndexTTS2介绍视频*
69
+
70
+ </div>
71
+
72
+ ### 联系方式
73
+
74
+ QQ群:663272642(4群) 1013410623(5群) \
75
+ Discord:https://discord.gg/uT32E7KDmy \
76
+ 邮箱:indexspeech@bilibili.com \
77
+ 欢迎加入我们的社区!🌏 \
78
+ 欢迎大家交流讨论!
79
+
80
+ > [!CAUTION]
81
+ > 感谢大家对bilibili indextts项目的支持与关注!
82
+ > 请注意,目前由核心团队直接维护的**官方渠道仅有**: [https://github.com/index-tts/index-tts](https://github.com/index-tts/index-tts).
83
+ > ***其他任何网站或服务均非官方提供***,我们对其内容及安全性、准确性和及时性不作任何担保。
84
+ > 为了保障您的权益,建议通过上述官方渠道获取bilibili indextts项目的最新进展与更新。
85
+
86
+
87
+ ## 📣 更新日志
88
+
89
+ - `2025/09/08` 🔥🔥🔥 IndexTTS-2全球发布!
90
+ - 首个支持精确合成时长控制的自回归TTS模型,支持可控与非可控模式。<i>本版本暂未开放该功能。</i>
91
+ - 模型实现高度情感表达的语音合成,支持多模态情感控制。
92
+ - `2025/05/14` 🔥🔥 IndexTTS-1.5发布,显著提升模型稳定性及英文表现。
93
+ - `2025/03/25` 🔥 IndexTTS-1.0发布,开放模型权重与推理代码。
94
+ - `2025/02/12` 🔥 论文提交arXiv,发布演示与测试集。
95
+
96
+ ## 🖥️ 神经网络架构
97
+
98
+ IndexTTS2架构总览:
99
+
100
+ <picture>
101
+ <img src="../assets/IndexTTS2.png" width="800"/>
102
+ </picture>
103
+
104
+ 主要创新点:
105
+
106
+ - 提出自回归TTS模型的时长自适应方案。IndexTTS2是首个将精确时长控制与自然时长生成结合的自回归零样本TTS模型,方法可扩展至任意自回归大模型。
107
+ - 情感与说话人特征从提示中解耦,设计特征融合策略,在高情感表达下保持语义流畅与发音清晰,并开发了基于自然语言描述的情感控制工具。
108
+ - 针对高表达性语音数据缺乏,提出高效训练策略,显著提升零样本TTS情感表达至SOTA水平。
109
+ - 代码与预训练权重将公开,促进后续研究与应用。
110
+
111
+ ## 模型下载
112
+
113
+ | **HuggingFace** | **ModelScope** |
114
+ |----------------------------------------------------------|----------------------------------------------------------|
115
+ | [😁 IndexTTS-2](https://huggingface.co/IndexTeam/IndexTTS-2) | [IndexTTS-2](https://modelscope.cn/models/IndexTeam/IndexTTS-2) |
116
+ | [IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) |
117
+ | [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) |
118
+
119
+ ## 使用说明
120
+
121
+ ### ⚙️ 环境配置
122
+
123
+ 1. 请确保已安装 [git](https://git-scm.com/downloads) 和 [git-lfs](https://git-lfs.com/)。
124
+
125
+ 在仓库中启用Git-LFS:
126
+
127
+ ```bash
128
+ git lfs install
129
+ ```
130
+
131
+ 2. 下载代码:
132
+
133
+ ```bash
134
+ git clone https://github.com/index-tts/index-tts.git && cd index-tts
135
+ git lfs pull # 下载大文件
136
+ ```
137
+
138
+ 3. 安装 [uv 包管理器](https://docs.astral.sh/uv/getting-started/installation/)。
139
+ *必须*使用uv保证依赖环境可靠。
140
+
141
+ > [!TIP]
142
+ > **快速安装方法:**
143
+ >
144
+ > uv安装方式多样,详见官网。也可快速安装:
145
+ >
146
+ > ```bash
147
+ > pip install -U uv
148
+ > ```
149
+
150
+ > [!WARNING]
151
+ > 本文档仅支持uv安装。其他工具如conda/pip无法保证依赖正确,可能导致*偶发bug、报错、GPU加速失效*等问题。
152
+ >
153
+ > uv比pip快[115倍](https://github.com/astral-sh/uv/blob/main/BENCHMARKS.md),强烈推荐。
154
+
155
+ 4. 安装依赖:
156
+
157
+ 使用uv安装依赖时,会创建虚拟环境,将所有依赖安装到`.venv`目录:
158
+
159
+ ```bash
160
+ uv sync --all-extras
161
+ ```
162
+
163
+ 如中国大陆地区用户下载缓慢,可选用国内镜像:
164
+
165
+ ```bash
166
+ uv sync --all-extras --default-index "https://mirrors.aliyun.com/pypi/simple"
167
+
168
+ uv sync --all-extras --default-index "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
169
+ ```
170
+
171
+ > [!TIP]
172
+ > **可选功能:**
173
+ >
174
+ > - `--all-extras`:安装全部可选功能。可去除自定义。
175
+ > - `--extra webui`:安装WebUI支持(推荐)。
176
+ > - `--extra deepspeed`:安装DeepSpeed加速。
177
+
178
+ > [!IMPORTANT]
179
+ > **Windows注意:** DeepSpeed在部分Windows环境较难安装,可去除`--all-extras`。
180
+ >
181
+ > **Linux/Windows注意:** 如遇CUDA相关报错,请确保已安装NVIDIA [CUDA Toolkit](https://developer.nvidia.com/cuda-toolkit) 12.8及以上。
182
+
183
+ 5. 下载模型:
184
+
185
+ HuggingFace下载:
186
+
187
+ ```bash
188
+ uv tool install "huggingface-hub[cli,hf_xet]"
189
+
190
+ hf download IndexTeam/IndexTTS-2 --local-dir=checkpoints
191
+ ```
192
+
193
+ ModelScope下载:
194
+
195
+ ```bash
196
+ uv tool install "modelscope"
197
+
198
+ modelscope download --model IndexTeam/IndexTTS-2 --local_dir checkpoints
199
+ ```
200
+
201
+ > [!NOTE]
202
+ > 项目首次运行还会自动下载部分小模型。如网络访问HuggingFace较慢,建议提前设置:
203
+ >
204
+ > ```bash
205
+ > export HF_ENDPOINT="https://hf-mirror.com"
206
+ > ```
207
+
208
+ #### 🖥️ PyTorch GPU 加速检测
209
+
210
+ 可运行脚本检测机器是否有GPU,以及是否安装了GPU版本的PyTorch。(如PyTorch版本不对,可能使用CPU启动,推理会非常慢)
211
+
212
+ ```bash
213
+ uv run tools/gpu_check.py
214
+ ```
215
+
216
+ ### 🔥 IndexTTS2快速体验
217
+
218
+ #### 🌐 Web演示
219
+
220
+ ```bash
221
+ uv run webui.py
222
+ ```
223
+
224
+ 浏览器访问 `http://127.0.0.1:7860` 查看演示。
225
+
226
+ 可通过命令行参数开启FP16推理(降低显存占用)、DeepSpeed加速、CUDA内核编译加速等。可运行以下命令查看所有选项:
227
+
228
+ ```bash
229
+ uv run webui.py -h
230
+ ```
231
+
232
+ 祝使用愉快!
233
+
234
+ #### 📝 Python脚本调用
235
+
236
+ 用`uv run <file.py>`保证程序在uv创建的虚拟环境下运行。部分情况需要指定`PYTHONPATH`。
237
+
238
+ 示例:
239
+
240
+ ```bash
241
+ PYTHONPATH="$PYTHONPATH:." uv run indextts/infer_v2.py
242
+ ```
243
+
244
+ 以下为IndexTTS2脚本调用示例:
245
+
246
+ 1. 单一参考音频(音色克隆):
247
+
248
+ ```python
249
+ from indextts.infer_v2 import IndexTTS2
250
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
251
+ text = "Translate for me, what is a surprise!"
252
+ tts.infer(spk_audio_prompt='examples/voice_01.wav', text=text, output_path="gen.wav", verbose=True)
253
+ ```
254
+
255
+ 2. 指定情感参考音频:
256
+
257
+ ```python
258
+ from indextts.infer_v2 import IndexTTS2
259
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
260
+ text = "酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。"
261
+ tts.infer(spk_audio_prompt='examples/voice_07.wav', text=text, output_path="gen.wav", emo_audio_prompt="examples/emo_sad.wav", verbose=True)
262
+ ```
263
+
264
+ 3. 可调节情感参考音频的权重(`emo_alpha`,范围0.0-1.0,默认1.0):
265
+
266
+ ```python
267
+ from indextts.infer_v2 import IndexTTS2
268
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
269
+ text = "酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。"
270
+ tts.infer(spk_audio_prompt='examples/voice_07.wav', text=text, output_path="gen.wav", emo_audio_prompt="examples/emo_sad.wav", emo_alpha=0.9, verbose=True)
271
+ ```
272
+
273
+ 4. 可直接指定8维情感向量 `[高兴, 愤怒, 悲伤, 害怕, 厌恶, 忧郁, 惊讶, 平静]`,可用`use_random`开启随机情感采样(默认False):
274
+
275
+ > [!NOTE]
276
+ > 开启随机采样会降低音色的还原度。
277
+
278
+ ```python
279
+ from indextts.infer_v2 import IndexTTS2
280
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
281
+ text = "哇塞!这个爆率也太高了!欧皇附体了!"
282
+ tts.infer(spk_audio_prompt='examples/voice_10.wav', text=text, output_path="gen.wav", emo_vector=[0, 0, 0, 0, 0, 0, 0.45, 0], use_random=False, verbose=True)
283
+ ```
284
+
285
+ 5. 可用`use_emo_text`根据文本自动生成情感向量,可用`use_random`开启随机情感采样:
286
+
287
+ ```python
288
+ from indextts.infer_v2 import IndexTTS2
289
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
290
+ text = "快躲起来!是他要来了!他要来抓我们了!"
291
+ tts.infer(spk_audio_prompt='examples/voice_12.wav', text=text, output_path="gen.wav", emo_alpha=0.6, use_emo_text=True, use_random=False, verbose=True)
292
+ ```
293
+
294
+ 6. 可直接指定情感文本描述(`emo_text`),实现文本与情感分离控制:
295
+
296
+ ```python
297
+ from indextts.infer_v2 import IndexTTS2
298
+ tts = IndexTTS2(cfg_path="checkpoints/config.yaml", model_dir="checkpoints", use_fp16=False, use_cuda_kernel=False, use_deepspeed=False)
299
+ text = "快躲起来!是他要来了!他要来抓我们了!"
300
+ emo_text = "你吓死我了!你是鬼吗?"
301
+ tts.infer(spk_audio_prompt='examples/voice_12.wav', text=text, output_path="gen.wav", emo_alpha=0.6, use_emo_text=True, emo_text=emo_text, use_random=False, verbose=True)
302
+ ```
303
+
304
+ > [!TIP]
305
+ > **拼音使用注意事项:**
306
+ >
307
+ > IndexTTS2依然支持中文字符与拼音混合建模。
308
+ > 在使用时,如果需要精确的发音控制,请输入包含特定拼音标注的文本来触发拼音控制功能。
309
+ > 需要注意的是:拼音控制并不是对所有声母韵母(辅音、元音)组合都生效,系统仅保留中文合法拼音的发音。
310
+ > 具体合法情况可参考项目中的`checkpoints/pinyin.vocab`文件。
311
+ >
312
+ > 参考样例:
313
+ > ```
314
+ > 之前你做DE5很好,所以这一次也DEI3做DE2很好才XING2,如果这次目标完成得不错的话,我们就直接打DI1去银行取钱。
315
+ > ```
316
+
317
+ ### 旧版IndexTTS1使用指南
318
+
319
+ 如果需要使用旧的IndexTTS1.5模型,可以import旧模块:
320
+
321
+ ```python
322
+ from indextts.infer import IndexTTS
323
+ tts = IndexTTS(model_dir="checkpoints",cfg_path="checkpoints/config.yaml")
324
+ voice = "examples/voice_07.wav"
325
+ text = "大家好,我现在正在bilibili 体验 ai 科技,说实话,来之前我绝对想不到!AI技术已经发展到这样匪夷所思的地步了!比如说,现在正在说话的其实是B站为我现场复刻的数字分身,简直就是平行宇宙的另一个我了。如果大家也想体验更多深入的AIGC功能,可以访问 bilibili studio,相信我,你们也会吃惊的。"
326
+ tts.infer(voice, text, 'gen.wav')
327
+ ```
328
+
329
+ 详细信息见 [README_INDEXTTS_1_5](archive/README_INDEXTTS_1_5.md),或访问 <a href="https://github.com/index-tts/index-tts/tree/v1.5.0">index-tts:v1.5.0</a>。
330
+
331
+ ## 演示
332
+
333
+ ### IndexTTS2: [[论文]](https://arxiv.org/abs/2506.21619); [[演示]](https://index-tts.github.io/index-tts2.github.io/); [[ModelScope]](https://modelscope.cn/studios/IndexTeam/IndexTTS-2-Demo); [[HuggingFace]](https://huggingface.co/spaces/IndexTeam/IndexTTS-2-Demo)
334
+
335
+ ### IndexTTS1: [[论文]](https://arxiv.org/abs/2502.05512); [[演示]](https://index-tts.github.io/); [[ModelScope]](https://modelscope.cn/studios/IndexTeam/IndexTTS-Demo); [[HuggingFace]](https://huggingface.co/spaces/IndexTeam/IndexTTS)
336
+
337
+ ## 致谢
338
+
339
+ 1. [tortoise-tts](https://github.com/neonbjb/tortoise-tts)
340
+ 2. [XTTSv2](https://github.com/coqui-ai/TTS)
341
+ 3. [BigVGAN](https://github.com/NVIDIA/BigVGAN)
342
+ 4. [wenet](https://github.com/wenet-e2e/wenet/tree/main)
343
+ 5. [icefall](https://github.com/k2-fsa/icefall)
344
+ 6. [maskgct](https://github.com/open-mmlab/Amphion/tree/main/models/tts/maskgct)
345
+ 7. [seed-vc](https://github.com/Plachtaa/seed-vc)
346
+
347
+ ## Bilibili 贡献者名录
348
+ 我们诚挚感谢来自Bilibili的同事们,是大家的共同努力让IndexTTS系列得以实现。
349
+
350
+ ### 核心作者
351
+ - **Siyi Zhou** – 核心作者;在IndexTTS2中主导模型架构设计与训练流程优化,重点推动多语言、多情感合成等关键功能。
352
+ - **Wei Deng** – 核心作者;在IndexTTS1中主导模型架构设计与训练流程,负责基础能力建设与性能优化。
353
+ - **Jingchen Shu** – 核心作者;负责整体架构设计、跨语种建模方案与训练策略优化,推动模型迭代。
354
+ - **Xun Zhou** – 核心作者;负责跨语言数据处理与实验,探索多语种训练策略,并在音质提升与稳定性评估方面作出贡献。
355
+ - **Jinchao Wang** – 核心作者;负责模型开发与部署,构建推理框架并支持系统落地。
356
+ - **Yiquan Zhou** – 核心作者;参与模型实验与验证,并提出并实现了基于文本的情感控制。
357
+ - **Yi He** – 核心作者;参与模型实验与验证。
358
+ - **Lu Wang** – 核心作者;负责数据处理与模型评测,支持模型训练与性能验证。
359
+
360
+ ### 技术贡献者
361
+ - **Yining Wang** – 技术贡献者;负责开源代码的实现与维护,支持功能适配与社区发布。
362
+ - **Yong Wu** – 技术贡献者;参与数据处理与实验支持,保障模型训练的数据质量与迭代效率。
363
+ - **Yaqin Huang** – 技术贡献者;参与系统性模型评估与效果跟进,提供反馈以支持迭代优化。
364
+ - **Yunhan Xu** – 技术贡献者;在录音与数据采集方面提供指导,并从产品与运营角度提出改进建议,提升模型的易用性与实际应用效果。
365
+ - **Yuelang Sun** – 技术贡献者;在音频录制与数据采集方面提供专业支持,保障模型训练与评测所需的高质量数据。
366
+ - **Yihuang Liang** – 技术贡献者;参与系统性模型评估与项目推广,帮助IndexTTS项目扩大影响力并提升用户参与度。
367
+
368
+ ### 技术指导
369
+ - **Huyang Sun** – 对IndexTTS项目给予了大力支持,确保了项目的战略方向与资源保障。
370
+ - **Bin Xia** – 参与技术方案的评审、优化与跟进,重点关注模型效果的保障。
371
+
372
+ ## 📚 论文引用
373
+
374
+ 🌟 如果本项目对您有帮助,请为我们点star并引用论文。
375
+
376
+ IndexTTS2:
377
+
378
+ ```
379
+ @article{zhou2025indextts2,
380
+ title={IndexTTS2: A Breakthrough in Emotionally Expressive and Duration-Controlled Auto-Regressive Zero-Shot Text-to-Speech},
381
+ author={Siyi Zhou, Yiquan Zhou, Yi He, Xun Zhou, Jinchao Wang, Wei Deng, Jingchen Shu},
382
+ journal={arXiv preprint arXiv:2506.21619},
383
+ year={2025}
384
+ }
385
+ ```
386
+
387
+ IndexTTS:
388
+
389
+ ```
390
+ @article{deng2025indextts,
391
+ title={IndexTTS: An Industrial-Level Controllable and Efficient Zero-Shot Text-To-Speech System},
392
+ author={Wei Deng, Siyi Zhou, Jingchen Shu, Jinchao Wang, Lu Wang},
393
+ journal={arXiv preprint arXiv:2502.05512},
394
+ year={2025},
395
+ doi={10.48550/arXiv.2502.05512},
396
+ url={https://arxiv.org/abs/2502.05512}
397
+ }
398
+ ```
399
+
examples/cases.jsonl ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"prompt_audio":"voice_01.wav","text":"Translate for me, what is a surprise!","emo_mode":0}
2
+ {"prompt_audio":"voice_02.wav","text":"The palace is strict, no false rumors, Lady Qi!","emo_mode":0}
3
+ {"prompt_audio":"voice_03.wav","text":"这个呀,就是我们精心制作准备的纪念品,大家可以看到这个色泽和这个材质啊,哎呀多么的光彩照人。","emo_mode":0}
4
+ {"prompt_audio":"voice_04.wav","text":"你就需要我这种专业人士的帮助,就像手无缚鸡之力的人进入雪山狩猎,一定需要最老练的猎人指导。","emo_mode":0}
5
+ {"prompt_audio":"voice_05.wav","text":"在真正的日本剑道中,格斗过程极其短暂,常常短至半秒,最长也不超过两秒,利剑相击的转瞬间,已有一方倒在血泊中。但在这电光石火的对决之前,双方都要以一个石雕般凝固的姿势站定,长时间的逼视对方,这一过程可能长达十分钟!","emo_mode":0}
6
+ {"prompt_audio":"voice_06.wav","text":"今天呢,咱们开一部新书,叫《赛博朋克二零七七》。这词儿我听着都新鲜。这赛博朋克啊,简单理解就是“高科技,低生活”。这一听,我就明白了,于老师就爱用那高科技的东西,手机都得拿脚纹开,大冬天为了解锁脱得一丝不挂,冻得跟王八蛋似的。","emo_mode":0}
7
+ {"prompt_audio":"voice_07.wav","emo_audio":"emo_sad.wav","emo_weight":0.65,"emo_mode":1,"text":"酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。"}
8
+ {"prompt_audio":"voice_08.wav","emo_audio":"emo_hate.wav","emo_weight":0.65,"emo_mode":1,"text":"你看看你,对我还有没有一点父子之间的信任了。"}
9
+ {"prompt_audio":"voice_09.wav","emo_weight": 0.8,"emo_mode":2,"emo_vec_3":0.8,"text":"对不起嘛!我的记性真的不太好,但是和你在一起的事情,我都会努力记住的~"}
10
+ {"prompt_audio":"voice_10.wav","emo_weight": 0.8,"emo_mode":2,"emo_vec_7":1.0,"text":"哇塞!这个爆率也太高了!欧皇附体了!"}
11
+ {"prompt_audio":"voice_11.wav","emo_mode":3,"emo_text":"极度悲伤","text":"这些年的时光终究是错付了... "}
12
+ {"prompt_audio":"voice_12.wav","emo_mode":3,"emo_text":"You scared me to death! What are you, a ghost?","text":"快躲起来!是他要来了!他要来抓我们了!"}
examples/emo_hate.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89e6e7eee1a28303776e9cf43971e9505529bd0e669f5fcf47f4d1370f9187c4
3
+ size 145368
examples/emo_sad.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7d3e5bf2b7bca6458f9e6d7a5ce073c41eb4418895e7df2f994e5a0c96c064a
3
+ size 842016
examples/voice_01.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e33e6ee0107a1dd58e1d66dd90c13df3d55a8683047cc3d7ea206dad84ed3fc8
3
+ size 478050
examples/voice_02.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fe2dd1dbd54ef85a073fbc4c8fc0198f8d4523cc3320a600de0e347a3d8b491
3
+ size 574074
examples/voice_03.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50e8b632efd794418919e2d33c8c2aab9189a57f4d21ef55020413be9f2b292a
3
+ size 616814
examples/voice_04.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a3d2536245f45fd5e1eef046dd768ae7b72a0dba3ec3f370f145862fe64b3b2
3
+ size 681084
extend_bpe.bat ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ uv run tools/tokenizer/extend_bpe.py ^
2
+ --base-model checkpoints/bpe.model ^
3
+ --manifests dataset/thaitts_emilia_dataset/forbpe.jsonl ^
4
+ --output-model checkpoints/thai3normalbpe.model ^
5
+ --target-size 36000 ^
6
+ --character-coverage 1.0 ^
7
+ --model-type bpe
indextts/BigVGAN/ECAPA_TDNN.py ADDED
@@ -0,0 +1,656 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A popular speaker recognition and diarization model.
2
+
3
+ Authors
4
+ * Hwidong Na 2020
5
+ """
6
+
7
+ import torch # noqa: F401
8
+ import torch.nn as nn
9
+ import torch.nn.functional as F
10
+
11
+ from indextts.BigVGAN.nnet.CNN import Conv1d as _Conv1d
12
+ from indextts.BigVGAN.nnet.linear import Linear
13
+ from indextts.BigVGAN.nnet.normalization import BatchNorm1d as _BatchNorm1d
14
+
15
+
16
+ def length_to_mask(length, max_len=None, dtype=None, device=None):
17
+ """Creates a binary mask for each sequence.
18
+
19
+ Reference: https://discuss.pytorch.org/t/how-to-generate-variable-length-mask/23397/3
20
+
21
+ Arguments
22
+ ---------
23
+ length : torch.LongTensor
24
+ Containing the length of each sequence in the batch. Must be 1D.
25
+ max_len : int
26
+ Max length for the mask, also the size of the second dimension.
27
+ dtype : torch.dtype, default: None
28
+ The dtype of the generated mask.
29
+ device: torch.device, default: None
30
+ The device to put the mask variable.
31
+
32
+ Returns
33
+ -------
34
+ mask : tensor
35
+ The binary mask.
36
+
37
+ Example
38
+ -------
39
+ >>> length=torch.Tensor([1,2,3])
40
+ >>> mask=length_to_mask(length)
41
+ >>> mask
42
+ tensor([[1., 0., 0.],
43
+ [1., 1., 0.],
44
+ [1., 1., 1.]])
45
+ """
46
+ assert len(length.shape) == 1
47
+
48
+ if max_len is None:
49
+ max_len = length.max().long().item() # using arange to generate mask
50
+ mask = torch.arange(
51
+ max_len, device=length.device, dtype=length.dtype
52
+ ).expand(len(length), max_len) < length.unsqueeze(1)
53
+
54
+ if dtype is None:
55
+ dtype = length.dtype
56
+
57
+ if device is None:
58
+ device = length.device
59
+
60
+ mask = torch.as_tensor(mask, dtype=dtype, device=device)
61
+ return mask
62
+
63
+
64
+ # Skip transpose as much as possible for efficiency
65
+ class Conv1d(_Conv1d):
66
+ """1D convolution. Skip transpose is used to improve efficiency."""
67
+
68
+ def __init__(self, *args, **kwargs):
69
+ super().__init__(skip_transpose=True, *args, **kwargs)
70
+
71
+
72
+ class BatchNorm1d(_BatchNorm1d):
73
+ """1D batch normalization. Skip transpose is used to improve efficiency."""
74
+
75
+ def __init__(self, *args, **kwargs):
76
+ super().__init__(skip_transpose=True, *args, **kwargs)
77
+
78
+
79
+ class TDNNBlock(nn.Module):
80
+ """An implementation of TDNN.
81
+
82
+ Arguments
83
+ ---------
84
+ in_channels : int
85
+ Number of input channels.
86
+ out_channels : int
87
+ The number of output channels.
88
+ kernel_size : int
89
+ The kernel size of the TDNN blocks.
90
+ dilation : int
91
+ The dilation of the TDNN block.
92
+ activation : torch class
93
+ A class for constructing the activation layers.
94
+ groups : int
95
+ The groups size of the TDNN blocks.
96
+
97
+ Example
98
+ -------
99
+ >>> inp_tensor = torch.rand([8, 120, 64]).transpose(1, 2)
100
+ >>> layer = TDNNBlock(64, 64, kernel_size=3, dilation=1)
101
+ >>> out_tensor = layer(inp_tensor).transpose(1, 2)
102
+ >>> out_tensor.shape
103
+ torch.Size([8, 120, 64])
104
+ """
105
+
106
+ def __init__(
107
+ self,
108
+ in_channels,
109
+ out_channels,
110
+ kernel_size,
111
+ dilation,
112
+ activation=nn.ReLU,
113
+ groups=1,
114
+ ):
115
+ super().__init__()
116
+ self.conv = Conv1d(
117
+ in_channels=in_channels,
118
+ out_channels=out_channels,
119
+ kernel_size=kernel_size,
120
+ dilation=dilation,
121
+ groups=groups,
122
+ )
123
+ self.activation = activation()
124
+ self.norm = BatchNorm1d(input_size=out_channels)
125
+
126
+ def forward(self, x):
127
+ """Processes the input tensor x and returns an output tensor."""
128
+ return self.norm(self.activation(self.conv(x)))
129
+
130
+
131
+ class Res2NetBlock(torch.nn.Module):
132
+ """An implementation of Res2NetBlock w/ dilation.
133
+
134
+ Arguments
135
+ ---------
136
+ in_channels : int
137
+ The number of channels expected in the input.
138
+ out_channels : int
139
+ The number of output channels.
140
+ scale : int
141
+ The scale of the Res2Net block.
142
+ kernel_size: int
143
+ The kernel size of the Res2Net block.
144
+ dilation : int
145
+ The dilation of the Res2Net block.
146
+
147
+ Example
148
+ -------
149
+ >>> inp_tensor = torch.rand([8, 120, 64]).transpose(1, 2)
150
+ >>> layer = Res2NetBlock(64, 64, scale=4, dilation=3)
151
+ >>> out_tensor = layer(inp_tensor).transpose(1, 2)
152
+ >>> out_tensor.shape
153
+ torch.Size([8, 120, 64])
154
+ """
155
+
156
+ def __init__(
157
+ self, in_channels, out_channels, scale=8, kernel_size=3, dilation=1
158
+ ):
159
+ super().__init__()
160
+ assert in_channels % scale == 0
161
+ assert out_channels % scale == 0
162
+
163
+ in_channel = in_channels // scale
164
+ hidden_channel = out_channels // scale
165
+
166
+ self.blocks = nn.ModuleList(
167
+ [
168
+ TDNNBlock(
169
+ in_channel,
170
+ hidden_channel,
171
+ kernel_size=kernel_size,
172
+ dilation=dilation,
173
+ )
174
+ for i in range(scale - 1)
175
+ ]
176
+ )
177
+ self.scale = scale
178
+
179
+ def forward(self, x):
180
+ """Processes the input tensor x and returns an output tensor."""
181
+ y = []
182
+ for i, x_i in enumerate(torch.chunk(x, self.scale, dim=1)):
183
+ if i == 0:
184
+ y_i = x_i
185
+ elif i == 1:
186
+ y_i = self.blocks[i - 1](x_i)
187
+ else:
188
+ y_i = self.blocks[i - 1](x_i + y_i)
189
+ y.append(y_i)
190
+ y = torch.cat(y, dim=1)
191
+ return y
192
+
193
+
194
+ class SEBlock(nn.Module):
195
+ """An implementation of squeeze-and-excitation block.
196
+
197
+ Arguments
198
+ ---------
199
+ in_channels : int
200
+ The number of input channels.
201
+ se_channels : int
202
+ The number of output channels after squeeze.
203
+ out_channels : int
204
+ The number of output channels.
205
+
206
+ Example
207
+ -------
208
+ >>> inp_tensor = torch.rand([8, 120, 64]).transpose(1, 2)
209
+ >>> se_layer = SEBlock(64, 16, 64)
210
+ >>> lengths = torch.rand((8,))
211
+ >>> out_tensor = se_layer(inp_tensor, lengths).transpose(1, 2)
212
+ >>> out_tensor.shape
213
+ torch.Size([8, 120, 64])
214
+ """
215
+
216
+ def __init__(self, in_channels, se_channels, out_channels):
217
+ super().__init__()
218
+
219
+ self.conv1 = Conv1d(
220
+ in_channels=in_channels, out_channels=se_channels, kernel_size=1
221
+ )
222
+ self.relu = torch.nn.ReLU(inplace=True)
223
+ self.conv2 = Conv1d(
224
+ in_channels=se_channels, out_channels=out_channels, kernel_size=1
225
+ )
226
+ self.sigmoid = torch.nn.Sigmoid()
227
+
228
+ def forward(self, x, lengths=None):
229
+ """Processes the input tensor x and returns an output tensor."""
230
+ L = x.shape[-1]
231
+ if lengths is not None:
232
+ mask = length_to_mask(lengths * L, max_len=L, device=x.device)
233
+ mask = mask.unsqueeze(1)
234
+ total = mask.sum(dim=2, keepdim=True)
235
+ s = (x * mask).sum(dim=2, keepdim=True) / total
236
+ else:
237
+ s = x.mean(dim=2, keepdim=True)
238
+
239
+ s = self.relu(self.conv1(s))
240
+ s = self.sigmoid(self.conv2(s))
241
+
242
+ return s * x
243
+
244
+
245
+ class AttentiveStatisticsPooling(nn.Module):
246
+ """This class implements an attentive statistic pooling layer for each channel.
247
+ It returns the concatenated mean and std of the input tensor.
248
+
249
+ Arguments
250
+ ---------
251
+ channels: int
252
+ The number of input channels.
253
+ attention_channels: int
254
+ The number of attention channels.
255
+ global_context: bool
256
+ Whether to use global context.
257
+
258
+ Example
259
+ -------
260
+ >>> inp_tensor = torch.rand([8, 120, 64]).transpose(1, 2)
261
+ >>> asp_layer = AttentiveStatisticsPooling(64)
262
+ >>> lengths = torch.rand((8,))
263
+ >>> out_tensor = asp_layer(inp_tensor, lengths).transpose(1, 2)
264
+ >>> out_tensor.shape
265
+ torch.Size([8, 1, 128])
266
+ """
267
+
268
+ def __init__(self, channels, attention_channels=128, global_context=True):
269
+ super().__init__()
270
+
271
+ self.eps = 1e-12
272
+ self.global_context = global_context
273
+ if global_context:
274
+ self.tdnn = TDNNBlock(channels * 3, attention_channels, 1, 1)
275
+ else:
276
+ self.tdnn = TDNNBlock(channels, attention_channels, 1, 1)
277
+ self.tanh = nn.Tanh()
278
+ self.conv = Conv1d(
279
+ in_channels=attention_channels, out_channels=channels, kernel_size=1
280
+ )
281
+
282
+ def forward(self, x, lengths=None):
283
+ """Calculates mean and std for a batch (input tensor).
284
+
285
+ Arguments
286
+ ---------
287
+ x : torch.Tensor
288
+ Tensor of shape [N, C, L].
289
+ lengths : torch.Tensor
290
+ The corresponding relative lengths of the inputs.
291
+
292
+ Returns
293
+ -------
294
+ pooled_stats : torch.Tensor
295
+ mean and std of batch
296
+ """
297
+ L = x.shape[-1]
298
+
299
+ def _compute_statistics(x, m, dim=2, eps=self.eps):
300
+ mean = (m * x).sum(dim)
301
+ std = torch.sqrt(
302
+ (m * (x - mean.unsqueeze(dim)).pow(2)).sum(dim).clamp(eps)
303
+ )
304
+ return mean, std
305
+
306
+ if lengths is None:
307
+ lengths = torch.ones(x.shape[0], device=x.device)
308
+
309
+ # Make binary mask of shape [N, 1, L]
310
+ mask = length_to_mask(lengths * L, max_len=L, device=x.device)
311
+ mask = mask.unsqueeze(1)
312
+
313
+ # Expand the temporal context of the pooling layer by allowing the
314
+ # self-attention to look at global properties of the utterance.
315
+ if self.global_context:
316
+ # torch.std is unstable for backward computation
317
+ # https://github.com/pytorch/pytorch/issues/4320
318
+ total = mask.sum(dim=2, keepdim=True).float()
319
+ mean, std = _compute_statistics(x, mask / total)
320
+ mean = mean.unsqueeze(2).repeat(1, 1, L)
321
+ std = std.unsqueeze(2).repeat(1, 1, L)
322
+ attn = torch.cat([x, mean, std], dim=1)
323
+ else:
324
+ attn = x
325
+
326
+ # Apply layers
327
+ attn = self.conv(self.tanh(self.tdnn(attn)))
328
+
329
+ # Filter out zero-paddings
330
+ attn = attn.masked_fill(mask == 0, float("-inf"))
331
+
332
+ attn = F.softmax(attn, dim=2)
333
+ mean, std = _compute_statistics(x, attn)
334
+ # Append mean and std of the batch
335
+ pooled_stats = torch.cat((mean, std), dim=1)
336
+ pooled_stats = pooled_stats.unsqueeze(2)
337
+
338
+ return pooled_stats
339
+
340
+
341
+ class SERes2NetBlock(nn.Module):
342
+ """An implementation of building block in ECAPA-TDNN, i.e.,
343
+ TDNN-Res2Net-TDNN-SEBlock.
344
+
345
+ Arguments
346
+ ---------
347
+ in_channels: int
348
+ Expected size of input channels.
349
+ out_channels: int
350
+ The number of output channels.
351
+ res2net_scale: int
352
+ The scale of the Res2Net block.
353
+ se_channels : int
354
+ The number of output channels after squeeze.
355
+ kernel_size: int
356
+ The kernel size of the TDNN blocks.
357
+ dilation: int
358
+ The dilation of the Res2Net block.
359
+ activation : torch class
360
+ A class for constructing the activation layers.
361
+ groups: int
362
+ Number of blocked connections from input channels to output channels.
363
+
364
+ Example
365
+ -------
366
+ >>> x = torch.rand(8, 120, 64).transpose(1, 2)
367
+ >>> conv = SERes2NetBlock(64, 64, res2net_scale=4)
368
+ >>> out = conv(x).transpose(1, 2)
369
+ >>> out.shape
370
+ torch.Size([8, 120, 64])
371
+ """
372
+
373
+ def __init__(
374
+ self,
375
+ in_channels,
376
+ out_channels,
377
+ res2net_scale=8,
378
+ se_channels=128,
379
+ kernel_size=1,
380
+ dilation=1,
381
+ activation=torch.nn.ReLU,
382
+ groups=1,
383
+ ):
384
+ super().__init__()
385
+ self.out_channels = out_channels
386
+ self.tdnn1 = TDNNBlock(
387
+ in_channels,
388
+ out_channels,
389
+ kernel_size=1,
390
+ dilation=1,
391
+ activation=activation,
392
+ groups=groups,
393
+ )
394
+ self.res2net_block = Res2NetBlock(
395
+ out_channels, out_channels, res2net_scale, kernel_size, dilation
396
+ )
397
+ self.tdnn2 = TDNNBlock(
398
+ out_channels,
399
+ out_channels,
400
+ kernel_size=1,
401
+ dilation=1,
402
+ activation=activation,
403
+ groups=groups,
404
+ )
405
+ self.se_block = SEBlock(out_channels, se_channels, out_channels)
406
+
407
+ self.shortcut = None
408
+ if in_channels != out_channels:
409
+ self.shortcut = Conv1d(
410
+ in_channels=in_channels,
411
+ out_channels=out_channels,
412
+ kernel_size=1,
413
+ )
414
+
415
+ def forward(self, x, lengths=None):
416
+ """Processes the input tensor x and returns an output tensor."""
417
+ residual = x
418
+ if self.shortcut:
419
+ residual = self.shortcut(x)
420
+
421
+ x = self.tdnn1(x)
422
+ x = self.res2net_block(x)
423
+ x = self.tdnn2(x)
424
+ x = self.se_block(x, lengths)
425
+
426
+ return x + residual
427
+
428
+
429
+ class ECAPA_TDNN(torch.nn.Module):
430
+ """An implementation of the speaker embedding model in a paper.
431
+ "ECAPA-TDNN: Emphasized Channel Attention, Propagation and Aggregation in
432
+ TDNN Based Speaker Verification" (https://arxiv.org/abs/2005.07143).
433
+
434
+ Arguments
435
+ ---------
436
+ input_size : int
437
+ Expected size of the input dimension.
438
+ device : str
439
+ Device used, e.g., "cpu" or "cuda".
440
+ lin_neurons : int
441
+ Number of neurons in linear layers.
442
+ activation : torch class
443
+ A class for constructing the activation layers.
444
+ channels : list of ints
445
+ Output channels for TDNN/SERes2Net layer.
446
+ kernel_sizes : list of ints
447
+ List of kernel sizes for each layer.
448
+ dilations : list of ints
449
+ List of dilations for kernels in each layer.
450
+ attention_channels: int
451
+ The number of attention channels.
452
+ res2net_scale : int
453
+ The scale of the Res2Net block.
454
+ se_channels : int
455
+ The number of output channels after squeeze.
456
+ global_context: bool
457
+ Whether to use global context.
458
+ groups : list of ints
459
+ List of groups for kernels in each layer.
460
+
461
+ Example
462
+ -------
463
+ >>> input_feats = torch.rand([5, 120, 80])
464
+ >>> compute_embedding = ECAPA_TDNN(80, lin_neurons=192)
465
+ >>> outputs = compute_embedding(input_feats)
466
+ >>> outputs.shape
467
+ torch.Size([5, 1, 192])
468
+ """
469
+
470
+ def __init__(
471
+ self,
472
+ input_size,
473
+ device="cpu",
474
+ lin_neurons=192,
475
+ activation=torch.nn.ReLU,
476
+ channels=[512, 512, 512, 512, 1536],
477
+ kernel_sizes=[5, 3, 3, 3, 1],
478
+ dilations=[1, 2, 3, 4, 1],
479
+ attention_channels=128,
480
+ res2net_scale=8,
481
+ se_channels=128,
482
+ global_context=True,
483
+ groups=[1, 1, 1, 1, 1],
484
+ ):
485
+ super().__init__()
486
+ assert len(channels) == len(kernel_sizes)
487
+ assert len(channels) == len(dilations)
488
+ self.channels = channels
489
+ self.blocks = nn.ModuleList()
490
+
491
+ # The initial TDNN layer
492
+ self.blocks.append(
493
+ TDNNBlock(
494
+ input_size,
495
+ channels[0],
496
+ kernel_sizes[0],
497
+ dilations[0],
498
+ activation,
499
+ groups[0],
500
+ )
501
+ )
502
+
503
+ # SE-Res2Net layers
504
+ for i in range(1, len(channels) - 1):
505
+ self.blocks.append(
506
+ SERes2NetBlock(
507
+ channels[i - 1],
508
+ channels[i],
509
+ res2net_scale=res2net_scale,
510
+ se_channels=se_channels,
511
+ kernel_size=kernel_sizes[i],
512
+ dilation=dilations[i],
513
+ activation=activation,
514
+ groups=groups[i],
515
+ )
516
+ )
517
+
518
+ # Multi-layer feature aggregation
519
+ self.mfa = TDNNBlock(
520
+ channels[-2] * (len(channels) - 2),
521
+ channels[-1],
522
+ kernel_sizes[-1],
523
+ dilations[-1],
524
+ activation,
525
+ groups=groups[-1],
526
+ )
527
+
528
+ # Attentive Statistical Pooling
529
+ self.asp = AttentiveStatisticsPooling(
530
+ channels[-1],
531
+ attention_channels=attention_channels,
532
+ global_context=global_context,
533
+ )
534
+ self.asp_bn = BatchNorm1d(input_size=channels[-1] * 2)
535
+
536
+ # Final linear transformation
537
+ self.fc = Conv1d(
538
+ in_channels=channels[-1] * 2,
539
+ out_channels=lin_neurons,
540
+ kernel_size=1,
541
+ )
542
+
543
+ def forward(self, x, lengths=None):
544
+ """Returns the embedding vector.
545
+
546
+ Arguments
547
+ ---------
548
+ x : torch.Tensor
549
+ Tensor of shape (batch, time, channel).
550
+ lengths : torch.Tensor
551
+ Corresponding relative lengths of inputs.
552
+
553
+ Returns
554
+ -------
555
+ x : torch.Tensor
556
+ Embedding vector.
557
+ """
558
+ # Minimize transpose for efficiency
559
+ x = x.transpose(1, 2)
560
+
561
+ xl = []
562
+ for layer in self.blocks:
563
+ try:
564
+ x = layer(x, lengths=lengths)
565
+ except TypeError:
566
+ x = layer(x)
567
+ xl.append(x)
568
+
569
+ # Multi-layer feature aggregation
570
+ x = torch.cat(xl[1:], dim=1)
571
+ x = self.mfa(x)
572
+
573
+ # Attentive Statistical Pooling
574
+ x = self.asp(x, lengths=lengths)
575
+ x = self.asp_bn(x)
576
+
577
+ # Final linear transformation
578
+ x = self.fc(x)
579
+
580
+ x = x.transpose(1, 2)
581
+ return x
582
+
583
+
584
+ class Classifier(torch.nn.Module):
585
+ """This class implements the cosine similarity on the top of features.
586
+
587
+ Arguments
588
+ ---------
589
+ input_size : int
590
+ Expected size of input dimension.
591
+ device : str
592
+ Device used, e.g., "cpu" or "cuda".
593
+ lin_blocks : int
594
+ Number of linear layers.
595
+ lin_neurons : int
596
+ Number of neurons in linear layers.
597
+ out_neurons : int
598
+ Number of classes.
599
+
600
+ Example
601
+ -------
602
+ >>> classify = Classifier(input_size=2, lin_neurons=2, out_neurons=2)
603
+ >>> outputs = torch.tensor([ [1., -1.], [-9., 1.], [0.9, 0.1], [0.1, 0.9] ])
604
+ >>> outputs = outputs.unsqueeze(1)
605
+ >>> cos = classify(outputs)
606
+ >>> (cos < -1.0).long().sum()
607
+ tensor(0)
608
+ >>> (cos > 1.0).long().sum()
609
+ tensor(0)
610
+ """
611
+
612
+ def __init__(
613
+ self,
614
+ input_size,
615
+ device="cpu",
616
+ lin_blocks=0,
617
+ lin_neurons=192,
618
+ out_neurons=1211,
619
+ ):
620
+ super().__init__()
621
+ self.blocks = nn.ModuleList()
622
+
623
+ for block_index in range(lin_blocks):
624
+ self.blocks.extend(
625
+ [
626
+ _BatchNorm1d(input_size=input_size),
627
+ Linear(input_size=input_size, n_neurons=lin_neurons),
628
+ ]
629
+ )
630
+ input_size = lin_neurons
631
+
632
+ # Final Layer
633
+ self.weight = nn.Parameter(
634
+ torch.FloatTensor(out_neurons, input_size, device=device)
635
+ )
636
+ nn.init.xavier_uniform_(self.weight)
637
+
638
+ def forward(self, x):
639
+ """Returns the output probabilities over speakers.
640
+
641
+ Arguments
642
+ ---------
643
+ x : torch.Tensor
644
+ Torch tensor.
645
+
646
+ Returns
647
+ -------
648
+ out : torch.Tensor
649
+ Output probabilities over speakers.
650
+ """
651
+ for layer in self.blocks:
652
+ x = layer(x)
653
+
654
+ # Need to be normalized
655
+ x = F.linear(F.normalize(x.squeeze(1)), F.normalize(self.weight))
656
+ return x.unsqueeze(1)