Skip to content

Commit

Permalink
Merge pull request #2060 from elebumm/develop
Browse files Browse the repository at this point in the history
Update 3.3.0
  • Loading branch information
JasonLovesDoggo authored Jun 16, 2024
2 parents 340762e + 6b474b4 commit c68c580
Show file tree
Hide file tree
Showing 29 changed files with 214 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
27 changes: 16 additions & 11 deletions .github/workflows/autoblack.yml → .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
# https://github.com/cclauss/autoblack

name: autoblack
name: fmt
on:
push:
branches: ["develop"]
jobs:
build:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Black
run: pip install black
- name: Run black --check .
run: black --check .
- name: If needed, commit black changes to the pull request
python-version: 3.10.14
- name: Install Black & isort
run: pip install black isort
- name: Run black check
run: black --check . --line-length 101
- name: Run isort check
run: isort . --check-only --diff --profile black
- name: If needed, commit changes to the pull request
if: failure()
run: |
black . --line-length 101
isort . --profile black
git config --global user.name github-actions
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: Format Python code with Black"
git push origin HEAD:develop
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--line-length 101"
- uses: isort/isort-action@v1
with:
configuration: "--check-only --diff --profile black"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

assets/
assets/temp
assets/backgrounds
/.vscode
out
.DS_Store
Expand All @@ -244,4 +245,4 @@ video_creation/data/videos.json
video_creation/data/envvars.txt

config.toml
*.exe
*.exe
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10.9-slim
FROM python:3.10.14-slim

RUN apt update
RUN apt-get install -y ffmpeg
Expand All @@ -9,8 +9,4 @@ ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt

# tricks for pytube : https://github.com/elebumm/RedditVideoMakerBot/issues/142
# (NOTE : This is no longer useful since pytube was removed from the dependencies)
# RUN sed -i 's/re.compile(r"^\\w+\\W")/re.compile(r"^\\$*\\w+\\W")/' /usr/local/lib/python3.8/dist-packages/pytube/cipher.py

CMD ["python3", "main.py"]
4 changes: 2 additions & 2 deletions GUI/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<select name="background_choice" class="form-select" data-toggle="tooltip"
data-original-title='Sets the background of the video'>
<option value=" ">Random Video</option>
{% for background in checks["background_choice"]["options"][1:] %}
{% for background in checks["background_video"]["options"][1:] %}
<option value="{{background}}">{{background}}</option>
{% endfor %}
</select>
Expand Down Expand Up @@ -618,4 +618,4 @@
});
</script>

{% endblock %}
{% endblock %}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ On macOS and Linux (debian, arch, fedora and centos, and based on those), you ca
This can also be used to update the installation

4. Run `python main.py`
5. Visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps), and set up an app that is a "script". Paste any URL in redirect URL. Ex:google.com
5. Visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps), and set up an app that is a "script". Paste any URL in redirect URL. Ex:`https://jasoncameron.dev`
6. The bot will ask you to fill in your details to connect to the Reddit API, and configure the bot to your liking
7. Enjoy 😎
8. If you need to reconfigure the bot, simply open the `config.toml` file and delete the lines that need to be changed. On the next run of the bot, it will help you reconfigure those options.
Expand Down Expand Up @@ -81,7 +81,7 @@ I have tried to simplify the code so anyone can read it and start contributing a

Please read our [contributing guidelines](CONTRIBUTING.md) for more detailed information.

### For any questions or support join the [Discord](https://discord.gg/WBQT52RrHV) server
### For any questions or support join the [Discord](https://discord.gg/qfQSx45xCV) server

## Developers and maintainers.

Expand All @@ -101,6 +101,8 @@ Freebiell (Freebie#3263) - https://github.com/FreebieII

Aman Raza (electro199#8130) - https://github.com/electro199

Cyteon (cyteon) - https://github.com/cyteon


## LICENSE
[Roboto Fonts](https://fonts.google.com/specimen/Roboto/about) are licensed under [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0)
2 changes: 1 addition & 1 deletion TTS/TikTok.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import base64
import random
import time
from typing import Optional, Final
from typing import Final, Optional

import requests

Expand Down
30 changes: 13 additions & 17 deletions TTS/elevenlabs.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
import random

from elevenlabs import generate, save
from elevenlabs import save
from elevenlabs.client import ElevenLabs

from utils import settings

voices = [
"Adam",
"Antoni",
"Arnold",
"Bella",
"Domi",
"Elli",
"Josh",
"Rachel",
"Sam",
]


class elevenlabs:
def __init__(self):
self.max_chars = 2500
self.voices = voices
self.client: ElevenLabs = None

def run(self, text, filepath, random_voice: bool = False):
if self.client is None:
self.initialize()
if random_voice:
voice = self.randomvoice()
else:
voice = str(settings.config["settings"]["tts"]["elevenlabs_voice_name"]).capitalize()

audio = self.client.generate(text=text, voice=voice, model="eleven_multilingual_v1")
save(audio=audio, filename=filepath)

def initialize(self):
if settings.config["settings"]["tts"]["elevenlabs_api_key"]:
api_key = settings.config["settings"]["tts"]["elevenlabs_api_key"]
else:
raise ValueError(
"You didn't set an Elevenlabs API key! Please set the config variable ELEVENLABS_API_KEY to a valid API key."
)

audio = generate(api_key=api_key, text=text, voice=voice, model="eleven_multilingual_v1")
save(audio=audio, filename=filepath)
self.client = ElevenLabs(api_key=api_key)

def randomvoice(self):
return random.choice(self.voices)
if self.client is None:
self.initialize()
return random.choice(self.client.voices.get_all().voices).voice_name
2 changes: 0 additions & 2 deletions TTS/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
from utils.console import print_step, print_substep
from utils.voice import sanitize_text


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


class TTSEngine:

"""Calls the given TTS engine to reduce code duplication and allow multiple TTS engines.
Args:
Expand Down
2 changes: 2 additions & 0 deletions TTS/streamlabs_polly.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def run(self, text, filepath, random_voice: bool = False):
f"Please set the config variable STREAMLABS_POLLY_VOICE to a valid voice. options are: {voices}"
)
voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize()

body = {"voice": voice, "text": text, "service": "polly"}
headers = {"Referer": "https://streamlabs.com/"}
response = requests.post(self.url, headers=headers, data=body)

if not check_ratelimit(response):
self.run(text, filepath, random_voice)

Expand Down
Binary file added assets/title_template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
from typing import NoReturn

from prawcore import ResponseException
from utils.console import print_substep

from reddit.subreddit import get_subreddit_threads
from utils import settings
from utils.cleanup import cleanup
from utils.console import print_markdown, print_step
from utils.console import print_markdown, print_step, print_substep
from utils.ffmpeg_install import ffmpeg_install
from utils.id import id
from utils.version import checkversion
from video_creation.background import (
download_background_video,
download_background_audio,
chop_background,
download_background_audio,
download_background_video,
get_background_config,
)
from video_creation.final_video import make_final_video
from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts
from video_creation.voices import save_text_to_mp3
from utils.ffmpeg_install import ffmpeg_install

__VERSION__ = "3.2.1"
__VERSION__ = "3.3.0"

print(
"""
Expand All @@ -37,7 +37,6 @@
╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
"""
)
# Modified by JasonLovesDoggo
print_markdown(
"### Thanks for using this tool! Feel free to contribute to this project on GitHub! If you have any questions, feel free to join my Discord server or submit a GitHub issue. You can find solutions to many common problems in the documentation: https://reddit-video-maker-bot.netlify.app/"
)
Expand Down
10 changes: 4 additions & 6 deletions reddit/subreddit.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import re

from prawcore.exceptions import ResponseException

from utils import settings
import praw
from praw.models import MoreComments
from prawcore.exceptions import ResponseException

from utils import settings
from utils.ai_methods import sort_by_similarity
from utils.console import print_step, print_substep
from utils.posttextparser import posttextparser
from utils.subreddit import get_subreddit_undone
from utils.videos import check_done
from utils.voice import sanitize_text
from utils.posttextparser import posttextparser
from utils.ai_methods import sort_by_similarity


def get_subreddit_threads(POST_ID: str):
Expand Down Expand Up @@ -106,7 +104,7 @@ def get_subreddit_threads(POST_ID: str):
upvotes = submission.score
ratio = submission.upvote_ratio * 100
num_comments = submission.num_comments
threadurl = f"https://reddit.com{submission.permalink}"
threadurl = f"https://new.reddit.com/{submission.permalink}"

print_substep(f"Video will be: {submission.title} :thumbsup:", style="bold green")
print_substep(f"Thread url is: {threadurl} :thumbsup:", style="bold green")
Expand Down
35 changes: 18 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
boto3==1.26.142
botocore==1.29.142
gTTS==2.3.2
boto3==1.34.127
botocore==1.34.127
gTTS==2.5.1
moviepy==1.0.3
playwright==1.34.0
praw==7.7.0
playwright==1.44.0
praw==7.7.1
prawcore~=2.3.0
requests==2.31.0
rich==13.4.1
requests==2.32.3
rich==13.7.1
toml==0.10.2
translators==5.7.6
translators==5.9.2
pyttsx3==2.90
Pillow==9.5.0
tomlkit==0.11.8
Flask==2.3.3
Pillow==10.3.0
tomlkit==0.12.5
Flask==3.0.3
clean-text==0.6.0
unidecode==1.3.6
spacy==3.5.3
torch==2.0.1
transformers==4.29.2
unidecode==1.3.8
spacy==3.7.5
torch==2.3.1
transformers==4.41.2
ffmpeg-python==0.2.0
elevenlabs==0.2.17
yt-dlp==2023.7.6
elevenlabs==1.3.0
yt-dlp==2024.5.27
numpy==1.26.4
3 changes: 2 additions & 1 deletion utils/.config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ storymode_max_length = { optional = true, default = 1000, example = 1000, explan
resolution_w = { optional = false, default = 1080, example = 1440, explantation = "Sets the width in pixels of the final video" }
resolution_h = { optional = false, default = 1920, example = 2560, explantation = "Sets the height in pixels of the final video" }
zoom = { optional = true, default = 1, example = 1.1, explanation = "Sets the browser zoom level. Useful if you want the text larger.", type = "float", nmin = 0.1, nmax = 2, oob_error = "The text is really difficult to read at a zoom level higher than 2" }
channel_name = { optional = true, default = "Reddit Tales", example = "Reddit Stories", explanation = "Sets the channel name for the video" }

[settings.background]
background_video = { optional = true, default = "minecraft", example = "rocket-league", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", "minecraft-2","multiversus","fall-guys","steep", ""], explanation = "Sets the background for the video based on game name" }
Expand All @@ -44,7 +45,7 @@ background_thumbnail_font_color = { optional = true, default = "255,255,255", ex

[settings.tts]
voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. " }
random_voice = { optional = false, default = true, example = true, type = "bool", options = [true, false,], explanation = "Randomizes the voice used for each comment" }
random_voice = { optional = false, type = "bool", default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" }
elevenlabs_voice_name = { optional = false, default = "Bella", example = "Bella", explanation = "The voice used for elevenlabs", options = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam", ] }
elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" }
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }
Expand Down
2 changes: 1 addition & 1 deletion utils/ai_methods.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from transformers import AutoTokenizer, AutoModel
import torch
from transformers import AutoModel, AutoTokenizer


# Mean Pooling - Take attention mask into account for correct averaging
Expand Down
2 changes: 1 addition & 1 deletion utils/cleanup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from os.path import exists
import shutil
from os.path import exists


def _listdir(d): # listdir with full path
Expand Down
Loading

0 comments on commit c68c580

Please sign in to comment.