This commit is contained in:
Brandon Thomas
2022-07-04 00:40:12 -04:00
parent 1bfc4f9959
commit 7529181864
5 changed files with 42 additions and 32 deletions
@@ -1,4 +1,5 @@
from typing import List
from tts.text.input_parsing.parser import ArpabetSequence, GraphemeSequence, ParsedSequence
from tts.text.phonetization.base_phonetization import BasePhonetization
from tts.text.phonetization.cmudict import CMUDict
@@ -7,7 +8,7 @@ class EnglishPhonetization(BasePhonetization):
def __init__(self, phoneme_dictionary: CMUDict):
super().__init__(phoneme_dictionary)
def try_convert_to_phonemes(self, grapheme_sequence: str) -> List[str]:
def try_convert_to_phonemes(self, grapheme_sequence: str) -> ParsedSequence:
"""
Attempt to enrich a grapheme sequence with phonemes where word lookup succeeds.
Grapheme symbols will be left in place.
@@ -21,9 +22,9 @@ class EnglishPhonetization(BasePhonetization):
if maybe_phonemes:
# NB: Dictionary returns a list of possible matches.
# We'll just use the first.
converted_words.append(maybe_phonemes[0])
converted_words.append(ArpabetSequence(maybe_phonemes[0]))
else:
# TODO: Use g2p prediction to predict the phonemes.
converted_words.append(word)
converted_words.append(GraphemeSequence(word))
return converted_words