diff --git a/inbox.py b/inbox.py index 33fa4db85..fa72339c5 100644 --- a/inbox.py +++ b/inbox.py @@ -86,6 +86,7 @@ from content import htmlReplaceQuoteMarks from speaker import speakerReplaceLinks from speaker import speakerPronounce from speaker import speakerEndpointJson +from speaker import removeEmojiFromText def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None: @@ -2201,6 +2202,7 @@ def _updateSpeaker(baseDir: str, nickname: str, domain: str, getDisplayName(baseDir, postJsonObject['actor'], personCache) if not speakerName: return + speakerName = removeEmojiFromText(speakerName) gender = getGenderFromBio(baseDir, postJsonObject['actor'], personCache, translate) if announcingActor: diff --git a/speaker.py b/speaker.py index bd14ea414..284938427 100644 --- a/speaker.py +++ b/speaker.py @@ -171,6 +171,25 @@ def _addSSMLemphasis(sayText: str) -> str: return sayText +def removeEmojiFromText(sayText: str) -> str: + """Removes :emoji: from the given text + """ + if '*' not in sayText: + return sayText + text = sayText + for ch in speakerRemoveChars: + text = text.replace(ch, ' ') + wordsList = text.split(' ') + replacements = {} + for word in wordsList: + if word.startswith(':'): + if word.endswith(':'): + replacements[word] = word.replace('*', '') + for replaceStr, newStr in replacements.items(): + sayText = sayText.replace(replaceStr, newStr) + return sayText.replace(' ', ' ').strip() + + def getSpeakerFromServer(baseDir: str, session, nickname: str, password: str, domain: str, port: int,