Skip to content

Commit

Permalink
Fix bug where sometimes the second sentence disappears if it doesn't …
Browse files Browse the repository at this point in the history
…end with punctuation
  • Loading branch information
reuben authored and erogol committed Feb 19, 2020
1 parent bfd45a8 commit 846d147
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions server/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def save_wav(self, wav, path):
self.ap.save_wav(wav, path)

def split_into_sentences(self, text):
text = " " + text + " "
text = " " + text + " <stop>"
text = text.replace("\n", " ")
text = re.sub(prefixes, "\\1<prd>", text)
text = re.sub(websites, "<prd>\\1", text)
Expand All @@ -149,15 +149,13 @@ def split_into_sentences(self, text):
text = text.replace("<prd>", ".")
sentences = text.split("<stop>")
sentences = sentences[:-1]
sentences = [s.strip() for s in sentences]
sentences = list(filter(None, [s.strip() for s in sentences])) # remove empty sentences
return sentences

def tts(self, text):
wavs = []
sens = self.split_into_sentences(text)
print(sens)
if not sens:
sens = [text+'.']
for sen in sens:
# preprocess the given text
inputs = text_to_seqvec(sen, self.tts_config, self.use_cuda)
Expand Down

0 comments on commit 846d147

Please sign in to comment.