From 267e344a0956c09f4c2ff9e16d1c6bda7d67c11a Mon Sep 17 00:00:00 2001 From: Yrom Date: Thu, 20 Nov 2025 19:49:02 +0800 Subject: [PATCH] fix: handle multiple sentence placeholders in de_tokenized_by_CJK_char --- indextts/utils/common.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/indextts/utils/common.py b/indextts/utils/common.py index d137e18..933f163 100644 --- a/indextts/utils/common.py +++ b/indextts/utils/common.py @@ -69,15 +69,16 @@ def de_tokenized_by_CJK_char(line: str, do_lower_case=False) -> str: words = line.split() # restore english sentences - sent_placeholder_pattern = re.compile(r"^.*?()") + sent_placeholder_pattern = re.compile(r"()") for i in range(len(words)): - m = sent_placeholder_pattern.match(words[i]) - if m: + all_matches = sent_placeholder_pattern.findall(words[i]) + if len(all_matches) > 1: # restore the english word - placeholder_index = int(m.group(2)) - words[i] = words[i].replace(m.group(1), english_sents[placeholder_index]) - if do_lower_case: - words[i] = words[i].lower() + for h,j in all_matches: + placeholder_index = int(j) + words[i] = words[i].replace(h, english_sents[placeholder_index]) + if do_lower_case: + words[i] = words[i].lower() return "".join(words)