Skip to content

Commit 99de32e

Browse files
Version 3.2.1
2 parents 72a1e9d + 57e7b55 commit 99de32e

27 files changed

+192
-342
lines changed

.github/workflows/autoblack.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name: autoblack
77
on:
88
push:
9-
branches: ["master"]
9+
branches: ["develop"]
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
@@ -24,9 +24,9 @@ jobs:
2424
if: failure()
2525
run: |
2626
black . --line-length 101
27-
git config --global user.name 'autoblack'
28-
git config --global user.email 'jasoncameron.all@gmail.com'
27+
git config --global user.name github-actions
28+
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
2929
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
3030
git checkout $GITHUB_HEAD_REF
3131
git commit -am "fixup: Format Python code with Black"
32-
git push origin HEAD:master
32+
git push origin HEAD:develop

GUI.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ def settings():
8282
# Change settings
8383
config = gui.modify_settings(data, config_load, checks)
8484

85-
return render_template(
86-
"settings.html", file="config.toml", data=config, checks=checks
87-
)
85+
return render_template("settings.html", file="config.toml", data=config, checks=checks)
8886

8987

9088
# Make videos.json accessible

TTS/TikTok.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ def __init__(self):
8686
"Cookie": f"sessionid={settings.config['settings']['tts']['tiktok_sessionid']}",
8787
}
8888

89-
self.URI_BASE = (
90-
"https://api16-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke/"
91-
)
89+
self.URI_BASE = "https://api16-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke/"
9290
self.max_chars = 200
9391

9492
self._session = requests.Session()

TTS/aws_polly.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ def run(self, text, filepath, random_voice: bool = False):
4141
raise ValueError(
4242
f"Please set the TOML variable AWS_VOICE to a valid voice. options are: {voices}"
4343
)
44-
voice = str(
45-
settings.config["settings"]["tts"]["aws_polly_voice"]
46-
).capitalize()
44+
voice = str(settings.config["settings"]["tts"]["aws_polly_voice"]).capitalize()
4745
try:
4846
# Request speech synthesis
4947
response = polly.synthesize_speech(

TTS/elevenlabs.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def run(self, text, filepath, random_voice: bool = False):
2626
if random_voice:
2727
voice = self.randomvoice()
2828
else:
29-
voice = str(
30-
settings.config["settings"]["tts"]["elevenlabs_voice_name"]
31-
).capitalize()
29+
voice = str(settings.config["settings"]["tts"]["elevenlabs_voice_name"]).capitalize()
3230

3331
if settings.config["settings"]["tts"]["elevenlabs_api_key"]:
3432
api_key = settings.config["settings"]["tts"]["elevenlabs_api_key"]
@@ -37,9 +35,7 @@ def run(self, text, filepath, random_voice: bool = False):
3735
"You didn't set an Elevenlabs API key! Please set the config variable ELEVENLABS_API_KEY to a valid API key."
3836
)
3937

40-
audio = generate(
41-
api_key=api_key, text=text, voice=voice, model="eleven_multilingual_v1"
42-
)
38+
audio = generate(api_key=api_key, text=text, voice=voice, model="eleven_multilingual_v1")
4339
save(audio=audio, filename=filepath)
4440

4541
def randomvoice(self):

TTS/engine_wrapper.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
from utils.voice import sanitize_text
1616

1717

18-
DEFAULT_MAX_LENGTH: int = 50 # Video length variable, edit this on your own risk. It should work, but it's not supported
19-
18+
DEFAULT_MAX_LENGTH: int = (
19+
50 # Video length variable, edit this on your own risk. It should work, but it's not supported
20+
)
2021

2122

2223
class TTSEngine:
@@ -59,9 +60,7 @@ def add_periods(
5960
comment["comment_body"] = re.sub(regex_urls, " ", comment["comment_body"])
6061
comment["comment_body"] = comment["comment_body"].replace("\n", ". ")
6162
comment["comment_body"] = re.sub(r"\bAI\b", "A.I", comment["comment_body"])
62-
comment["comment_body"] = re.sub(
63-
r"\bAGI\b", "A.G.I", comment["comment_body"]
64-
)
63+
comment["comment_body"] = re.sub(r"\bAGI\b", "A.G.I", comment["comment_body"])
6564
if comment["comment_body"][-1] != ".":
6665
comment["comment_body"] += "."
6766
comment["comment_body"] = comment["comment_body"].replace(". . .", ".")
@@ -83,17 +82,13 @@ def run(self) -> Tuple[int, int]:
8382
if len(self.reddit_object["thread_post"]) > self.tts_module.max_chars:
8483
self.split_post(self.reddit_object["thread_post"], "postaudio")
8584
else:
86-
self.call_tts(
87-
"postaudio", process_text(self.reddit_object["thread_post"])
88-
)
85+
self.call_tts("postaudio", process_text(self.reddit_object["thread_post"]))
8986
elif settings.config["settings"]["storymodemethod"] == 1:
9087
for idx, text in track(enumerate(self.reddit_object["thread_post"])):
9188
self.call_tts(f"postaudio-{idx}", process_text(text))
9289

9390
else:
94-
for idx, comment in track(
95-
enumerate(self.reddit_object["comments"]), "Saving..."
96-
):
91+
for idx, comment in track(enumerate(self.reddit_object["comments"]), "Saving..."):
9792
# ! Stop creating mp3 files if the length is greater than max length.
9893
if self.length > self.max_length and idx > 1:
9994
self.length -= self.last_clip_length
@@ -176,16 +171,14 @@ def create_silence_mp3(self):
176171
fps=44100,
177172
)
178173
silence = volumex(silence, 0)
179-
silence.write_audiofile(
180-
f"{self.path}/silence.mp3", fps=44100, verbose=False, logger=None
181-
)
174+
silence.write_audiofile(f"{self.path}/silence.mp3", fps=44100, verbose=False, logger=None)
182175

183176

184177
def process_text(text: str, clean: bool = True):
185178
lang = settings.config["reddit"]["thread"]["post_lang"]
186179
new_text = sanitize_text(text) if clean else text
187180
if lang:
188181
print_substep("Translating Text...")
189-
translated_text = translators.google(text, to_language=lang)
182+
translated_text = translators.translate_text(text, translator="google", to_language=lang)
190183
new_text = sanitize_text(translated_text)
191184
return new_text

TTS/pyttsx.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def run(
2121
if voice_id == "" or voice_num == "":
2222
voice_id = 2
2323
voice_num = 3
24-
raise ValueError(
25-
"set pyttsx values to a valid value, switching to defaults"
26-
)
24+
raise ValueError("set pyttsx values to a valid value, switching to defaults")
2725
else:
2826
voice_id = int(voice_id)
2927
voice_num = int(voice_num)

TTS/streamlabs_polly.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def run(self, text, filepath, random_voice: bool = False):
4242
raise ValueError(
4343
f"Please set the config variable STREAMLABS_POLLY_VOICE to a valid voice. options are: {voices}"
4444
)
45-
voice = str(
46-
settings.config["settings"]["tts"]["streamlabs_polly_voice"]
47-
).capitalize()
45+
voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize()
4846
body = {"voice": voice, "text": text, "service": "polly"}
4947
response = requests.post(self.url, data=body)
5048
if not check_ratelimit(response):

main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from video_creation.voices import save_text_to_mp3
2626
from utils.ffmpeg_install import ffmpeg_install
2727

28-
__VERSION__ = "3.2"
28+
__VERSION__ = "3.2.1"
2929

3030
print(
3131
"""
@@ -74,22 +74,24 @@ def shutdown() -> NoReturn:
7474
if "redditid" in globals():
7575
print_markdown("## Clearing temp files")
7676
cleanup(redditid)
77-
77+
7878
print("Exiting...")
7979
sys.exit()
8080

8181

8282
if __name__ == "__main__":
8383
if sys.version_info.major != 3 or sys.version_info.minor != 10:
84-
print("Hey! Congratulations, you've made it so far (which is pretty rare with no Python 3.10). Unfortunately, this program only works on Python 3.10. Please install Python 3.10 and try again.")
84+
print(
85+
"Hey! Congratulations, you've made it so far (which is pretty rare with no Python 3.10). Unfortunately, this program only works on Python 3.10. Please install Python 3.10 and try again."
86+
)
8587
sys.exit()
8688
ffmpeg_install()
8789
directory = Path().absolute()
8890
config = settings.check_toml(
8991
f"{directory}/utils/.config.template.toml", f"{directory}/config.toml"
9092
)
9193
config is False and sys.exit()
92-
94+
9395
if (
9496
not settings.config["settings"]["tts"]["tiktok_sessionid"]
9597
or settings.config["settings"]["tts"]["tiktok_sessionid"] == ""
@@ -101,9 +103,7 @@ def shutdown() -> NoReturn:
101103
sys.exit()
102104
try:
103105
if config["reddit"]["thread"]["post_id"]:
104-
for index, post_id in enumerate(
105-
config["reddit"]["thread"]["post_id"].split("+")
106-
):
106+
for index, post_id in enumerate(config["reddit"]["thread"]["post_id"].split("+")):
107107
index += 1
108108
print_step(
109109
f'on the {index}{("st" if index % 10 == 1 else ("nd" if index % 10 == 2 else ("rd" if index % 10 == 3 else "th")))} post of {len(config["reddit"]["thread"]["post_id"].split("+"))}'

reddit/subreddit.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def get_subreddit_threads(POST_ID: str):
2424

2525
content = {}
2626
if settings.config["reddit"]["creds"]["2fa"]:
27-
print(
28-
"\nEnter your two-factor authentication code from your authenticator app.\n"
29-
)
27+
print("\nEnter your two-factor authentication code from your authenticator app.\n")
3028
code = input("> ")
3129
print()
3230
pw = settings.config["reddit"]["creds"]["password"]
@@ -59,9 +57,7 @@ def get_subreddit_threads(POST_ID: str):
5957
]: # note to user. you can have multiple subreddits via reddit.subreddit("redditdev+learnpython")
6058
try:
6159
subreddit = reddit.subreddit(
62-
re.sub(
63-
r"r\/", "", input("What subreddit would you like to pull from? ")
64-
)
60+
re.sub(r"r\/", "", input("What subreddit would you like to pull from? "))
6561
# removes the r/ from the input
6662
)
6763
except ValueError:
@@ -71,9 +67,7 @@ def get_subreddit_threads(POST_ID: str):
7167
sub = settings.config["reddit"]["thread"]["subreddit"]
7268
print_substep(f"Using subreddit: r/{sub} from TOML config")
7369
subreddit_choice = sub
74-
if (
75-
str(subreddit_choice).casefold().startswith("r/")
76-
): # removes the r/ from the input
70+
if str(subreddit_choice).casefold().startswith("r/"): # removes the r/ from the input
7771
subreddit_choice = subreddit_choice[2:]
7872
subreddit = reddit.subreddit(subreddit_choice)
7973

@@ -84,12 +78,8 @@ def get_subreddit_threads(POST_ID: str):
8478
settings.config["reddit"]["thread"]["post_id"]
8579
and len(str(settings.config["reddit"]["thread"]["post_id"]).split("+")) == 1
8680
):
87-
submission = reddit.submission(
88-
id=settings.config["reddit"]["thread"]["post_id"]
89-
)
90-
elif settings.config["ai"][
91-
"ai_similarity_enabled"
92-
]: # ai sorting based on comparison
81+
submission = reddit.submission(id=settings.config["reddit"]["thread"]["post_id"])
82+
elif settings.config["ai"]["ai_similarity_enabled"]: # ai sorting based on comparison
9383
threads = subreddit.hot(limit=50)
9484
keywords = settings.config["ai"]["ai_similarity_keywords"].split(",")
9585
keywords = [keyword.strip() for keyword in keywords]
@@ -107,10 +97,7 @@ def get_subreddit_threads(POST_ID: str):
10797
if submission is None:
10898
return get_subreddit_threads(POST_ID) # submission already done. rerun
10999

110-
elif (
111-
not submission.num_comments
112-
and settings.config["settings"]["storymode"] == "false"
113-
):
100+
elif not submission.num_comments and settings.config["settings"]["storymode"] == "false":
114101
print_substep("No comments found. Skipping.")
115102
exit()
116103

0 commit comments

Comments
 (0)