style: formatted with black

pull/1107/head
Callum Leslie 3 years ago
parent fec2c22f44
commit 9140af9c02
No known key found for this signature in database
GPG Key ID: D382C4AFEECEAA90

@ -59,16 +59,11 @@ class TTSEngine:
self.call_tts("title", process_text(self.reddit_object["thread_title"])) self.call_tts("title", process_text(self.reddit_object["thread_title"]))
processed_text = process_text(self.reddit_object["thread_post"]) processed_text = process_text(self.reddit_object["thread_post"])
if ( if processed_text != "" and settings.config["settings"]["storymode"] == True:
processed_text != ""
and settings.config["settings"]["storymode"] == True
):
self.call_tts("posttext", processed_text) self.call_tts("posttext", processed_text)
idx = None idx = None
for idx, comment in track( for idx, comment in track(enumerate(self.reddit_object["comments"]), "Saving..."):
enumerate(self.reddit_object["comments"]), "Saving..."
):
# ! Stop creating mp3 files if the length is greater than max length. # ! Stop creating mp3 files if the length is greater than max length.
if self.length > self.max_length: if self.length > self.max_length:
self.length -= self.last_clip_length self.length -= self.last_clip_length
@ -95,15 +90,13 @@ class TTSEngine:
offset = 0 offset = 0
for idy, text_cut in enumerate(split_text): for idy, text_cut in enumerate(split_text):
# print(f"{idx}-{idy}: {text_cut}\n") # print(f"{idx}-{idy}: {text_cut}\n")
new_text = process_text(text_cut) new_text = process_text(text_cut)
if not new_text or new_text.isspace(): if not new_text or new_text.isspace():
offset += 1 offset += 1
continue continue
self.call_tts(f"{idx}-{idy - offset}.part", new_text) self.call_tts(f"{idx}-{idy - offset}.part", new_text)
split_files.append( split_files.append(AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3"))
AudioFileClip(f"{self.path}/{idx}-{idy - offset}.part.mp3")
)
CompositeAudioClip([concatenate_audioclips(split_files)]).write_audiofile( CompositeAudioClip([concatenate_audioclips(split_files)]).write_audiofile(
f"{self.path}/{idx}.mp3", fps=44100, verbose=False, logger=None f"{self.path}/{idx}.mp3", fps=44100, verbose=False, logger=None
@ -120,9 +113,7 @@ class TTSEngine:
# Path(f"{self.path}/{idx}-{i}.part.mp3").unlink() # Path(f"{self.path}/{idx}-{i}.part.mp3").unlink()
def call_tts(self, filename: str, text: str): def call_tts(self, filename: str, text: str):
self.tts_module.run( self.tts_module.run(text, filepath=f"{self.path}/{filename}.mp3")
text, filepath=f"{self.path}/{filename}.mp3"
)
# try: # try:
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length # self.length += MP3(f"{self.path}/{filename}.mp3").info.length
# except (MutagenError, HeaderNotFoundError): # except (MutagenError, HeaderNotFoundError):

@ -49,7 +49,7 @@ def download_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: in
print_substep("Post is NSFW. You are spicy...") print_substep("Post is NSFW. You are spicy...")
page.locator('[data-testid="content-gate"] button').click() page.locator('[data-testid="content-gate"] button').click()
page.wait_for_load_state() # Wait for page to fully load page.wait_for_load_state() # Wait for page to fully load
if page.locator('[data-click-id="text"] button').is_visible(): if page.locator('[data-click-id="text"] button').is_visible():
page.locator( page.locator(

Loading…
Cancel
Save