Move phoneme compuataion to __init__ and put char list to symbols.py

This commit is contained in:
Eren Golge
2019-01-16 12:07:33 +01:00
parent da2f064bc5
commit df49e93684
3 changed files with 67 additions and 66 deletions
+15 -1
View File
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
import re
import epitran
from utils.text import cleaners
from utils.text.symbols import symbols, phonemes, _punctuations
from utils.text.cmudict import text2phone
# Mappings from symbol to numeric ID and vice versa:
_symbol_to_id = {s: i for i, s in enumerate(symbols)}
@@ -15,7 +15,21 @@ _id_to_phonemes = {i: s for i, s in enumerate(phonemes)}
# Regular expression matching text enclosed in curly braces:
_curly_re = re.compile(r'(.*?)\{(.+?)\}(.*)')
# phoneme converter
epi = epitran.Epitran('eng-Latn')
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