Files
RedditVideoMakerBot/utils/posttextparser.py
T
Simon 0ea74e43f1 Version 3.2
The RedditVideoMakerBot has been updated to version 3.2, bringing exciting new features and bug fixes. Introducing **ElevenLabs TTS** for high-quality audio. Enjoy **background audio** and **random voices per comment**. Run the bot with one click using the **bat file**. Use the **zoom setting** for bigger text. Bug fixes include video downloader improvements, random story mode fix, updated dependencies, code optimizations, text size adjustments, enhanced Reddit credentials validation, and translator fixes. Enjoy the new features and **thanks to all contributors**!
2023-05-28 16:05:41 +02:00

35 lines
835 B
Python

import os
import re
import time
from typing import List
import spacy
from utils.console import print_step
from utils.voice import sanitize_text
# working good
def posttextparser(obj, *, tried: bool = False) -> List[str]:
text: str = re.sub("\n", " ", obj)
try:
nlp = spacy.load("en_core_web_sm")
except OSError as e:
if not tried:
os.system("python -m spacy download en_core_web_sm")
time.sleep(5)
return posttextparser(obj, tried=True)
print_step(
"The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm ")
raise e
doc = nlp(text)
newtext: list = []
for line in doc.sents:
if sanitize_text(line.text):
newtext.append(line.text)
return newtext