diff --git a/TTS/utils/audio.py b/TTS/utils/audio.py index c476065d..609eab0a 100644 --- a/TTS/utils/audio.py +++ b/TTS/utils/audio.py @@ -429,11 +429,13 @@ class AudioProcessor(object): def dequantize(x, bits): return 2 * x / (2 ** bits - 1) - 1 + def _log(x, base): if base == 10: return np.log10(x) return np.log(x) + def _exp(x, base): if base == 10: return np.power(10, x) diff --git a/TTS/utils/synthesizer.py b/TTS/utils/synthesizer.py index 3753c121..b1ae968d 100644 --- a/TTS/utils/synthesizer.py +++ b/TTS/utils/synthesizer.py @@ -38,6 +38,8 @@ class Synthesizer(object): If you have certain special characters in your text, you need to handle them before providing the text to Synthesizer. + TODO: set the segmenter based on the source language + Args: tts_checkpoint (str): path to the tts model file. tts_config_path (str): path to the tts config file. @@ -152,7 +154,7 @@ class Synthesizer(object): if use_cuda: self.vocoder_model.cuda() - def _split_into_sentences(self, text) -> List[str]: + def split_into_sentences(self, text) -> List[str]: """Split give text into sentences. Args: @@ -187,7 +189,7 @@ class Synthesizer(object): """ start_time = time.time() wavs = [] - sens = self._split_into_sentences(text) + sens = self.split_into_sentences(text) print(" > Text splitted to sentences.") print(sens) diff --git a/tests/test_synthesizer.py b/tests/test_synthesizer.py index 46b9ab74..aa06a6f0 100644 --- a/tests/test_synthesizer.py +++ b/tests/test_synthesizer.py @@ -35,8 +35,8 @@ class SynthesizerTest(unittest.TestCase): def test_split_into_sentences(self): """Check demo server sentences split as expected""" print("\n > Testing demo server sentence splitting") - # pylint: disable=attribute-defined-outside-init - self.seg = Synthesizer.get_segmenter("en") + # pylint: disable=attribute-defined-outside-init, protected-access + self.seg = Synthesizer._get_segmenter("en") sis = Synthesizer.split_into_sentences assert sis(self, "Hello. Two sentences") == ["Hello.", "Two sentences"] assert sis(self, "He went to meet the adviser from Scott, Waltman & Co. next morning.") == [