Skip to content
Python

added missing stuff

DeepBeepMeepa8b97f9cbe1e
diff --git a/models/TTS/index_tts2/configs/config.yaml b/models/TTS/index_tts2/configs/config.yaml
new file mode 100644
index 0000000..4d929e2
--- /dev/null
+++ b/models/TTS/index_tts2/configs/config.yaml
@@ -0,0 +1,120 @@
+dataset:
+ bpe_model: bpe.model
+ sample_rate: 24000
+ squeeze: false
+ mel:
+ sample_rate: 24000
+ n_fft: 1024
+ hop_length: 256
+ win_length: 1024
+ n_mels: 100
+ mel_fmin: 0
+ normalize: false
+
+gpt:
+ model_dim: 1280
+ max_mel_tokens: 1815
+ max_text_tokens: 600
+ heads: 20
+ use_mel_codes_as_input: true
+ mel_length_compression: 1024
+ layers: 24
+ number_text_tokens: 12000
+ number_mel_codes: 8194
+ start_mel_token: 8192
+ stop_mel_token: 8193
+ start_text_token: 0
+ stop_text_token: 1
+ train_solo_embeddings: false
+ condition_type: "conformer_perceiver"
+ condition_module:
+ output_size: 512
+ linear_units: 2048
+ attention_heads: 8
+ num_blocks: 6
+ input_layer: "conv2d2"
+ perceiver_mult: 2
+ emo_condition_module:
+ output_size: 512
+ linear_units: 1024
+ attention_heads: 4
+ num_blocks: 4
+ input_layer: "conv2d2"
+ perceiver_mult: 2
+
+semantic_codec:
+ codebook_size: 8192
+ hidden_size: 1024
+ codebook_dim: 8
+ vocos_dim: 384
+ vocos_intermediate_dim: 2048
+ vocos_num_layers: 12
+
+s2mel:
+ preprocess_params:
+ sr: 22050
+ spect_params:
+ n_fft: 1024
+ win_length: 1024
+ hop_length: 256
+ n_mels: 80
+ fmin: 0
+ fmax: "None"
+
+ dit_type: "DiT"
+ reg_loss_type: "l1"
+ style_encoder:
+ dim: 192
+ length_regulator:
+ channels: 512
+ is_discrete: false
+ in_channels: 1024
+ content_codebook_size: 2048
+ sampling_ratios: [1, 1, 1, 1]
+ vector_quantize: false
+ n_codebooks: 1
+ quantizer_dropout: 0.0
+ f0_condition: false
+ n_f0_bins: 512
+ DiT:
+ hidden_dim: 512
+ num_heads: 8
+ depth: 13
+ class_dropout_prob: 0.1
+ block_size: 8192
+ in_channels: 80
+ style_condition: true
+ final_layer_type: 'wavenet'
+ target: 'mel'
+ content_dim: 512
+ content_codebook_size: 1024
+ content_type: 'discrete'
+ f0_condition: false
+ n_f0_bins: 512
+ content_codebooks: 1
+ is_causal: false
+ long_skip_connection: true
+ zero_prompt_speech_token: false
+ time_as_token: false
+ style_as_token: false
+ uvit_skip_connection: true
+ add_resblock_in_transformer: false
+ wavenet:
+ hidden_dim: 512
+ num_layers: 8
+ kernel_size: 5
+ dilation_rate: 1
+ p_dropout: 0.2
+ style_condition: true
+
+gpt_checkpoint: index_tts2_gpt.safetensors
+w2v_stat: wav2vec2bert_stats.pt
+s2mel_checkpoint: s2mel.safetensors
+emo_matrix: feat2.pt
+spk_matrix: feat1.pt
+emo_num: [3, 17, 2, 8, 4, 5, 10, 24]
+qwen_emo_path: qwen0.6bemo4-merge/
+vocoder:
+ type: "bigvgan"
+ name: "nvidia/bigvgan_v2_22khz_80band_256x"
+version: 2.0
diff --git a/models/TTS/index_tts2/configs/config_runtime.yaml b/models/TTS/index_tts2/configs/config_runtime.yaml
new file mode 100644
index 0000000..a76a99a
--- /dev/null
+++ b/models/TTS/index_tts2/configs/config_runtime.yaml
@@ -0,0 +1,128 @@
+dataset:
+ bpe_model: bpe.model
+ sample_rate: 24000
+ squeeze: false
+ mel:
+ sample_rate: 24000
+ n_fft: 1024
+ hop_length: 256
+ win_length: 1024
+ n_mels: 100
+ mel_fmin: 0
+ normalize: false
+gpt:
+ model_dim: 1280
+ max_mel_tokens: 1815
+ max_text_tokens: 600
+ heads: 20
+ use_mel_codes_as_input: true
+ mel_length_compression: 1024
+ layers: 24
+ number_text_tokens: 12000
+ number_mel_codes: 8194
+ start_mel_token: 8192
+ stop_mel_token: 8193
+ start_text_token: 0
+ stop_text_token: 1
+ train_solo_embeddings: false
+ condition_type: conformer_perceiver
+ condition_module:
+ output_size: 512
+ linear_units: 2048
+ attention_heads: 8
+ num_blocks: 6
+ input_layer: conv2d2
+ perceiver_mult: 2
+ emo_condition_module:
+ output_size: 512
+ linear_units: 1024
+ attention_heads: 4
+ num_blocks: 4
+ input_layer: conv2d2
+ perceiver_mult: 2
+semantic_codec:
+ codebook_size: 8192
+ hidden_size: 1024
+ codebook_dim: 8
+ vocos_dim: 384
+ vocos_intermediate_dim: 2048
+ vocos_num_layers: 12
+s2mel:
+ preprocess_params:
+ sr: 22050
+ spect_params:
+ n_fft: 1024
+ win_length: 1024
+ hop_length: 256
+ n_mels: 80
+ fmin: 0
+ fmax: None
+ dit_type: DiT
+ reg_loss_type: l1
+ style_encoder:
+ dim: 192
+ length_regulator:
+ channels: 512
+ is_discrete: false
+ in_channels: 1024
+ content_codebook_size: 2048
+ sampling_ratios:
+ - 1
+ - 1
+ - 1
+ - 1
+ vector_quantize: false
+ n_codebooks: 1
+ quantizer_dropout: 0.0
+ f0_condition: false
+ n_f0_bins: 512
+ DiT:
+ hidden_dim: 512
+ num_heads: 8
+ depth: 13
+ class_dropout_prob: 0.1
+ block_size: 8192
+ in_channels: 80
+ style_condition: true
+ final_layer_type: wavenet
+ target: mel
+ content_dim: 512
+ content_codebook_size: 1024
+ content_type: discrete
+ f0_condition: false
+ n_f0_bins: 512
+ content_codebooks: 1
+ is_causal: false
+ long_skip_connection: true
+ zero_prompt_speech_token: false
+ time_as_token: false
+ style_as_token: false
+ uvit_skip_connection: true
+ add_resblock_in_transformer: false
+ wavenet:
+ hidden_dim: 512
+ num_layers: 8
+ kernel_size: 5
+ dilation_rate: 1
+ p_dropout: 0.2
+ style_condition: true
+gpt_checkpoint: E:\ML\Wan2GP\ckpts\index_tts2_gpt_fp16.safetensors
+w2v_stat: wav2vec2bert_stats.pt
+s2mel_checkpoint: s2mel.safetensors
+emo_matrix: feat2.pt
+spk_matrix: feat1.pt
+emo_num:
+- 3
+- 17
+- 2
+- 8
+- 4
+- 5
+- 10
+- 24
+qwen_emo_path: E:\ML\Wan2GP\ckpts\qwen0.6bemo4-merge
+vocoder:
+ type: bigvgan
+ name: ckpts\bigvgan_v2_22khz_80band_256x
+version: 2.0
+w2v_bert_path: E:\ML\Wan2GP\ckpts\w2v-bert-2.0
diff --git a/models/TTS/index_tts2/configs/gpt_runtime_config.json b/models/TTS/index_tts2/configs/gpt_runtime_config.json
new file mode 100644
index 0000000..b7b2c7e
--- /dev/null
+++ b/models/TTS/index_tts2/configs/gpt_runtime_config.json
@@ -0,0 +1 @@
+{"model_dim": 1280, "max_mel_tokens": 1815, "max_text_tokens": 600, "heads": 20, "use_mel_codes_as_input": true, "mel_length_compression": 1024, "layers": 24, "number_text_tokens": 12000, "number_mel_codes": 8194, "start_mel_token": 8192, "stop_mel_token": 8193, "start_text_token": 0, "stop_text_token": 1, "train_solo_embeddings": false, "condition_type": "conformer_perceiver", "condition_module": {"output_size": 512, "linear_units": 2048, "attention_heads": 8, "num_blocks": 6, "input_layer": "conv2d2", "perceiver_mult": 2}, "emo_condition_module": {"output_size": 512, "linear_units": 1024, "attention_heads": 4, "num_blocks": 4, "input_layer": "conv2d2", "perceiver_mult": 2}}
\ No newline at end of file
diff --git a/models/TTS/index_tts2/pipeline.py b/models/TTS/index_tts2/pipeline.py
index 0606337..4ed3d44 100644
--- a/models/TTS/index_tts2/pipeline.py
+++ b/models/TTS/index_tts2/pipeline.py
@@ -25,6 +25,7 @@ _W2V_BERT_FOLDER = "w2v-bert-2.0"
_CONFIGS_SUBDIR = "configs"
_BASE_CFG_NAME = "config.yaml"
_RUNTIME_CFG_NAME = "config_runtime.yaml"
+_SOURCE_CONFIGS_DIR = Path(__file__).resolve().parent / _CONFIGS_SUBDIR
_AUTO_SPLIT_SETTING_ID = "auto_split_every_s"
_AUTO_SPLIT_TOKENS_PER_SECOND = 6.0
_MEL_TOKENS_PER_SOUND_TOKEN = 1.72
@@ -99,16 +100,13 @@ class IndexTTS2Pipeline:
self._mark_model_dtypes()
def _resolve_config_path(self) -> Path:
- configs_dir = self.model_dir / _CONFIGS_SUBDIR
- cfg_path = configs_dir / _BASE_CFG_NAME
+ cfg_path = _SOURCE_CONFIGS_DIR / _BASE_CFG_NAME
if cfg_path.is_file():
return cfg_path
- legacy_cfg_path = self.model_dir / _BASE_CFG_NAME
- if legacy_cfg_path.is_file():
- configs_dir.mkdir(parents=True, exist_ok=True)
- legacy_cfg_path.replace(cfg_path)
- return cfg_path
- raise FileNotFoundError(f"IndexTTS2 config not found: {cfg_path}")
+ raise FileNotFoundError(
+ f"IndexTTS2 source config not found: {cfg_path}. "
+ f"Expected configs bundled with project source in '{_SOURCE_CONFIGS_DIR}'."
+ )
def _resolve_model_dir(self) -> Path:
located = fl.locate_folder("index_tts2", error_if_none=False)
diff --git a/models/TTS/index_tts2_handler.py b/models/TTS/index_tts2_handler.py
index f769908..a006a4b 100644
--- a/models/TTS/index_tts2_handler.py
+++ b/models/TTS/index_tts2_handler.py
@@ -10,7 +10,6 @@ from .prompt_enhancers import TTS_MONOLOGUE_PROMPT, TTS_QWEN3_DIALOGUE_PROMPT
INDEX_TTS2_REPO_ID = "DeepBeepMeep/TTS"
INDEX_TTS2_FOLDER = "index_tts2"
-INDEX_TTS2_CONFIGS_FOLDER = "index_tts2/configs"
INDEX_TTS2_MAIN_GPT_FILENAME = "index_tts2_gpt_fp16.safetensors"
INDEX_TTS2_QWEN_EMO_FOLDER = "qwen0.6bemo4-merge"
INDEX_TTS2_BIGVGAN_FOLDER = "bigvgan_v2_22khz_80band_256x"
@@ -22,7 +21,7 @@ INDEX_TTS2_BIGVGAN_FILES = [
INDEX_TTS2_W2V_BERT_FILES = [
"config.json",
"preprocessor_config.json",
- "model.safetensors",
+ "model_fp16.safetensors",
]
INDEX_TTS2_SHOW_LOAD_LOGS = False
INDEX_TTS2_ROOT_FILES = [
@@ -34,7 +33,6 @@ INDEX_TTS2_ROOT_FILES = [
"campplus_cn_common.bin",
"index_tts2_semantic_codec.safetensors",
]
-INDEX_TTS2_CONFIG_FILES = ["config.yaml"]
INDEX_TTS2_QWEN_EMO_FILES = [
"Modelfile",
"added_tokens.json",
@@ -121,16 +119,15 @@ def _get_index_tts2_model_def():
def _get_index_tts2_download_def():
return {
"repoId": INDEX_TTS2_REPO_ID,
+ # IndexTTS2 configs are bundled with source code in models/TTS/index_tts2/configs.
"sourceFolderList": [
INDEX_TTS2_FOLDER,
- INDEX_TTS2_CONFIGS_FOLDER,
INDEX_TTS2_QWEN_EMO_FOLDER,
INDEX_TTS2_BIGVGAN_FOLDER,
INDEX_TTS2_W2V_BERT_FOLDER,
],
"fileList": [
INDEX_TTS2_ROOT_FILES,
- INDEX_TTS2_CONFIG_FILES,
INDEX_TTS2_QWEN_EMO_FILES,
INDEX_TTS2_BIGVGAN_FILES,
INDEX_TTS2_W2V_BERT_FILES,
@@ -155,25 +152,25 @@ def _ensure_w2v_bert_fp16_file():
f"IndexTTS2 semantic folder '{INDEX_TTS2_W2V_BERT_FOLDER}' is missing. "
"WanGP must download it from DeepBeepMeep/TTS."
)
- fp32_path = os.path.join(w2v_dir, "model.safetensors")
- if not os.path.isfile(fp32_path):
- raise FileNotFoundError(
- f"IndexTTS2 semantic model file is missing at '{fp32_path}'. "
- "Expected DeepBeepMeep/TTS/w2v-bert-2.0/model.safetensors."
- )
+ # fp32_path = os.path.join(w2v_dir, "model.safetensors")
+ # if not os.path.isfile(fp32_path):
+ # raise FileNotFoundError(
+ # f"IndexTTS2 semantic model file is missing at '{fp32_path}'. "
+ # "Expected DeepBeepMeep/TTS/w2v-bert-2.0/model.safetensors."
+ # )
fp16_path = os.path.join(w2v_dir, "model_fp16.safetensors")
if os.path.isfile(fp16_path):
return fp16_path
- from safetensors.torch import load_file, save_file
-
- src = load_file(fp32_path, device="cpu")
- dst = {}
- for key, value in src.items():
- if torch.is_floating_point(value) and value.dtype != torch.float16:
- dst[key] = value.to(torch.float16).contiguous()
- else:
- dst[key] = value.contiguous()
- save_file(dst, fp16_path, metadata={"format": "pt", "dtype": "float16"})
+ from mmgp import offload
+
+ src = safetensors2.l .load_ (fp16_path, device="cpu")
+ # dst = {}
+ # for key, value in src.items():
+ # if torch.is_floating_point(value) and value.dtype != torch.float16:
+ # dst[key] = value.to(torch.float16).contiguous()
+ # else:
+ # dst[key] = value.contiguous()
+ # save_file(dst, fp16_path, metadata={"format": "pt", "dtype": "float16"})
return fp16_path
@@ -235,7 +232,7 @@ class family_handler:
):
from .index_tts2.pipeline import IndexTTS2Pipeline
- _ensure_w2v_bert_fp16_file()
+ # _ensure_w2v_bert_fp16_file()
weights_candidate = None
if isinstance(model_filename, (list, tuple)):
if len(model_filename) > 0: