Skip to content

Commit

Permalink
feat/optional_g2p (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Jul 4, 2023
1 parent 8e5b3c5 commit aeb765c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ovos_plugin_manager/templates/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,13 @@ def __init__(self, lang="en-us", config=None, validator=None,
cfg["g2p"]["module"] = g2pm
else:
LOG.warning(f"TTS selected {g2pm}, but it is not available!")
self.g2p = OVOSG2PFactory.create(cfg)

try:
self.g2p = OVOSG2PFactory.create(cfg)
except:
LOG.exception("G2P plugin not loaded, there will be no mouth movements")
self.g2p = None

self.cache.curate()

self.add_metric({"metric_type": "tts.init"})
Expand Down Expand Up @@ -744,10 +750,10 @@ def _execute(self, sentence, ident, listen, **kwargs):
audio_file, phonemes = self.synth(sentence, **kwargs)

# get visemes/mouth movements
viseme = []
if phonemes:
viseme = self.viseme(phonemes)
else:
viseme = []
elif self.g2p is not None:
try:
viseme = self.g2p.utterance2visemes(sentence, lang)
except OutOfVocabulary:
Expand Down Expand Up @@ -811,7 +817,7 @@ def synth(self, sentence, **kwargs):

def _cache_phonemes(self, sentence, phonemes=None, sentence_hash=None):
sentence_hash = sentence_hash or hash_sentence(sentence)
if not phonemes:
if not phonemes and self.g2p is not None:
try:
phonemes = self.g2p.utterance2arpa(sentence, self.lang)
self.add_metric({"metric_type": "tts.phonemes.g2p"})
Expand Down

0 comments on commit aeb765c

Please sign in to comment.