Added option to remove emojis from TTS (#1380)

Thank you @Chizaruu!
This commit is contained in:
Chizaruu authored and GitHub committed 2022-12-19 18:41:42 +01:00
1 parent e30eaf7594
commit 48109f5318
3 files changed
+12 -1

No files matched your search

+3 -1
View File
@@ -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
+1
View File
@@ -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" }
+8
View File
@@ -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())