From e40bc18c84ba16456ad9f3f7529f76ffc568b6b2 Mon Sep 17 00:00:00 2001 From: erogol Date: Thu, 13 Feb 2020 17:23:37 +0100 Subject: [PATCH] fix linter problems and loader test --- tests/test_loader.py | 4 +--- tests/test_text_processing.py | 4 ++-- utils/text/__init__.py | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/test_loader.py b/tests/test_loader.py index 751bc181..d8727895 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -137,9 +137,7 @@ class TestTTSDataset(unittest.TestCase): # NOTE: Below needs to check == 0 but due to an unknown reason # there is a slight difference between two matrices. # TODO: Check this assert cond more in detail. - assert abs((abs(mel.T) - - abs(mel_dl) - ).sum()) < 1e-5, (abs(mel.T) - abs(mel_dl)).sum() + assert abs(mel.T - mel_dl).max() < 1e-5, abs(mel.T - mel_dl).max() # check mel-spec correctness mel_spec = mel_input[0].cpu().numpy() diff --git a/tests/test_text_processing.py b/tests/test_text_processing.py index 0ecb9962..aa17f694 100644 --- a/tests/test_text_processing.py +++ b/tests/test_text_processing.py @@ -71,5 +71,5 @@ def test_text2phone(): text = "Recent research at Harvard has shown meditating for as little as 8 weeks can actually increase, the grey matter in the parts of the brain responsible for emotional regulation and learning!" gt = "ɹ|iː|s|ə|n|t| |ɹ|ɪ|s|ɜː|tʃ| |æ|t| |h|ɑːɹ|v|ɚ|d| |h|ɐ|z| |ʃ|oʊ|n| |m|ɛ|d|ᵻ|t|eɪ|ɾ|ɪ|ŋ| |f|ɔː|ɹ| |æ|z| |l|ɪ|ɾ|əl| |æ|z| |eɪ|t| |w|iː|k|s| |k|æ|n| |æ|k|tʃ|uː|əl|i| |ɪ|n|k|ɹ|iː|s|,| |ð|ə| |ɡ|ɹ|eɪ| |m|æ|ɾ|ɚ|ɹ| |ɪ|n|ð|ə| |p|ɑːɹ|t|s| |ʌ|v|ð|ə| |b|ɹ|eɪ|n| |ɹ|ɪ|s|p|ɑː|n|s|ə|b|əl| |f|ɔː|ɹ| |ɪ|m|oʊ|ʃ|ə|n|əl| |ɹ|ɛ|ɡ|j|uː|l|eɪ|ʃ|ə|n| |æ|n|d| |l|ɜː|n|ɪ|ŋ|!" lang = "en-us" - phonemes = text2phone(text, lang) - assert gt == phonemes, f"\n{phonemes} \n vs \n{gt}" + ph = text2phone(text, lang) + assert gt == ph, f"\n{phonemes} \n vs \n{gt}" diff --git a/utils/text/__init__.py b/utils/text/__init__.py index e6842dfa..0e6684d2 100644 --- a/utils/text/__init__.py +++ b/utils/text/__init__.py @@ -38,10 +38,7 @@ def text2phone(text, language): if text[-1] == punctuations[-1]: for punct in punctuations[:-1]: ph = ph.replace('| |\n', '|'+punct+'| |', 1) - try: ph = ph + punctuations[-1] - except: - print(text) else: for punct in punctuations: ph = ph.replace('| |\n', '|'+punct+'| |', 1)