rhasspy / piper

A fast, local neural text to speech system
https://rhasspy.github.io/piper-samples/
MIT License
6.25k stars 459 forks source link

Filter out certain Characters when speaking #565

Open krisf12 opened 2 months ago

krisf12 commented 2 months ago

I have Piper in home assistant speaking out the weather but it always speaks out "asterisk" when there is a * in the response. Is there a way to filter this out or can this be added in a future update?

Thanks!

odproductor commented 1 month ago

Filter and delete the string: (Python)

def clean_text(text): emoji_pattern = re.compile( '[' '\U0001F600-\U0001F64F' # Emojis '\U0001F300-\U0001F5FF' # '\U0001F680-\U0001F6FF' # '\U0001F700-\U0001F77F' # '\U0001F780-\U0001F7FF' # '\U0001F800-\U0001F8FF' # '\U0001F900-\U0001F9FF' # '\U0001FA00-\U0001FA6F' # '\U0001FA70-\U0001FAFF' # '\u2600-\u26FF' # '\u2700-\u27BF' # '\u2300-\u23FF' # '\u2B50' # ']+', flags=re.UNICODE)

text_without_emojis = emoji_pattern.sub(r'', text)

text_cleaned = re.sub(r'[^a-zA-Z0-9\s]', '', text_without_emojis)

return text_cleaned