From 995eb1bf074caae257a87f5ef54ae5f63617b227 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Thu, 13 Feb 2020 16:03:30 +0100 Subject: [PATCH] Fix bug where sometimes the second sentence disappears if it doesn't end with punctuation --- server/synthesizer.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/synthesizer.py b/server/synthesizer.py index 455bd332..1082b73a 100644 --- a/server/synthesizer.py +++ b/server/synthesizer.py @@ -122,7 +122,7 @@ class Synthesizer(object): self.ap.save_wav(wav, path) def split_into_sentences(self, text): - text = " " + text + " " + text = " " + text + " " text = text.replace("\n", " ") text = re.sub(prefixes, "\\1", text) text = re.sub(websites, "\\1", text) @@ -149,15 +149,13 @@ class Synthesizer(object): text = text.replace("", ".") sentences = text.split("") 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)