Spaces:
Running on Zero
Running on Zero
Initial commit: per-language Chatterbox TTS demo
Browse files- README.md +2 -2
- chatterbox/src/chatterbox/tts.py +8 -4
README.md
CHANGED
|
@@ -11,7 +11,7 @@ pinned: false
|
|
| 11 |
short_description: "Chatterbox TTS fine-tuned for Hindi (hi)."
|
| 12 |
models:
|
| 13 |
- ResembleAI/Chatterbox-Multilingual-hi
|
| 14 |
-
- ResembleAI/
|
| 15 |
---
|
| 16 |
|
| 17 |
# Chatterbox Multilingual TTS — Hindi
|
|
@@ -19,6 +19,6 @@ models:
|
|
| 19 |
Chatterbox TTS fine-tuned for Hindi (hi).
|
| 20 |
|
| 21 |
Powered by [`ResembleAI/Chatterbox-Multilingual-hi`](https://huggingface.co/ResembleAI/Chatterbox-Multilingual-hi).
|
| 22 |
-
Base components reused from [`ResembleAI/
|
| 23 |
|
| 24 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 11 |
short_description: "Chatterbox TTS fine-tuned for Hindi (hi)."
|
| 12 |
models:
|
| 13 |
- ResembleAI/Chatterbox-Multilingual-hi
|
| 14 |
+
- ResembleAI/chatterbox
|
| 15 |
---
|
| 16 |
|
| 17 |
# Chatterbox Multilingual TTS — Hindi
|
|
|
|
| 19 |
Chatterbox TTS fine-tuned for Hindi (hi).
|
| 20 |
|
| 21 |
Powered by [`ResembleAI/Chatterbox-Multilingual-hi`](https://huggingface.co/ResembleAI/Chatterbox-Multilingual-hi).
|
| 22 |
+
Base components reused from [`ResembleAI/chatterbox`](https://huggingface.co/ResembleAI/chatterbox).
|
| 23 |
|
| 24 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
chatterbox/src/chatterbox/tts.py
CHANGED
|
@@ -19,8 +19,10 @@ from .models.t3.modules.cond_enc import T3Cond
|
|
| 19 |
|
| 20 |
|
| 21 |
REPO_ID = "ResembleAI/Chatterbox-Multilingual-hi"
|
| 22 |
-
BASE_REPO_ID = "ResembleAI/
|
| 23 |
T3_FILENAME = "t3_hi.safetensors"
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
def punc_norm(text: str) -> str:
|
|
@@ -144,7 +146,9 @@ class ChatterboxTTS:
|
|
| 144 |
)
|
| 145 |
ve.to(device).eval()
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
t3_state = load_safetensors(ckpt_dir / t3_filename)
|
| 149 |
if "model" in t3_state.keys():
|
| 150 |
t3_state = t3_state["model"][0]
|
|
@@ -158,7 +162,7 @@ class ChatterboxTTS:
|
|
| 158 |
s3gen.to(device).eval()
|
| 159 |
|
| 160 |
tokenizer = MTLTokenizer(
|
| 161 |
-
str(ckpt_dir /
|
| 162 |
)
|
| 163 |
|
| 164 |
conds = None
|
|
@@ -170,7 +174,7 @@ class ChatterboxTTS:
|
|
| 170 |
@classmethod
|
| 171 |
def from_pretrained(cls, device: torch.device) -> 'ChatterboxTTS':
|
| 172 |
token = os.getenv("HF_TOKEN")
|
| 173 |
-
base_files = ["ve.pt", "s3gen.pt",
|
| 174 |
base_dir = Path(
|
| 175 |
snapshot_download(
|
| 176 |
repo_id=BASE_REPO_ID,
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
REPO_ID = "ResembleAI/Chatterbox-Multilingual-hi"
|
| 22 |
+
BASE_REPO_ID = "ResembleAI/chatterbox"
|
| 23 |
T3_FILENAME = "t3_hi.safetensors"
|
| 24 |
+
TOKENIZER_FILENAME = "grapheme_mtl_merged_expanded_v1.json"
|
| 25 |
+
T3_TEXT_VOCAB_SIZE = 2454
|
| 26 |
|
| 27 |
|
| 28 |
def punc_norm(text: str) -> str:
|
|
|
|
| 146 |
)
|
| 147 |
ve.to(device).eval()
|
| 148 |
|
| 149 |
+
t3_cfg = T3ConfigMultilingual()
|
| 150 |
+
t3_cfg.text_tokens_dict_size = T3_TEXT_VOCAB_SIZE
|
| 151 |
+
t3 = T3(t3_cfg)
|
| 152 |
t3_state = load_safetensors(ckpt_dir / t3_filename)
|
| 153 |
if "model" in t3_state.keys():
|
| 154 |
t3_state = t3_state["model"][0]
|
|
|
|
| 162 |
s3gen.to(device).eval()
|
| 163 |
|
| 164 |
tokenizer = MTLTokenizer(
|
| 165 |
+
str(ckpt_dir / TOKENIZER_FILENAME)
|
| 166 |
)
|
| 167 |
|
| 168 |
conds = None
|
|
|
|
| 174 |
@classmethod
|
| 175 |
def from_pretrained(cls, device: torch.device) -> 'ChatterboxTTS':
|
| 176 |
token = os.getenv("HF_TOKEN")
|
| 177 |
+
base_files = ["ve.pt", "s3gen.pt", TOKENIZER_FILENAME, "conds.pt"]
|
| 178 |
base_dir = Path(
|
| 179 |
snapshot_download(
|
| 180 |
repo_id=BASE_REPO_ID,
|