mirror of
https://github.com/DrewThomasson/ebook2audiobook.git
synced 2026-01-07 21:14:06 -05:00
v26.1.4
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
20
lib/core.py
20
lib/core.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user