Skip to content

Commit

Permalink
Fix for sentence end punctuation handling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KoljaB committed Nov 23, 2023
1 parent 4646e96 commit a0de0c9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions RealtimeTTS/engines/coqui_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ def synthesize(self,
#text= re.sub("([^\x00-\x7F]|\w)(\.|\。|\?)",r"\1 \2",text)

try:
if text[-1] in ["."]:
if len(text) > 2 and text[-1] in ["."]:
text = text[:-1]
elif text[-1] in ["!", "?", ","]:
elif len(text) > 2 and text[-1] in ["!", "?", ","]:
text = text[:-1] + " " + text[-1]
elif text[-2] in ["."]:
elif len(text) > 3 and text[-2] in ["."]:
text = text[:-2]
elif text[-2] in ["!", "?", ","]:
elif len(text) > 3 and text[-2] in ["!", "?", ","]:
text = text[:-2] + " " + text[-2]
except Exception as e:
logging.warning (f"Error fixing sentence end punctuation: {e}, Text: \"{text}\"")
Expand Down

0 comments on commit a0de0c9

Please sign in to comment.