@@ -217,7 +217,9 @@ def __init__(self, lang="en-us", config=None, validator=None,
217217 self .log_timestamps = self .config .get ("log_timestamps" , False )
218218
219219 self .voice = self .config .get ("voice" )
220- self .filename = get_temp_path ('tts.' + self .audio_ext )
220+ # TODO can self.filename be deprecated ? is it used anywhere at all?
221+ cache_dir = get_cache_directory (self .tts_name )
222+ self .filename = join (cache_dir , 'tts.' + self .audio_ext )
221223 self .enclosure = None
222224 random .seed ()
223225 self .queue = Queue ()
@@ -405,13 +407,16 @@ def execute(self, sentence, ident=None, listen=False, **kwargs):
405407 # Re-raise to allow the Exception to be handled externally as well.
406408 raise
407409
408- def _execute (self , sentence , ident , listen , ** kwargs ):
410+ def _replace_phonetic_spellings (self , sentence ):
409411 if self .phonetic_spelling :
410412 for word in re .findall (r"[\w']+" , sentence ):
411413 if word .lower () in self .spellings :
412- sentence = sentence .replace (word ,
413- self .spellings [word .lower ()])
414+ spelled = self .spellings [word .lower ()]
415+ sentence = sentence .replace (word , spelled )
416+ return sentence
414417
418+ def _execute (self , sentence , ident , listen , ** kwargs ):
419+ sentence = self ._replace_phonetic_spellings (sentence )
415420 chunks = self ._preprocess_sentence (sentence )
416421 # Apply the listen flag to the last chunk, set the rest to False
417422 chunks = [(chunks [i ], listen if i == len (chunks ) - 1 else False )
@@ -456,7 +461,7 @@ def _synth(self, sentence_hash, sentence, **kwargs):
456461 # NOTE: this is ovos only functionality, not in mycroft-core!
457462 lang = kwargs .get ("lang" )
458463 if not lang and kwargs .get ("message" ):
459- # some plugins accept a message object
464+ # get lang from message object if possible
460465 try :
461466 lang = kwargs ["message" ].data .get ("lang" ) or \
462467 kwargs ["message" ].context .get ("lang" )
0 commit comments