diff --git a/cli.py b/cli.py index f0ba6fc991ba0..002d925c2eca5 100644 --- a/cli.py +++ b/cli.py @@ -8397,6 +8397,8 @@ def _voice_speak_response(self, text: str): tts_text = re.sub(r'^\s*[-*]\s+', '', tts_text, flags=re.MULTILINE) # list items tts_text = re.sub(r'---+', '', tts_text) # horizontal rules tts_text = re.sub(r'\n{3,}', '\n\n', tts_text) # excessive newlines + # Strip emojis so TTS doesn't read out emoji descriptions + tts_text = re.sub(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F1E0-\U0001F1FF\U00002702-\U000027B0\U0000FE00-\U0000FE0F\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002600-\U000026FF\U0000200D]+', '', tts_text) tts_text = tts_text.strip() if not tts_text: return diff --git a/hermes_cli/voice.py b/hermes_cli/voice.py index 0a355ce4faadc..2429eab40bfb2 100644 --- a/hermes_cli/voice.py +++ b/hermes_cli/voice.py @@ -494,6 +494,8 @@ def speak_text(text: str) -> None: tts_text = re.sub(r'^\s*[-*]\s+', '', tts_text, flags=re.MULTILINE) # list bullets tts_text = re.sub(r'---+', '', tts_text) # horizontal rules tts_text = re.sub(r'\n{3,}', '\n\n', tts_text) # excess newlines + # Strip emojis so TTS doesn't read out emoji descriptions + tts_text = re.sub(r'[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F1E0-\U0001F1FF\U00002702-\U000027B0\U0000FE00-\U0000FE0F\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002600-\U000026FF\U0000200D]+', '', tts_text) tts_text = tts_text.strip() if not tts_text: return diff --git a/tools/tts_tool.py b/tools/tts_tool.py index 7473b32a1dcbc..32d7252b51c03 100644 --- a/tools/tts_tool.py +++ b/tools/tts_tool.py @@ -1910,6 +1910,19 @@ def _strip_markdown_for_tts(text: str) -> str: text = _MD_LIST_ITEM.sub('', text) text = _MD_HR.sub('', text) text = _MD_EXCESS_NL.sub('\n\n', text) + # Strip emojis so TTS doesn't read out emoji descriptions + text = re.sub(r'[\U0001F600-\U0001F64F' # emoticons + r'\U0001F300-\U0001F5FF' # symbols & pictographs + r'\U0001F680-\U0001F6FF' # transport & map + r'\U0001F1E0-\U0001F1FF' # flags + r'\U00002702-\U000027B0' # dingbats + r'\U0000FE00-\U0000FE0F' # variation selectors + r'\U0001F900-\U0001F9FF' # supplemental symbols + r'\U0001FA00-\U0001FA6F' # chess symbols + r'\U0001FA70-\U0001FAFF' # symbols extended-A + r'\U00002600-\U000026FF' # misc symbols + r'\U0000200D' # zero-width joiner + r']+', '', text) return text.strip()