style and linter fixes

This commit is contained in:
Eren Gölge 2021-04-26 15:22:24 +02:00
parent 4cf211348d
commit b82daa5e86
3 changed files with 8 additions and 4 deletions

View File

@ -429,11 +429,13 @@ class AudioProcessor(object):
def dequantize(x, bits): def dequantize(x, bits):
return 2 * x / (2 ** bits - 1) - 1 return 2 * x / (2 ** bits - 1) - 1
def _log(x, base): def _log(x, base):
if base == 10: if base == 10:
return np.log10(x) return np.log10(x)
return np.log(x) return np.log(x)
def _exp(x, base): def _exp(x, base):
if base == 10: if base == 10:
return np.power(10, x) return np.power(10, x)

View File

@ -38,6 +38,8 @@ class Synthesizer(object):
If you have certain special characters in your text, you need to handle If you have certain special characters in your text, you need to handle
them before providing the text to Synthesizer. them before providing the text to Synthesizer.
TODO: set the segmenter based on the source language
Args: Args:
tts_checkpoint (str): path to the tts model file. tts_checkpoint (str): path to the tts model file.
tts_config_path (str): path to the tts config file. tts_config_path (str): path to the tts config file.
@ -152,7 +154,7 @@ class Synthesizer(object):
if use_cuda: if use_cuda:
self.vocoder_model.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. """Split give text into sentences.
Args: Args:
@ -187,7 +189,7 @@ class Synthesizer(object):
""" """
start_time = time.time() start_time = time.time()
wavs = [] wavs = []
sens = self._split_into_sentences(text) sens = self.split_into_sentences(text)
print(" > Text splitted to sentences.") print(" > Text splitted to sentences.")
print(sens) print(sens)

View File

@ -35,8 +35,8 @@ class SynthesizerTest(unittest.TestCase):
def test_split_into_sentences(self): def test_split_into_sentences(self):
"""Check demo server sentences split as expected""" """Check demo server sentences split as expected"""
print("\n > Testing demo server sentence splitting") print("\n > Testing demo server sentence splitting")
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init, protected-access
self.seg = Synthesizer.get_segmenter("en") self.seg = Synthesizer._get_segmenter("en")
sis = Synthesizer.split_into_sentences sis = Synthesizer.split_into_sentences
assert sis(self, "Hello. Two sentences") == ["Hello.", "Two 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.") == [ assert sis(self, "He went to meet the adviser from Scott, Waltman & Co. next morning.") == [