many changes

good ones
pull/915/head
anthony lloyd 3 years ago
parent 969f449961
commit a533c6c0d6

@ -96,26 +96,33 @@ class TTSEngine:
idy = None
for idy, text_cut in enumerate(split_text):
#print(f"{idx}-{idy}: {text_cut}\n")
self.call_tts(f"{idx}-{idy}.part", text_cut)
with open(f"{self.path}/list.txt", 'w') as f:
for newy in range(0, len(split_text)):
f.write("file " + f"'{idx}-{newy}.part.mp3'"+"\n")
f.write("file " + f"'long_silence.mp3'"+"\n")
os.system("ffmpeg -f concat -y -hide_banner -loglevel panic -safe 0 " +
"-i " + f"{self.path}/list.txt " +
"-c copy " + f"{self.path}/{idx}.mp3")
for i in range(0, idy + 1):
# print(f"Cleaning up {self.path}/{idx}-{i}.part.mp3")
Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
print(f"{idx}-{idy}: {text_cut}\n")
newtext = process_text(text_cut)
#print(newtext)
if not newtext or newtext.isspace():
print("fuck you")
break
else:
self.call_tts(f"{idx}-{idy}.part", newtext)
with open(f"{self.path}/list.txt", 'w') as f:
for newy in range(0, len(split_text)):
f.write("file " + f"'{idx}-{newy}.part.mp3'" + "\n")
f.write("file " + f"'long_silence.mp3'" + "\n")
os.system("ffmpeg -f concat -y -hide_banner -loglevel panic -safe 0 " +
"-i " + f"{self.path}/list.txt " +
"-c copy " + f"{self.path}/{idx}.mp3")
try:
for i in range(0, idy + 1):
# print(f"Cleaning up {self.path}/{idx}-{i}.part.mp3")
Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
except FileNotFoundError:
print("file not found error")
def call_tts(self, filename: str, text: str):
if filename == "title":
self.tts_module.run(text=process_text(text), filepath=f"{self.path}/title_nosilence.mp3")
self.tts_module.run(text, filepath=f"{self.path}/title_nosilence.mp3")
silence_long = AudioClip(make_frame=lambda t: np.sin(440 * 2 * np.pi * t), duration=0.3,

@ -7,6 +7,7 @@ from praw.models import MoreComments
from utils.console import print_step, print_substep
from utils.subreddit import get_subreddit_undone
from utils.videos import check_done
from utils.voice import sanitize_text
def get_subreddit_threads(POST_ID: str):
@ -105,6 +106,10 @@ def get_subreddit_threads(POST_ID: str):
continue
if top_level_comment.body in ["[removed]", "[deleted]"]:
continue # # see https://github.com/JasonLovesDoggo/RedditVideoMakerBot/issues/78
#print(sanitize_text(top_level_comment.body))
if not sanitize_text(top_level_comment.body)or sanitize_text(top_level_comment.body).isspace():
print("fuck you")
continue # # see https://github.com/JasonLovesDoggo/RedditVideoMakerBot/issues/78
if not top_level_comment.stickied:
if len(top_level_comment.body) <= int(
settings.config["reddit"]["thread"]["max_comment_length"]

@ -73,15 +73,21 @@ def sanitize_text(text: str) -> str:
Returns:
str: Sanitized text
"""
#text.join("—-")
# remove any urls from the text
regex_urls = r"((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*"
result = re.sub(regex_urls, "url", text)
result = re.sub(regex_urls, "", text)
# note: not removing apostrophes
regex_expr = r"\s['|]|['|]\s|[\^_~@!&;#:\-%—“”‘\"%\*/{}\[\]\(\)\\|<>=+]"
regex_expr = r"\s['|]|['|]\s|[\^_~@!&;#:\%“”‘\"%\*/{}\[\]\(\)\\|<>=+]"
regex_expr2 = r""
regex_expr3 = r""
regex_expr4 = r"-"
result = re.sub(regex_expr, " ", result)
result = re.sub(regex_expr2, " ", result)
result = re.sub(regex_expr3, " ", result)
result = re.sub(regex_expr4, " ", result)
result = result.replace("+", "plus").replace("&", "and")
# remove extra whitespace
return " ".join(result.split())

@ -1 +1,82 @@
[]
[
{
"subreddit": "askreddit",
"id": "ablzuq",
"time": "1657556410",
"background_credit": "bbswitzer",
"reddit_title": "People who havent pooped in 2019 yet why are you still holding on to last years shit",
"filename": "People who havent pooped in 2019 yet why are you still holding on to last years shit.mp4"
},
{
"subreddit": "askreddit",
"id": "l7530r",
"time": "1657556683",
"background_credit": "bbswitzer",
"reddit_title": "How would you feel about Reddit adding 3 NSFW filters to distinguish between porn gore and repetitive posts asking how you would feel about Reddit adding 2 NSFW filters to distinguish between porn and gore",
"filename": "How would you feel about Reddit adding 3 NSFW filters to distinguish between porn gore and repetitive posts asking how you would feel about .mp4"
},
{
"subreddit": "askreddit",
"id": "f08dxb",
"time": "1657556794",
"background_credit": "bbswitzer",
"reddit_title": "Would you watch a show where a billionaire CEO has to go an entire month on their lowest paid employees salary without access to any other resources than that of the employee What do you think would happen",
"filename": "Would you watch a show where a billionaire CEO has to go an entire month on their lowest paid employees salary without access to any other r.mp4"
},
{
"subreddit": "askreddit",
"id": "iwedc5",
"time": "1657557328",
"background_credit": "bbswitzer",
"reddit_title": "What if God came down one day and said Its pronounced Jod then left",
"filename": "What if God came down one day and said Its pronounced Jod then left.mp4"
},
{
"subreddit": "askreddit",
"id": "draola",
"time": "1657557575",
"background_credit": "bbswitzer",
"reddit_title": "How would you feel about a feature where if someone upvotes a crosspost the original post is upvoted automatically",
"filename": "How would you feel about a feature where if someone upvotes a crosspost the original post is upvoted automatically.mp4"
},
{
"subreddit": "askreddit",
"id": "kr8op6",
"time": "1657558076",
"background_credit": "bbswitzer",
"reddit_title": "How would you feel about a if you accidentally scroll to the top you can go back to where you were button for Reddit",
"filename": "How would you feel about a if you accidentally scroll to the top you can go back to where you were button for Reddit.mp4"
},
{
"subreddit": "askreddit",
"id": "9whgf4",
"time": "1657558661",
"background_credit": "bbswitzer",
"reddit_title": "Stan Lee has passed away at 95 years old",
"filename": "Stan Lee has passed away at 95 years old.mp4"
},
{
"subreddit": "askreddit",
"id": "9gx68l",
"time": "1657558799",
"background_credit": "bbswitzer",
"reddit_title": "Reddit how would you feel about a law that bans radio stations from playing commercials with honkingbeepingsiren noises in them",
"filename": "Reddit how would you feel about a law that bans radio stations from playing commercials with honkingbeepingsiren noises in them.mp4"
},
{
"subreddit": "askreddit",
"id": "himsju",
"time": "1657559045",
"background_credit": "bbswitzer",
"reddit_title": "Bill Gates said I will always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it Whats a real-life example of this",
"filename": "Bill Gates said I will always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it Whats a real-l.mp4"
},
{
"subreddit": "askreddit",
"id": "kka536",
"time": "1657561674",
"background_credit": "bbswitzer",
"reddit_title": "What if Earth is like one of those uncontacted tribes in South America like the whole Galaxy knows were here but theyve agreed not to contact us until we figure it out for ourselves",
"filename": "What if Earth is like one of those uncontacted tribes in South America like the whole Galaxy knows were here but theyve agreed not to contac.mp4"
}
]

@ -146,10 +146,11 @@ def make_final_video(
"assets/temp/temp.mp4",
fps=30,
audio_codec="aac",
audio_bitrate="192k",
audio_bitrate="256k",
verbose=False,
codec="h264_nvenc",
threads=multiprocessing.cpu_count(),
ffmpeg_params=['--enable nvenc -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc -preset slow output"']
#ffmpeg_params=["-vcodec h264_nvenc"]
)

Loading…
Cancel
Save