-
Notifications
You must be signed in to change notification settings - Fork 8
Prevent emojis from being spoken aloud by avatar #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||||||||
| import re | ||||||||||||||||
| from typing import Any, Mapping | ||||||||||||||||
|
|
||||||||||||||||
| from pipecat.utils.text.base_text_filter import BaseTextFilter | ||||||||||||||||
|
|
||||||||||||||||
| _EMOJI_RE = re.compile( | ||||||||||||||||
| "[" | ||||||||||||||||
| "\U0001F600-\U0001F64F" | ||||||||||||||||
| "\U0001F300-\U0001F5FF" | ||||||||||||||||
| "\U0001F680-\U0001F6FF" | ||||||||||||||||
| "\U0001F1E0-\U0001F1FF" | ||||||||||||||||
| "\U00002600-\U000026FF" | ||||||||||||||||
| "\U00002700-\U000027BF" | ||||||||||||||||
| "\U0000FE00-\U0000FE0F" | ||||||||||||||||
| "\U0001F900-\U0001F9FF" | ||||||||||||||||
| "\U0001FA70-\U0001FAFF" | ||||||||||||||||
| "\U00002300-\U000023FF" | ||||||||||||||||
| "\U00002B50-\U00002B55" | ||||||||||||||||
| "\U0001F004" | ||||||||||||||||
| "\U0001F0CF" | ||||||||||||||||
| "]+", | ||||||||||||||||
| flags=re.UNICODE, | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class EmojiTextFilter(BaseTextFilter): | ||||||||||||||||
| """Strips emoji characters from text before TTS synthesis.""" | ||||||||||||||||
|
|
||||||||||||||||
| async def update_settings(self, settings: Mapping[str, Any]): | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| async def filter(self, text: str) -> str: | ||||||||||||||||
| return _EMOJI_RE.sub("", text).strip() | ||||||||||||||||
|
Comment on lines
+32
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing emojis with an empty string can lead to double spaces in the middle of sentences (e.g.,
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| async def handle_interruption(self): | ||||||||||||||||
| pass | ||||||||||||||||
|
|
||||||||||||||||
| async def reset_interruption(self): | ||||||||||||||||
| pass | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current regex for identifying emojis is missing several important ranges and special characters. Specifically, it does not include the Zero Width Joiner (
\u200D), which is frequently used in complex emoji sequences (like family or profession emojis), nor does it cover combining characters like the keycap symbol (\u20E3). Additionally, many symbols in the\U0001F000-\U0001F2FFrange (Mahjong, Dominoes, Playing Cards, Enclosed Alphanumeric/Ideographic Supplements) are omitted. Consider using a more comprehensive range or adding these specific characters to prevent them from being read aloud by the TTS engine.