Merge pull request #205 from MeDBeD1/MeDBeD1-patch-1
Added TTS reading the text of the post if present
This commit is contained in:
5 files changed
+40
-27
No files matched your search
+3
-3
@@ -4,11 +4,11 @@ REDDIT_CLIENT_SECRET=""
|
||||
REDDIT_USERNAME=""
|
||||
REDDIT_PASSWORD=""
|
||||
|
||||
# Valid options are "yes" and "no"
|
||||
# Valid options are "yes" and "no"
|
||||
REDDIT_2FA=""
|
||||
|
||||
#If no, it will ask you a thread link to extract the thread, if yes it will randomize it.
|
||||
RANDOM_THREAD="no"
|
||||
#If no, it will ask you a thread link to extract the thread, if yes it will randomize it.
|
||||
RANDOM_THREAD="yes"
|
||||
|
||||
# Valid options are "light" and "dark"
|
||||
THEME=""
|
||||
|
||||
@@ -54,7 +54,7 @@ if not os.path.exists(".env"):
|
||||
console.log("[red] Your .env file is invalid, or was never created. Standby.")
|
||||
|
||||
for val in REQUIRED_VALUES:
|
||||
print(os.getenv(val))
|
||||
#print(os.getenv(val))
|
||||
if val not in os.environ or not os.getenv(val):
|
||||
console.log(f'[bold red]Missing Variable: "{val}"')
|
||||
configured = False
|
||||
@@ -70,8 +70,8 @@ for val in REQUIRED_VALUES:
|
||||
console.log("[bold green]Here goes nothing! Launching setup wizard...")
|
||||
time.sleep(0.5)
|
||||
os.system("python3 setup.py")
|
||||
else:
|
||||
if setup_ask == "no":
|
||||
|
||||
elif setup_ask == "no":
|
||||
console.print("[red]Exiting...")
|
||||
time.sleep(0.5)
|
||||
exit()
|
||||
@@ -79,8 +79,6 @@ for val in REQUIRED_VALUES:
|
||||
console.print("[red]I don't understand that. Exiting...")
|
||||
time.sleep(0.5)
|
||||
exit()
|
||||
|
||||
exit()
|
||||
try:
|
||||
float(os.getenv("OPACITY"))
|
||||
except:
|
||||
@@ -91,16 +89,6 @@ except:
|
||||
exit()
|
||||
console.log("[bold green]Enviroment Variables are set! Continuing...")
|
||||
|
||||
|
||||
length, number_of_comments = save_text_to_mp3(reddit_object)
|
||||
download_screenshots_of_reddit_posts(
|
||||
reddit_object, number_of_comments, os.getenv("THEME")
|
||||
)
|
||||
download_background()
|
||||
chop_background_video(length)
|
||||
final_video = make_final_video(number_of_comments)
|
||||
|
||||
|
||||
if configured:
|
||||
reddit_object = get_subreddit_threads()
|
||||
length, number_of_comments = save_text_to_mp3(reddit_object)
|
||||
|
||||
+2
-1
@@ -33,7 +33,7 @@ def get_subreddit_threads():
|
||||
username=os.getenv("REDDIT_USERNAME"),
|
||||
password=passkey,
|
||||
)
|
||||
|
||||
|
||||
# If the user specifies that he doesnt want a random thread, or if he doesn't insert the "RANDOM_THREAD" variable at all, ask the thread link
|
||||
if not os.getenv("RANDOM_THREAD") or os.getenv("RANDOM_THREAD") == "no":
|
||||
print_substep("Insert the full thread link:", style="bold green")
|
||||
@@ -62,6 +62,7 @@ def get_subreddit_threads():
|
||||
try:
|
||||
content["thread_url"] = submission.url
|
||||
content["thread_title"] = submission.title
|
||||
content["thread_post"] = submission.selftext
|
||||
content["comments"] = []
|
||||
|
||||
for top_level_comment in submission.comments:
|
||||
|
||||
@@ -40,6 +40,10 @@ def make_final_video(number_of_clips):
|
||||
for i in range(0, number_of_clips):
|
||||
audio_clips.append(AudioFileClip(f"assets/mp3/{i}.mp3"))
|
||||
audio_clips.insert(0, AudioFileClip(f"assets/mp3/title.mp3"))
|
||||
try:
|
||||
audio_clips.insert(1, AudioFileClip(f"assets/mp3/posttext.mp3"))
|
||||
except:
|
||||
OSError()
|
||||
audio_concat = concatenate_audioclips(audio_clips)
|
||||
audio_composite = CompositeAudioClip([audio_concat])
|
||||
|
||||
@@ -53,14 +57,24 @@ def make_final_video(number_of_clips):
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
image_clips.insert(
|
||||
0,
|
||||
ImageClip(f"assets/png/title.png")
|
||||
.set_duration(audio_clips[0].duration)
|
||||
.set_position("center")
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
if os.path.exists(f"assets/mp3/posttext.mp3"):
|
||||
image_clips.insert(
|
||||
0,
|
||||
ImageClip(f"assets/png/title.png")
|
||||
.set_duration(audio_clips[0].duration + audio_clips[1].duration)
|
||||
.set_position("center")
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
else:
|
||||
image_clips.insert(
|
||||
0,
|
||||
ImageClip(f"assets/png/title.png")
|
||||
.set_duration(audio_clips[0].duration)
|
||||
.set_position("center")
|
||||
.resize(width=W - 100)
|
||||
.set_opacity(float(opacity)),
|
||||
)
|
||||
image_concat = concatenate_videoclips(image_clips).set_position(
|
||||
("center", "center")
|
||||
)
|
||||
|
||||
@@ -21,6 +21,16 @@ def save_text_to_mp3(reddit_obj):
|
||||
tts.save(f"assets/mp3/title.mp3")
|
||||
length += MP3(f"assets/mp3/title.mp3").info.length
|
||||
|
||||
try:
|
||||
Path(f"assets/mp3/posttext.mp3").unlink()
|
||||
except OSError as e:
|
||||
pass
|
||||
|
||||
if reddit_obj["thread_post"] != "":
|
||||
tts = gTTS(text=reddit_obj["thread_post"], lang="en", slow=False)
|
||||
tts.save(f"assets/mp3/posttext.mp3")
|
||||
length += MP3(f"assets/mp3/posttext.mp3").info.length
|
||||
|
||||
for idx, comment in track(enumerate(reddit_obj["comments"]), "Saving..."):
|
||||
# ! Stop creating mp3 files if the length is greater than 50 seconds. This can be longer, but this is just a good starting point
|
||||
if length > 50:
|
||||
|
||||
Reference in new issue
Block a user