Spaces:
Running
Running
Update chatterbox/src/chatterbox/tts.py
Browse files
chatterbox/src/chatterbox/tts.py
CHANGED
|
@@ -45,10 +45,10 @@ def punc_norm(text: str) -> str:
|
|
| 45 |
("—", "-"),
|
| 46 |
("–", "-"),
|
| 47 |
(" ,", ","),
|
| 48 |
-
("
|
| 49 |
-
("
|
| 50 |
-
("
|
| 51 |
-
("
|
| 52 |
]
|
| 53 |
for old_char_sequence, new_char in punc_to_replace:
|
| 54 |
text = text.replace(old_char_sequence, new_char)
|
|
@@ -131,12 +131,12 @@ class ChatterboxTTS:
|
|
| 131 |
|
| 132 |
ve = VoiceEncoder()
|
| 133 |
ve.load_state_dict(
|
| 134 |
-
torch.load(ckpt_dir / "ve.pt")
|
| 135 |
)
|
| 136 |
ve.to(device).eval()
|
| 137 |
|
| 138 |
t3 = T3()
|
| 139 |
-
t3_state = torch.load(ckpt_dir / "t3_cfg.pt")
|
| 140 |
if "model" in t3_state.keys():
|
| 141 |
t3_state = t3_state["model"][0]
|
| 142 |
t3.load_state_dict(t3_state)
|
|
@@ -144,7 +144,7 @@ class ChatterboxTTS:
|
|
| 144 |
|
| 145 |
s3gen = S3Gen()
|
| 146 |
s3gen.load_state_dict(
|
| 147 |
-
torch.load(ckpt_dir / "s3gen.pt")
|
| 148 |
)
|
| 149 |
s3gen.to(device).eval()
|
| 150 |
|
|
@@ -154,7 +154,7 @@ class ChatterboxTTS:
|
|
| 154 |
|
| 155 |
conds = None
|
| 156 |
if (builtin_voice := ckpt_dir / "conds.pt").exists():
|
| 157 |
-
conds = Conditionals.load(builtin_voice).to(device)
|
| 158 |
|
| 159 |
return cls(t3, s3gen, ve, tokenizer, device, conds=conds)
|
| 160 |
|
|
@@ -267,4 +267,4 @@ class ChatterboxTTS:
|
|
| 267 |
)
|
| 268 |
wav = wav.squeeze(0).detach().cpu().numpy()
|
| 269 |
watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr)
|
| 270 |
-
return torch.from_numpy(watermarked_wav).unsqueeze(0)
|
|
|
|
| 45 |
("—", "-"),
|
| 46 |
("–", "-"),
|
| 47 |
(" ,", ","),
|
| 48 |
+
(""", "\""),
|
| 49 |
+
(""", "\""),
|
| 50 |
+
("'", "'"),
|
| 51 |
+
("'", "'"),
|
| 52 |
]
|
| 53 |
for old_char_sequence, new_char in punc_to_replace:
|
| 54 |
text = text.replace(old_char_sequence, new_char)
|
|
|
|
| 131 |
|
| 132 |
ve = VoiceEncoder()
|
| 133 |
ve.load_state_dict(
|
| 134 |
+
torch.load(ckpt_dir / "ve.pt", map_location=device)
|
| 135 |
)
|
| 136 |
ve.to(device).eval()
|
| 137 |
|
| 138 |
t3 = T3()
|
| 139 |
+
t3_state = torch.load(ckpt_dir / "t3_cfg.pt", map_location=device)
|
| 140 |
if "model" in t3_state.keys():
|
| 141 |
t3_state = t3_state["model"][0]
|
| 142 |
t3.load_state_dict(t3_state)
|
|
|
|
| 144 |
|
| 145 |
s3gen = S3Gen()
|
| 146 |
s3gen.load_state_dict(
|
| 147 |
+
torch.load(ckpt_dir / "s3gen.pt", map_location=device)
|
| 148 |
)
|
| 149 |
s3gen.to(device).eval()
|
| 150 |
|
|
|
|
| 154 |
|
| 155 |
conds = None
|
| 156 |
if (builtin_voice := ckpt_dir / "conds.pt").exists():
|
| 157 |
+
conds = Conditionals.load(builtin_voice, map_location=device).to(device)
|
| 158 |
|
| 159 |
return cls(t3, s3gen, ve, tokenizer, device, conds=conds)
|
| 160 |
|
|
|
|
| 267 |
)
|
| 268 |
wav = wav.squeeze(0).detach().cpu().numpy()
|
| 269 |
watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr)
|
| 270 |
+
return torch.from_numpy(watermarked_wav).unsqueeze(0)
|