92 Commits

Author SHA1 Message Date
Yrom
6deed97efe
feat(indextts): add glossary support for custom term pronunciations 2025-11-20 11:25:08 +08:00
Yrom
82a5b9004a
feat(front.py): add regex pattern for technical terms 2025-11-19 16:49:22 +08:00
Vanka0051
a963ca3d0b
Merge branch 'main' into perf/gumbel_softmax_sampler 2025-11-07 15:32:22 +08:00
Vanka0051
44b5ffcb5d
Merge pull request #536 from storyicon/support_batch
feat(accel): add batch support
2025-11-07 15:29:53 +08:00
PAN
a3b884ff6f feat: gumbel_softmax_sampler
Signed-off-by: PAN <1162953505@qq.com>
2025-11-06 13:12:11 +08:00
storyicon
3c360273da feat: add batch support
Signed-off-by: storyicon <storyicon@foxmail.com>
2025-11-06 05:00:28 +00:00
Vanka0051
5d67f6271b
Merge branch 'main' into gpt2_accel 2025-10-30 16:14:34 +08:00
storyicon
c1ef4148af feat: achieve inference acceleration for the gpt2 stage
Signed-off-by: storyicon <storyicon@foxmail.com>
2025-10-24 08:15:00 +00:00
storyicon
31e7e855e2 feat: optimize s2mel stage
Signed-off-by: storyicon <storyicon@foxmail.com>
2025-10-24 07:30:20 +00:00
Yt Zhong
750d9d9d15 fix: Empty generator -> IndexError problem on non-streaming infer() 2025-10-01 03:25:28 +08:00
Yt Zhong
b0c6ab8a93
Simple streaming return implementation, lower latency for the first sound. (#417)
* Add stream_return switch to get wavs from yield

* Add more_segment_before arg for more segmenting.

more_segment_before is a int, for token_index < more_segment_before, more segmenting will be applied.
0: no effect; 80 is recommended for better first-wav-latency

* Uncomment silence insertion

* fix: rename quick streaming tokens argument

* fix: rename quick streaming tokens argument

* fix: Add a wrapper for the yield function. It will not return a generator in normal condition.
2025-09-30 14:05:39 +08:00
Christopher Özbek
34be9bfb14 feat: Warn if input text contains UNK tokens
Added warnings for unknown tokens in input text.
2025-09-27 09:08:18 +02:00
kj863257rc
64cb31a6c3
Update infer_v2.py: solve the problem of persistent cache buildup (#382)
* Update infer_v2.py

clear old cache

* Update infer_v2.py: solve the problem of persistent cache buildup

clear old cache
2025-09-18 13:59:45 +08:00
Arcitec
8aa8064a53 feat: Add reusable Emotion Vector normalization helper
- The WebUI was secretly squashing all emotion vectors and re-scaling them. It's a good idea for user friendliness, but it makes it harder to learn what values will work in Python when using the WebUI for testing.

- Instead, let's move the normalization code into IndexTTS2 as a helper function which is used by Gradio and can be used from other people's code too.

- The emotion bias (which reduces the influence of certain emotions) has also been converted into an optional feature, which can be turned off if such biasing isn't wanted. And all biasing values have been re-scaled to use 1.0 as the reference, to avoid scaling relative to 0.8 (which previously meant that it applied double scaling).
2025-09-17 19:56:07 +02:00
nanaoto
ee23371296
Merge pull request #338 from yrom/fix/preload-bigvgan-cuda
Correct the import path of BigVGAN's custom cuda kernel
2025-09-15 16:27:40 +08:00
nanaoto
0828dcb098 feat: 裁剪过长的输入音频至15s,减少爆内存和显存 2025-09-12 16:45:37 +08:00
LGZwr
2cfc76ad9c fix: 修复样本音频太长报错的问题,对音频进行裁切。 2025-09-12 14:08:46 +08:00
Yrom
e409c4a19b
fix(infer_v2): Correct the import path of BigVGAN's custom cuda kernel 2025-09-11 16:55:18 +08:00
Arcitec
9668064377 feat: Implement emo_alpha scaling of emotion vectors and emotion text
- Added support for `emo_alpha` scaling of emotion vectors and emotion text inputs.

- This is a major new feature, which now allows for much more natural speech generation by lowering the influence of the emotion vector/text control modes.

- It is particularly useful for the "emotion text description" control mode, where a strength of 0.6 or lower is useful to get much more natural speech. Before this feature, it was not possible to make natural speech with that mode, because QwenEmotion assigns emotion scores to the text from 0.0-1.0, and that score was used directly as an emotion vector. This meant that the text mode always used very high strengths. Now, the user can adjust the strength of the emotions to get very natural results.

- Refactored `IndexTTS2.infer()` variable initialization logic to avoid repetition and ensure cleaner code paths.
2025-09-11 04:24:47 +02:00
Arcitec
555e146fb4 feat(webui): Implement speech synthesis progress bar 2025-09-11 04:17:02 +02:00
Arcitec
6113567e94 fix(cli): More robust device priority checks 2025-09-11 04:16:27 +02:00
DDXDB
e83df4e427
feat(cli): Support XPU (#322)
* Support XPU

* Support XPU
2025-09-10 22:35:06 +08:00
Arcitec
05a8ae45e5 fix: Don't load DeepSpeed if use_deepspeed is False
- A recent change made DeepSpeed optional (off by default), but the code was still trying to load DeepSpeed even when `use_deepspeed = False`. This means users would still have a big startup slowdown and a lot of error messages if their DeepSpeed module isn't working (usually because it's not able to compile itself on their machines).

- We now only load DeepSpeed if the user requested it.

- Translated the DeepSpeed error message to English, since all other errors in the same function were already English.
2025-09-09 18:20:28 +02:00
Arcitec
7aca90ba6c refactor: Simplify use_cuda_kernel check 2025-09-09 18:11:12 +02:00
nanaoto
ec530fb0a7
add deepspeed cmd option (#307) 2025-09-09 20:35:54 +08:00
仙舟龙脉研究所
5d6a18a776
Add support for Intel GPUs (#298) 2025-09-09 20:31:50 +08:00
十字鱼
055a23a12b
Add startup parameters for cuda_kernel (#302)
* Update webui.py

* Update infer_v2.py
2025-09-09 20:31:05 +08:00
Johnny Arcitec
cdcc62ae22
IndexTTS2 Release Preparation, Part 2 (#291)
* fix: Configure "uv" build system to use CUDA on supported platforms

- Linux builds of PyTorch always have CUDA acceleration built-in, but Windows only has it if we request a CUDA build.

- The built-in CUDA on Linux uses old libraries and can be slow.

- We now request PyTorch built for the most modern CUDA Toolkit on Linux + Windows, to solve both problems.

- Mac uses PyTorch without CUDA support, since it doesn't exist on that platform.

- Other dependencies have received new releases and are included in this fix too:

* click was downgraded because the author revoked 8.2.2 due to a bug.

* wetext received a new release now.

* fix: Use PyPI as the hashing reference in "uv" lockfile

- PyPI is the most trustworthy source for package hashes. We need to remove the custom mirror from the config, otherwise that mirror always becomes the default lockfile/package source, which leads to user trust issues and package impersonation risks.

- Regional mirrors should be added by users during installation instead, via the `uv sync --default-index` flag. Documented with example for Chinese mirror.

- When users add `--default-index`, "uv" will try to discover the exact same packages via the mirror to improve download speeds, but automatically uses PyPI if the mirror didn't have the files or if the mirror's file hashes were incorrect. Thus ensuring that users always have the correct package files.

* docs: Improve README for IndexTTS2 release!

- "Abstract" separated into paragraphs for easier readability.

- Clearer document structure and many grammatical improvements.

- More emojis, to make it easier to find sections when scrolling through the page!

- Added missing instructions:

* Needing `git-lfs` to clone the code.
* Needing CUDA Toolkit to install the dependencies.
* How to install the `hf` or `modelscope` CLI tools to download the models.

- Made our web demo the first section within "quickstart", to give users a quick, fun demo to start experimenting with.

- Fixed a bug in the "PYTHONPATH" recommendation. It must be enclosed in quotes `""`, otherwise the new path would break on systems that had spaces in their original path.

- Improved all Python code-example descriptions to make them much easier to understand.

- Clearly marked the IndexTTS1 legacy section as "legacy" to avoid confusion.

- Removed outdated Windows "conda/pip" instruction which is no longer relevant since we use "uv" now.

* refactor(webui): Remove unused imports

The old IndexTTS1 module and ModelScope were being loaded even though we don't need them. They also have a lot of dependencies, which slowed down loading and could even cause some conflicts.

* feat!: Remove obsolete build system (setup.py)

BREAKING CHANGE: The `setup.py` file has been removed.

Users should now use the new `pyproject.toml` based "uv" build system for installing and developing the project.

* feat: Add support for installing IndexTTS as a CLI tool

- We now support installing as a CLI tool via "uv".

- Uses the modern "hatchling" as the package / CLI build system.

- The `cli.py` code is currently outdated (doesn't support IndexTTS2). Marking as a TODO.

* chore: Add authors and classifiers metadata to pyproject.toml

* feat: Faster installs by making WebUI dependencies optional

* refactor!: Rename "sentences" to "segments" for clarity

- When we are splitting text into generation chunks, we are *not* creating "sentences". We are creating "segments". Because a *sentence* must always end with punctuation (".!?" etc). A *segment* can be a small fragment of a sentence, without any punctuation, so it's not accurate (and was very misleading) to use the word "sentences".

- All variables, function calls and strings have been carefully analyzed and renamed.

- This change will be part of user-facing code via a new feature, which is why the change was applied to the entire codebase.

- This change also helps future code contributors understand the code.

- All affected features are fully tested and work correctly after this refactoring.

- The `is_fp16` parameter has also been renamed to `use_fp16` since the previous name could confuse people ("is" implies an automatic check, "use" implies a user decision to enable/disable FP16).

- `cli.py`'s "--fp16" default value has been set to False, exactly like the web UI.

- `webui.py`'s "--is_fp16" flag has been changed to "--fp16" for easier usage and consistency with the CLI program, and the help-description has been improved.

* feat(webui): Set "max tokens per generation segment" via CLI flag

- The "Max tokens per generation segment" is a critical setting, as it directly impacts VRAM usage. Since the optimal value varies significantly based on a user's GPU, it is a frequent point of adjustment to prevent out-of-memory issues.

- This change allows the default value to be set via a CLI flag. Users can now conveniently start the web UI with the correct setting for their system, eliminating the need to manually reconfigure the value on every restart.

- The `webui.py -h` help text has also been enhanced to automatically display the default values for all CLI settings.

* refactor(i18n): Improve clarity of all web UI translation strings

* feat(webui): Use main text as emotion guidance when description is empty

If the user selects "text-to-emotion" control, but leaves the emotion description empty, we now automatically use the main text prompt instead.

This ensures that web users can enjoy every feature of IndexTTS2, including the ability to automatically guess the emotion from the main text prompt.

* feat: Add PyTorch GPU acceleration diagnostic tool

* chore: Use NVIDIA CUDA Toolkit v12.8

Downgrade from CUDA 12.9 to 12.8 to simplify user installation, since version 12.8 is very popular.

* docs: Simplify "uv run" command examples

The "uv run" command can take a `.py` file as direct argument and automatically understands that it should run via python.
2025-09-09 12:51:45 +08:00
Arcitec
dcdb0614bf fix: Use WeTextProcessing on Linux, and wetext on other platforms 2025-09-08 17:04:19 +02:00
Arcitec
dfe1bd41d8 refactor: Remove code duplication in DeepSpeed dependency check 2025-09-08 16:17:17 +02:00
Arcitec
a6a955d2aa fix: Add support for melancholic emotion in text-to-emotion vectors
- The "低落" (melancholic) emotion will always be mapped to "悲伤" (sad) by QwenEmotion's text analysis. It doesn't know the difference between those emotions even if the user writes the exact words.

- Since the words and their meanings are so similar, it might not be possible to train QwenEmotion to learn the difference.

- As a workaround, we perform input text analysis and look for words that mean "melancholic", and swap the "sad" detection result, to make the melancholic/low-energy speech emotion work correctly for users via text-to-emotion.
2025-09-08 16:14:38 +02:00
Arcitec
58ad225fb4 fix: Fast and robust text-to-emotion algorithm
- The new algorithm is now very fast and uses less memory, since it doesn't chain multiple `.replace()` calls or create a bunch of temporary strings and temporary dictionaries and lists anymore.

- Parses the JSON output from the QwenEmotion model directly instead of trying to manually parse it. If JSON parsing fails, it falls back to a fast and highly-accurate RegEx search which finds all key-value pairs.

- The desired emotion vector order is now stored as a static class attribute instead of being created from scratch on every call.

- The emotion dictionary creation has been completely rewritten to use a clear algorithm which takes the QwenEmotion answers, builds a new dictionary using `self.desired_vector_order`, maps each key's name to their English translations, fetches the values from QwenEmotion's answers or 0.0 if no value was given by QE, and clamps the values to the min/max ranges.

- The `backup_dict` is now removed, since it was error-prone and fragile. It could grow out of sync with the code if not carefully maintained to keep the correct order and labels.

- To handle the "fallback" dictionary creation, we now automatically scan the final emotion vectors, and if none of them are above 0.0 (meaning we didn't detect any emotions in the input text), we give the final vectors a "calm: 1.0" value. This means that we never have to worry about the fallback dictionary's correctness.

- The previous algorithm had multiple bugs. This rewrite fixes a serious vector order bug: The old algorithm built the dictionary via the found keys, and only checked if there's 8 keys in QwenEmotion's response, but it didn't check that the keys were valid. When building the final emotion dict, it skipped any values if they were not found in QE's response. Meaning that if the QE response only contained 4 of the 8 expected emotion vector labels, those would all be added at the start of the new dictionary as the "first 4 dict slots". After that, it looped through the "backup_dict" and appended any missing values at the end. This resulted in a final emotion dictionary with the wrong order for the emotion vectors. The new code always produces the correct emotion vector order.

- Discovered another bug in the text-to-emotion handling for the "melancholic" emotion, which has never worked for Chinese or English at all. It will be fixed in an upcoming patch.
2025-09-08 16:14:38 +02:00
Arcitec
feba501013 fix: Fix internal text-to-emotion vector labels
- The order of the `convert_dict` now matches the desired order of the emotion vectors, for clarity.

- Internal text labels now match the updated English translations.

- This (and the previous commit) also fixes a bug: The previous, inaccurate Emotion translations meant that QwenEmotion could not understand words such as "low" at all (no emotion mapping), and it always mapped "hate" to "angry". With the fixed translations, QwenEmotion now correctly maps text-to-emotions from English inputs when users input the words that they've been taught by the user interface.
2025-09-08 16:14:38 +02:00
十字鱼
9d4776b082
Use without deepspeed (#280)
Use without deepspeed
2025-09-08 22:09:26 +08:00
kemuriririn
72c09ec0b7
Indextts2 (#276)
* indextts2

* update lfs for audio files

---------

Co-authored-by: wangyining02 <wangyining02@bilibili.com>
2025-09-08 17:36:39 +08:00
root
9098497272 Fix the bug that 嗯 cannot be synthesized. 2025-06-17 17:48:04 +08:00
yrom
92bb2eb0c0 fix: 避免在 MinGW-w64 环境 jit compile cuda ext 2025-05-29 09:01:56 +08:00
yrom
59c05c0765
fix: add force_rebuild flag for fused alias_free_activation and update installation instructions 2025-05-23 15:07:39 +08:00
yrom
bb4d76aa2a fix: 添加英语缩写处理
临时解决WeTextProcessing 的部分badcase
2025-05-23 10:07:48 +08:00
Yrom
7d943b362d
fix: update PINYIN_TONE_PATTERN and NormalizerZh 2025-05-21 13:01:25 +08:00
yrom
3553a3755d fix 分句逻辑,增加测试用例
不包含。!?的句子没有被正确分句
2025-05-18 22:53:51 +08:00
yrom
60a2238eac sample_kwargs 替换为 generation_kwargs 2025-05-18 19:34:41 +08:00
yrom
96d3b75708 添加警告提示:生成停止因超出 max_mel_tokens 限制 2025-05-18 19:34:41 +08:00
yrom
7e52976bd1 删除测试代码 2025-05-18 19:34:41 +08:00
yrom
1b7529cacd 适配新版本transformers 2025-05-18 19:34:41 +08:00
yrom
22eeb7625f 修正attention mask和positional embeddings
- 将之前只有text右侧填充改为cond+text 整体左侧填充
- 添加填充测试用例
2025-05-18 19:34:32 +08:00
yrom
a50cb8c287 优化文本掩码填充逻辑,改进句子桶化处理 2025-05-17 20:59:07 +08:00
yrom
4de7611bda fix 批量推理1.5版本模型问题,调整分句逻辑和参数设置
- 将pad 改为全 eos token
- 优化bucket_sentences 算法
2025-05-17 14:40:01 +08:00
yrom
8f7c1f3e93 优化inference attention mask 2025-05-17 14:38:01 +08:00
yrom
cb6c73d391 优化文本归一化和分句逻辑
修复可能的递归问题 (Fixes #124)
2025-05-17 11:16:54 +08:00