From a0eee8862b2091057aefa21eed2a540cc73ab451 Mon Sep 17 00:00:00 2001 From: Steve Penrod Date: Wed, 26 Sep 2018 23:54:23 -0500 Subject: [PATCH] Use the phonetic_spellings.txt in Mimic2 The "phonetic_spellings.txt" mechanism converts odd words to strings that represent what they should sound like when spoken. For example, "mycroftai" to "Mycroft A.I.". This provides an easy mechanism to provide hints to lots of Text to Speech engines. This adds it to Mimic2, along with a spelling of "corgi". --- mycroft/res/text/en-us/phonetic_spellings.txt | 1 + mycroft/tts/mimic2_tts.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/mycroft/res/text/en-us/phonetic_spellings.txt b/mycroft/res/text/en-us/phonetic_spellings.txt index ac4f4a253d..dfa3cb9a67 100644 --- a/mycroft/res/text/en-us/phonetic_spellings.txt +++ b/mycroft/res/text/en-us/phonetic_spellings.txt @@ -2,3 +2,4 @@ jalepeno: hallipeenyo ai: A.I. mycroftai: mycroft A.I. spotify: spot-ify +corgi: core-gee diff --git a/mycroft/tts/mimic2_tts.py b/mycroft/tts/mimic2_tts.py index 7799157352..422c8f363a 100644 --- a/mycroft/tts/mimic2_tts.py +++ b/mycroft/tts/mimic2_tts.py @@ -279,6 +279,14 @@ class Mimic2(TTS): create_signal("isSpeaking") sentence = self._normalized_numbers(sentence) + + # Use the phonetic_spelling mechanism from the TTS base class + if self.phonetic_spelling: + for word in re.findall(r"[\w']+", sentence): + if word.lower() in self.spellings: + sentence = sentence.replace(word, + self.spellings[word.lower()]) + chunks = sentence_chunker(sentence, self.chunk_size) for idx, req in enumerate(self._requests(chunks)): results = req.result().json()