This commit is contained in:
ROBERT MCDOWELL
2026-01-04 13:02:57 -08:00
committed by GitHub
8 changed files with 25 additions and 9 deletions

View File

@@ -251,7 +251,7 @@ class Bark(TTSUtils, TTSRegistry, name='bark'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -310,7 +310,7 @@ class TTSUtils:
with open(path, "a", encoding="utf-8") as f:
start = format_timestamp(float(sentence_obj["start"]))
end = format_timestamp(float(sentence_obj["end"]))
text = re.sub(r"[\r\n]+", " ", str(sentence_obj["text"])).strip()
text = re.sub(r'\s+', ' ', default_sml_pattern.sub('', str(sentence_obj["text"]))).strip()
f.write(f"{start} --> {end}\n{text}\n\n")
return index + 1
except Exception as e:

View File

@@ -227,7 +227,7 @@ class Fairseq(TTSUtils, TTSRegistry, name='fairseq'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -255,7 +255,7 @@ class Tacotron2(TTSUtils, TTSRegistry, name='tacotron'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -240,7 +240,7 @@ class Vits(TTSUtils, TTSRegistry, name='vits'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -197,7 +197,7 @@ class XTTSv2(TTSUtils, TTSRegistry, name='xtts'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -165,7 +165,7 @@ class YourTTS(TTSUtils, TTSRegistry, name='yourtts'):
sentence_obj = {
"start": start_time,
"end": end_time,
"text": re.sub(r'\s+', ' ', default_sml_pattern.sub('', sentence)).strip(),
"text": sentence,
"idx": self.sentence_idx
}
self.sentence_idx = self._append_sentence2vtt(sentence_obj, self.vtt_path)

View File

@@ -1107,8 +1107,24 @@ def get_sentences(text:str, id:str)->list|None:
re.DOTALL
)
soft_list = []
for s in hard_list:
s = s.strip()
i = 0
n = len(hard_list)
while i < n:
s = hard_list[i].strip()
if not s:
i += 1
continue
if i + 1 < n:
next_s = hard_list[i + 1].strip()
next_clean = strip_sml(next_s)
if next_clean and sum(c.isalnum() for c in next_clean) < 3:
s = f"{s} {next_s}"
i += 2
else:
i += 1
else:
i += 1
if len(strip_sml(s)) <= max_chars:
soft_list.append(s)
continue