mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-27 08:58:13 +00:00
Add sequencing, improvements to pipeline
This commit is contained in:
@@ -4,6 +4,8 @@ Contents of this file are mostly from https://github.com/keithito/tacotron
|
||||
|
||||
import re
|
||||
|
||||
# TODO: Don't use strings for arpabet phoneme representation, and share the memory.
|
||||
|
||||
# Relative to TTS codebase root
|
||||
# This does not include any CMUDict extensions or alternatives (eg. for other languages).
|
||||
DEFAULT_CMUDICT_PATH = 'dictionaries/cmudict-0.7b'
|
||||
|
||||
@@ -7,7 +7,12 @@ class EnglishPhonetization(BasePhonetization):
|
||||
def __init__(self, phoneme_dictionary: CMUDict):
|
||||
super().__init__(phoneme_dictionary)
|
||||
|
||||
def convert_to_phonemes(self, grapheme_sequence: str) -> List[str]:
|
||||
def try_convert_to_phonemes(self, grapheme_sequence: str) -> List[str]:
|
||||
"""
|
||||
Attempt to enrich a grapheme sequence with phonemes where word lookup succeeds.
|
||||
Grapheme symbols will be left in place.
|
||||
The output list will need to be space-separated before inference.
|
||||
"""
|
||||
words = self._split_grapheme_sentence_to_words(grapheme_sequence)
|
||||
converted_words = []
|
||||
|
||||
|
||||
@@ -6,27 +6,27 @@ class TestEnglishPhonetization:
|
||||
def test_no_input(self):
|
||||
phoneme_dictionary = CMUDict(DEFAULT_CMUDICT_PATH)
|
||||
phonetization = EnglishPhonetization(phoneme_dictionary)
|
||||
output = phonetization.convert_to_phonemes("")
|
||||
output = phonetization.try_convert_to_phonemes("")
|
||||
assert output == []
|
||||
|
||||
def test_all_words_in_dictionary(self):
|
||||
phoneme_dictionary = CMUDict(DEFAULT_CMUDICT_PATH)
|
||||
phonetization = EnglishPhonetization(phoneme_dictionary)
|
||||
output = phonetization.convert_to_phonemes("this is a test")
|
||||
output = phonetization.try_convert_to_phonemes("this is a test")
|
||||
assert output == ["DH IH1 S", "IH1 Z", "AH0", "T EH1 S T"]
|
||||
|
||||
def test_most_words_in_dictionary(self):
|
||||
phoneme_dictionary = CMUDict(DEFAULT_CMUDICT_PATH)
|
||||
phonetization = EnglishPhonetization(phoneme_dictionary)
|
||||
output = phonetization.convert_to_phonemes("nonword is a test")
|
||||
output = phonetization.try_convert_to_phonemes("nonword is a test")
|
||||
assert output == ["nonword", "IH1 Z", "AH0", "T EH1 S T"]
|
||||
|
||||
def test_punctuation(self):
|
||||
phoneme_dictionary = CMUDict(DEFAULT_CMUDICT_PATH)
|
||||
phonetization = EnglishPhonetization(phoneme_dictionary)
|
||||
output = phonetization.convert_to_phonemes("this...")
|
||||
output = phonetization.try_convert_to_phonemes("this...")
|
||||
assert output == ["DH IH1 S", "..."]
|
||||
output = phonetization.convert_to_phonemes("this!")
|
||||
output = phonetization.try_convert_to_phonemes("this!")
|
||||
assert output == ["DH IH1 S", "!"]
|
||||
output = phonetization.convert_to_phonemes("this?")
|
||||
output = phonetization.try_convert_to_phonemes("this?")
|
||||
assert output == ["DH IH1 S", "?"]
|
||||
|
||||
Reference in New Issue
Block a user