From 51d7ad161c47748db417c2d970fbf97e5dab21e9 Mon Sep 17 00:00:00 2001 From: Jindrich Matousek Date: Wed, 6 Apr 2022 14:37:51 +0200 Subject: [PATCH] Better WA for glottal stop: now works also for multiple sentences in a single input text --- TTS/utils/synthesizer.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/TTS/utils/synthesizer.py b/TTS/utils/synthesizer.py index 392531a6..4007931b 100644 --- a/TTS/utils/synthesizer.py +++ b/TTS/utils/synthesizer.py @@ -156,12 +156,20 @@ class Synthesizer(object): List[str]: list of sentences. """ # JMa - # WA: fix glottal stop (!): "ahoj, !", "ahoj." => "ahoj, !ahoj." - # Exclamation mark (!) at the end of the sentence should not be affected. - # return self.seg.segment(text) - sents = self.seg.segment(text) - split_text = " ".join(sents) - return [split_text.replace("! ", "!")] + if "!" in self.tts_config.characters.characters: + # Our proprietary phonetic mode enabled: the input text is assumed + # to be a sequence of phones plus punctuations (without "!") and pauses (#, $). + # (!) is a regular character, not a punctuation + # WA: Glottal stop [!] is temporarily replaced with [*] to prevent + # boundary detection. + # + # Example: "!ahoj, !adame." -> ["!ahoj, !", "adame."] + # Fix: "!ahoj, !adame." -> ["!ahoj, !adame."] + text = text.replace("!", "*") + sents = self.seg.segment(text) + return [s.replace("*", "!") for s in sents] + else: # Original code + return self.seg.segment(text) def save_wav(self, wav: List[int], path: str) -> None: """Save the waveform as a file.