From c754ca89de7ac8831380d5f8e791a7114448f16b Mon Sep 17 00:00:00 2001 From: Eren Golge Date: Fri, 4 Jan 2019 16:18:49 +0100 Subject: [PATCH] Move phoneme compuataion to __init__ and put char list to symbols.py --- utils/text/__init__.py | 12 ++++++++++++ utils/text/cmudict.py | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/utils/text/__init__.py b/utils/text/__init__.py index f857de4a..35e8713b 100644 --- a/utils/text/__init__.py +++ b/utils/text/__init__.py @@ -67,6 +67,18 @@ def sequence_to_phoneme(sequence): return result.replace('}{', ' ') + +def text2phone(text): + ''' + Convert graphemes to phonemes. + ''' + try: + ph = epi.trans_list(text, normpunc=True) + except: + ph = None + return ph + + def phoneme_to_sequence(text, cleaner_names): ''' TODO: This ignores punctuations diff --git a/utils/text/cmudict.py b/utils/text/cmudict.py index 5fc3bcca..1202bf3d 100644 --- a/utils/text/cmudict.py +++ b/utils/text/cmudict.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- import re -import epitran -epi = epitran.Epitran('eng-Latn') # valid_symbols = [ # 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1',