Skip to content

Commit b5e452e

Browse files
committed
fix(core): split error on single sentence
1 parent 25cf2bc commit b5e452e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ChatTTS/core.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,15 @@ def infer(
225225
if "\n" in text:
226226
text = text.split("\n")
227227
else:
228-
text = re.split(r"(?<=[。(.\s)])", text)
228+
text = re.split(r"(?<=。)|(?<=\.\s)", text)
229229
nt = []
230-
for t in text:
231-
if t:
232-
nt.append(t)
233-
text = nt
230+
if isinstance(text, list):
231+
for t in text:
232+
if t:
233+
nt.append(t)
234+
text = nt
235+
else:
236+
text = [text]
234237
self.logger.info("split text into %d parts", len(text))
235238
self.logger.debug("%s", str(text))
236239

0 commit comments

Comments
 (0)