Added option to remove emojis from TTS (#1380)

Thank you @Chizaruu!
pull/1296/head
Chizaruu 2 years ago committed by GitHub
parent e30eaf7594
commit 48109f5318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,4 +14,6 @@ pyttsx3==2.90
Pillow~=9.3.0
tomlkit==0.11.4
Flask==2.2.2
spacy==3.4.1
clean-text==0.6.0
unidecode==1.3.2
spacy==3.4.1

@ -43,3 +43,4 @@ tiktok_voice = { optional = true, default = "en_us_006", example = "en_us_006",
python_voice = { optional = true, default = "1", example = "1", explanation = "The index of the system tts voices (can be downloaded externally, run ptt.py to find value, start from zero)" }
py_voice_num = { optional = true, default = "2", example = "2", explanation = "The number of system voices (2 are pre-installed in Windows)" }
silence_duration = { optional = true, example = "0.1", explanation = "Time in seconds between TTS comments", default = 0.3, type = "float" }
no_emojis = { optional = false, type = "bool", default = false, example = false, options = [true, false,], explanation = "Whether to remove emojis from the comments" }

@ -6,6 +6,9 @@ from time import sleep
from requests import Response
from utils import settings
from cleantext import clean
if sys.version_info[0] >= 3:
from datetime import timezone
@ -86,5 +89,10 @@ def sanitize_text(text: str) -> str:
regex_expr = r"\s['|]|['|]\s|[\^_~@!&;#:\-%—“”‘\"%\*/{}\[\]\(\)\\|<>=+]"
result = re.sub(regex_expr, " ", result)
result = result.replace("+", "plus").replace("&", "and")
# emoji removal if the setting is enabled
if settings.config["settings"]["tts"]["no_emojis"]:
result = clean(result, no_emoji=True)
# remove extra whitespace
return " ".join(result.split())

Loading…
Cancel
Save