Normalize question marks before local TTS

This commit is contained in:
Mikei386
2026-09-03 23:24:15 +02:00
parent 023c2ee40d
commit 384d81f6cd
2 changed files with 9 additions and 0 deletions
@@ -298,6 +298,10 @@ def clean_for_speech(text: str) -> str:
text = re.sub(r"(?<=\w)[\-‐‑‒–—−](?=\w)", " ", text)
text = re.sub(r"\s+[\-‐‑‒–—−]\s+", ", ", text)
text = re.sub(r"\s*[:;]+\s*", ", ", text)
# XTTS can pronounce literal question/exclamation glyphs as short
# nonsense syllables (for example "?" as "nau"). Retain a sentence
# boundary for pacing, but never pass those glyphs to the model.
text = re.sub(r"\s*[!?]+\s*", ". ", text)
text = "".join(
char for char in text
if unicodedata.category(char) not in {"So", "Cs"}